Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
27ba8c83
Commit
27ba8c83
authored
Jan 21, 2015
by
Hans Leidekker
Committed by
Alexandre Julliard
Jan 21, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp: Don't try to read data after a HEAD request.
parent
142ac824
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
13 deletions
+91
-13
request.c
dlls/winhttp/request.c
+21
-13
winhttp.c
dlls/winhttp/tests/winhttp.c
+70
-0
No files found.
dlls/winhttp/request.c
View file @
27ba8c83
...
@@ -1807,20 +1807,23 @@ static DWORD set_content_length( request_t *request, DWORD status )
...
@@ -1807,20 +1807,23 @@ static DWORD set_content_length( request_t *request, DWORD status )
WCHAR
encoding
[
20
];
WCHAR
encoding
[
20
];
DWORD
buflen
=
sizeof
(
request
->
content_length
);
DWORD
buflen
=
sizeof
(
request
->
content_length
);
if
(
status
==
HTTP_STATUS_NO_CONTENT
||
status
==
HTTP_STATUS_NOT_MODIFIED
)
if
(
status
==
HTTP_STATUS_NO_CONTENT
||
status
==
HTTP_STATUS_NOT_MODIFIED
||
!
strcmpW
(
request
->
verb
,
headW
)
)
request
->
content_length
=
0
;
request
->
content_length
=
0
;
else
if
(
!
query_headers
(
request
,
WINHTTP_QUERY_CONTENT_LENGTH
|
WINHTTP_QUERY_FLAG_NUMBER
,
else
NULL
,
&
request
->
content_length
,
&
buflen
,
NULL
))
request
->
content_length
=
~
0u
;
buflen
=
sizeof
(
encoding
);
if
(
query_headers
(
request
,
WINHTTP_QUERY_TRANSFER_ENCODING
,
NULL
,
encoding
,
&
buflen
,
NULL
)
&&
!
strcmpiW
(
encoding
,
chunkedW
))
{
{
request
->
content_length
=
~
0u
;
if
(
!
query_headers
(
request
,
WINHTTP_QUERY_CONTENT_LENGTH
|
WINHTTP_QUERY_FLAG_NUMBER
,
request
->
read_chunked
=
TRUE
;
NULL
,
&
request
->
content_length
,
&
buflen
,
NULL
))
request
->
read_chunked_size
=
~
0u
;
request
->
content_length
=
~
0u
;
request
->
read_chunked_eof
=
FALSE
;
buflen
=
sizeof
(
encoding
);
if
(
query_headers
(
request
,
WINHTTP_QUERY_TRANSFER_ENCODING
,
NULL
,
encoding
,
&
buflen
,
NULL
)
&&
!
strcmpiW
(
encoding
,
chunkedW
))
{
request
->
content_length
=
~
0u
;
request
->
read_chunked
=
TRUE
;
request
->
read_chunked_size
=
~
0u
;
request
->
read_chunked_eof
=
FALSE
;
}
}
}
request
->
content_read
=
0
;
request
->
content_read
=
0
;
return
request
->
content_length
;
return
request
->
content_length
;
...
@@ -1969,6 +1972,7 @@ static DWORD get_available_data( request_t *request )
...
@@ -1969,6 +1972,7 @@ static DWORD get_available_data( request_t *request )
/* check if we have reached the end of the data to read */
/* check if we have reached the end of the data to read */
static
BOOL
end_of_read_data
(
request_t
*
request
)
static
BOOL
end_of_read_data
(
request_t
*
request
)
{
{
if
(
!
request
->
content_length
)
return
TRUE
;
if
(
request
->
read_chunked
)
return
request
->
read_chunked_eof
;
if
(
request
->
read_chunked
)
return
request
->
read_chunked_eof
;
if
(
request
->
content_length
==
~
0u
)
return
FALSE
;
if
(
request
->
content_length
==
~
0u
)
return
FALSE
;
return
(
request
->
content_length
==
request
->
content_read
);
return
(
request
->
content_length
==
request
->
content_read
);
...
@@ -2394,8 +2398,11 @@ BOOL WINAPI WinHttpReceiveResponse( HINTERNET hrequest, LPVOID reserved )
...
@@ -2394,8 +2398,11 @@ BOOL WINAPI WinHttpReceiveResponse( HINTERNET hrequest, LPVOID reserved )
static
BOOL
query_data_available
(
request_t
*
request
,
DWORD
*
available
,
BOOL
async
)
static
BOOL
query_data_available
(
request_t
*
request
,
DWORD
*
available
,
BOOL
async
)
{
{
DWORD
count
=
get_available_data
(
request
);
DWORD
count
=
0
;
if
(
end_of_read_data
(
request
))
goto
done
;
count
=
get_available_data
(
request
);
if
(
!
request
->
read_chunked
)
if
(
!
request
->
read_chunked
)
count
+=
netconn_query_data_available
(
&
request
->
netconn
);
count
+=
netconn_query_data_available
(
&
request
->
netconn
);
if
(
!
count
)
if
(
!
count
)
...
@@ -2406,6 +2413,7 @@ static BOOL query_data_available( request_t *request, DWORD *available, BOOL asy
...
@@ -2406,6 +2413,7 @@ static BOOL query_data_available( request_t *request, DWORD *available, BOOL asy
count
+=
netconn_query_data_available
(
&
request
->
netconn
);
count
+=
netconn_query_data_available
(
&
request
->
netconn
);
}
}
done:
if
(
async
)
send_callback
(
&
request
->
hdr
,
WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE
,
&
count
,
sizeof
(
count
)
);
if
(
async
)
send_callback
(
&
request
->
hdr
,
WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE
,
&
count
,
sizeof
(
count
)
);
TRACE
(
"%u bytes available
\n
"
,
count
);
TRACE
(
"%u bytes available
\n
"
,
count
);
if
(
available
)
*
available
=
count
;
if
(
available
)
*
available
=
count
;
...
...
dlls/winhttp/tests/winhttp.c
View file @
27ba8c83
...
@@ -1818,6 +1818,11 @@ static const char okauthmsg[] =
...
@@ -1818,6 +1818,11 @@ static const char okauthmsg[] =
"Connection: close
\r\n
"
"Connection: close
\r\n
"
"
\r\n
"
;
"
\r\n
"
;
static
const
char
headmsg
[]
=
"HTTP/1.1 200 OK
\r\n
"
"Content-Length: 100
\r\n
"
"
\r\n
"
;
struct
server_info
struct
server_info
{
{
HANDLE
event
;
HANDLE
event
;
...
@@ -1904,6 +1909,11 @@ static DWORD CALLBACK server_thread(LPVOID param)
...
@@ -1904,6 +1909,11 @@ static DWORD CALLBACK server_thread(LPVOID param)
send
(
c
,
notmodified
,
sizeof
notmodified
-
1
,
0
);
send
(
c
,
notmodified
,
sizeof
notmodified
-
1
,
0
);
continue
;
continue
;
}
}
if
(
strstr
(
buffer
,
"HEAD /head"
))
{
send
(
c
,
headmsg
,
sizeof
headmsg
-
1
,
0
);
continue
;
}
if
(
strstr
(
buffer
,
"GET /quit"
))
if
(
strstr
(
buffer
,
"GET /quit"
))
{
{
send
(
c
,
okmsg
,
sizeof
okmsg
-
1
,
0
);
send
(
c
,
okmsg
,
sizeof
okmsg
-
1
,
0
);
...
@@ -2220,6 +2230,65 @@ static void test_no_content(int port)
...
@@ -2220,6 +2230,65 @@ static void test_no_content(int port)
WinHttpCloseHandle
(
ses
);
WinHttpCloseHandle
(
ses
);
}
}
static
void
test_head_request
(
int
port
)
{
static
const
WCHAR
verbW
[]
=
{
'H'
,
'E'
,
'A'
,
'D'
,
0
};
static
const
WCHAR
headW
[]
=
{
'/'
,
'h'
,
'e'
,
'a'
,
'd'
,
0
};
HINTERNET
ses
,
con
,
req
;
char
buf
[
128
];
DWORD
size
,
len
,
count
,
status
;
BOOL
ret
;
ses
=
WinHttpOpen
(
test_useragent
,
0
,
NULL
,
NULL
,
0
);
ok
(
ses
!=
NULL
,
"failed to open session %u
\n
"
,
GetLastError
());
con
=
WinHttpConnect
(
ses
,
localhostW
,
port
,
0
);
ok
(
con
!=
NULL
,
"failed to open a connection %u
\n
"
,
GetLastError
());
req
=
WinHttpOpenRequest
(
con
,
verbW
,
headW
,
NULL
,
NULL
,
NULL
,
0
);
ok
(
req
!=
NULL
,
"failed to open a request %u
\n
"
,
GetLastError
());
ret
=
WinHttpSendRequest
(
req
,
NULL
,
0
,
NULL
,
0
,
0
,
0
);
ok
(
ret
,
"failed to send request %u
\n
"
,
GetLastError
());
ret
=
WinHttpReceiveResponse
(
req
,
NULL
);
ok
(
ret
,
"failed to receive response %u
\n
"
,
GetLastError
());
status
=
0xdeadbeef
;
size
=
sizeof
(
status
);
ret
=
WinHttpQueryHeaders
(
req
,
WINHTTP_QUERY_STATUS_CODE
|
WINHTTP_QUERY_FLAG_NUMBER
,
NULL
,
&
status
,
&
size
,
NULL
);
ok
(
ret
,
"failed to get status code %u
\n
"
,
GetLastError
());
ok
(
status
==
200
,
"got %u
\n
"
,
status
);
len
=
0xdeadbeef
;
size
=
sizeof
(
len
);
ret
=
WinHttpQueryHeaders
(
req
,
WINHTTP_QUERY_CONTENT_LENGTH
|
WINHTTP_QUERY_FLAG_NUMBER
,
NULL
,
&
len
,
&
size
,
0
);
ok
(
ret
,
"failed to get content-length header %u
\n
"
,
GetLastError
());
ok
(
len
==
100
,
"got %u
\n
"
,
len
);
count
=
0xdeadbeef
;
ret
=
WinHttpQueryDataAvailable
(
req
,
&
count
);
ok
(
ret
,
"failed to query data available %u
\n
"
,
GetLastError
());
ok
(
!
count
,
"got %u
\n
"
,
count
);
len
=
sizeof
(
buf
);
count
=
0xdeadbeef
;
ret
=
WinHttpReadData
(
req
,
buf
,
len
,
&
count
);
ok
(
ret
,
"failed to read data %u
\n
"
,
GetLastError
());
ok
(
!
count
,
"got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
ret
=
WinHttpQueryDataAvailable
(
req
,
&
count
);
ok
(
ret
,
"failed to query data available %u
\n
"
,
GetLastError
());
ok
(
!
count
,
"got %u
\n
"
,
count
);
WinHttpCloseHandle
(
req
);
WinHttpCloseHandle
(
con
);
WinHttpCloseHandle
(
ses
);
}
static
void
test_not_modified
(
int
port
)
static
void
test_not_modified
(
int
port
)
{
{
static
const
WCHAR
pathW
[]
=
{
'/'
,
'n'
,
'o'
,
't'
,
'_'
,
'm'
,
'o'
,
'd'
,
'i'
,
'f'
,
'i'
,
'e'
,
'd'
,
0
};
static
const
WCHAR
pathW
[]
=
{
'/'
,
'n'
,
'o'
,
't'
,
'_'
,
'm'
,
'o'
,
'd'
,
'i'
,
'f'
,
'i'
,
'e'
,
'd'
,
0
};
...
@@ -3278,6 +3347,7 @@ START_TEST (winhttp)
...
@@ -3278,6 +3347,7 @@ START_TEST (winhttp)
test_basic_request
(
si
.
port
,
NULL
,
basicW
);
test_basic_request
(
si
.
port
,
NULL
,
basicW
);
test_no_headers
(
si
.
port
);
test_no_headers
(
si
.
port
);
test_no_content
(
si
.
port
);
test_no_content
(
si
.
port
);
test_head_request
(
si
.
port
);
test_not_modified
(
si
.
port
);
test_not_modified
(
si
.
port
);
test_basic_authentication
(
si
.
port
);
test_basic_authentication
(
si
.
port
);
test_bad_header
(
si
.
port
);
test_bad_header
(
si
.
port
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment