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
ce4bdcd0
Commit
ce4bdcd0
authored
May 17, 2016
by
Jacek Caban
Committed by
Alexandre Julliard
May 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Rewrite test_accept_encoding using more generic request.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
aa475ce2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
15 deletions
+36
-15
http.c
dlls/wininet/tests/http.c
+36
-15
No files found.
dlls/wininet/tests/http.c
View file @
ce4bdcd0
...
@@ -475,6 +475,18 @@ static void _close_request(unsigned line, test_request_t *req)
...
@@ -475,6 +475,18 @@ static void _close_request(unsigned line, test_request_t *req)
ok_
(
__FILE__
,
line
)(
ret
,
"InternetCloseHandle(session) failed: %u
\n
"
,
GetLastError
());
ok_
(
__FILE__
,
line
)(
ret
,
"InternetCloseHandle(session) failed: %u
\n
"
,
GetLastError
());
}
}
#define receive_simple_request(a,b,c) _receive_simple_request(__LINE__,a,b,c)
static
DWORD
_receive_simple_request
(
unsigned
line
,
HINTERNET
req
,
char
*
buf
,
size_t
buf_size
)
{
DWORD
read
=
0
;
BOOL
ret
;
ret
=
InternetReadFile
(
req
,
buf
,
buf_size
,
&
read
);
ok_
(
__FILE__
,
line
)(
ret
,
"InternetReadFile failed: %u
\n
"
,
GetLastError
());
return
read
;
}
static
void
close_async_handle
(
HINTERNET
handle
,
HANDLE
complete_event
,
int
handle_cnt
)
static
void
close_async_handle
(
HINTERNET
handle
,
HANDLE
complete_event
,
int
handle_cnt
)
{
{
BOOL
res
;
BOOL
res
;
...
@@ -2055,7 +2067,8 @@ static DWORD CALLBACK server_thread(LPVOID param)
...
@@ -2055,7 +2067,8 @@ static DWORD CALLBACK server_thread(LPVOID param)
int
r
,
c
=
-
1
,
i
,
on
,
count
=
0
;
int
r
,
c
=
-
1
,
i
,
on
,
count
=
0
;
SOCKET
s
;
SOCKET
s
;
struct
sockaddr_in
sa
;
struct
sockaddr_in
sa
;
char
buffer
[
0x100
];
char
*
buffer
;
size_t
buffer_size
;
WSADATA
wsaData
;
WSADATA
wsaData
;
int
last_request
=
0
;
int
last_request
=
0
;
char
host_header
[
22
];
char
host_header
[
22
];
...
@@ -2086,16 +2099,20 @@ static DWORD CALLBACK server_thread(LPVOID param)
...
@@ -2086,16 +2099,20 @@ static DWORD CALLBACK server_thread(LPVOID param)
sprintf
(
host_header
,
"Host: localhost:%d"
,
si
->
port
);
sprintf
(
host_header
,
"Host: localhost:%d"
,
si
->
port
);
sprintf
(
host_header_override
,
"Host: test.local:%d
\r\n
"
,
si
->
port
);
sprintf
(
host_header_override
,
"Host: test.local:%d
\r\n
"
,
si
->
port
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
buffer_size
=
1000
);
do
do
{
{
if
(
c
==
-
1
)
if
(
c
==
-
1
)
c
=
accept
(
s
,
NULL
,
NULL
);
c
=
accept
(
s
,
NULL
,
NULL
);
memset
(
buffer
,
0
,
sizeof
buffer
);
memset
(
buffer
,
0
,
buffer_size
);
for
(
i
=
0
;
i
<
(
sizeof
buffer
-
1
)
;
i
++
)
for
(
i
=
0
;;
i
++
)
{
{
r
=
recv
(
c
,
&
buffer
[
i
],
1
,
0
);
if
(
i
==
buffer_size
)
buffer
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
buffer
,
buffer_size
*=
2
);
r
=
recv
(
c
,
buffer
+
i
,
1
,
0
);
if
(
r
!=
1
)
if
(
r
!=
1
)
break
;
break
;
if
(
i
<
4
)
continue
;
if
(
i
<
4
)
continue
;
...
@@ -2168,7 +2185,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
...
@@ -2168,7 +2185,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
if
(
strstr
(
buffer
,
"Content-Length: 100"
))
if
(
strstr
(
buffer
,
"Content-Length: 100"
))
{
{
if
(
strstr
(
buffer
,
"POST /test7b"
))
if
(
strstr
(
buffer
,
"POST /test7b"
))
recvfrom
(
c
,
buffer
,
sizeof
buffer
,
0
,
NULL
,
NULL
);
recvfrom
(
c
,
buffer
,
buffer_size
,
0
,
NULL
,
NULL
);
send
(
c
,
okmsg
,
sizeof
okmsg
-
1
,
0
);
send
(
c
,
okmsg
,
sizeof
okmsg
-
1
,
0
);
send
(
c
,
page1
,
sizeof
page1
-
1
,
0
);
send
(
c
,
page1
,
sizeof
page1
-
1
,
0
);
}
}
...
@@ -2259,7 +2276,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
...
@@ -2259,7 +2276,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
if
(
strstr
(
buffer
,
"GET /testH"
))
if
(
strstr
(
buffer
,
"GET /testH"
))
{
{
send
(
c
,
ok_with_length2
,
sizeof
(
ok_with_length2
)
-
1
,
0
);
send
(
c
,
ok_with_length2
,
sizeof
(
ok_with_length2
)
-
1
,
0
);
recvfrom
(
c
,
buffer
,
sizeof
(
buffer
)
,
0
,
NULL
,
NULL
);
recvfrom
(
c
,
buffer
,
buffer_size
,
0
,
NULL
,
NULL
);
send
(
c
,
ok_with_length
,
sizeof
(
ok_with_length
)
-
1
,
0
);
send
(
c
,
ok_with_length
,
sizeof
(
ok_with_length
)
-
1
,
0
);
}
}
...
@@ -2341,13 +2358,6 @@ static DWORD CALLBACK server_thread(LPVOID param)
...
@@ -2341,13 +2358,6 @@ static DWORD CALLBACK server_thread(LPVOID param)
}
}
if
(
strstr
(
buffer
,
"GET /test_premature_disconnect"
))
if
(
strstr
(
buffer
,
"GET /test_premature_disconnect"
))
trace
(
"closing connection
\n
"
);
trace
(
"closing connection
\n
"
);
if
(
strstr
(
buffer
,
"/test_accept_encoding_http10"
))
{
if
(
strstr
(
buffer
,
"Accept-Encoding: gzip"
))
send
(
c
,
okmsg
,
sizeof
okmsg
-
1
,
0
);
else
send
(
c
,
notokmsg
,
sizeof
notokmsg
-
1
,
0
);
}
if
(
strstr
(
buffer
,
"HEAD /upload.txt"
))
if
(
strstr
(
buffer
,
"HEAD /upload.txt"
))
{
{
if
(
strstr
(
buffer
,
"Authorization: Basic dXNlcjpwd2Q="
))
if
(
strstr
(
buffer
,
"Authorization: Basic dXNlcjpwd2Q="
))
...
@@ -2384,12 +2394,18 @@ static DWORD CALLBACK server_thread(LPVOID param)
...
@@ -2384,12 +2394,18 @@ static DWORD CALLBACK server_thread(LPVOID param)
SetEvent
(
server_req_rec_event
);
SetEvent
(
server_req_rec_event
);
WaitForSingleObject
(
conn_wait_event
,
INFINITE
);
WaitForSingleObject
(
conn_wait_event
,
INFINITE
);
}
}
if
(
strstr
(
buffer
,
"/echo_request"
))
{
send
(
c
,
okmsg
,
sizeof
(
okmsg
)
-
1
,
0
);
send
(
c
,
buffer
,
strlen
(
buffer
),
0
);
}
shutdown
(
c
,
2
);
shutdown
(
c
,
2
);
closesocket
(
c
);
closesocket
(
c
);
c
=
-
1
;
c
=
-
1
;
}
while
(
!
last_request
);
}
while
(
!
last_request
);
closesocket
(
s
);
closesocket
(
s
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
0
;
return
0
;
}
}
...
@@ -4250,6 +4266,7 @@ static void test_request_content_length(int port)
...
@@ -4250,6 +4266,7 @@ static void test_request_content_length(int port)
static
void
test_accept_encoding
(
int
port
)
static
void
test_accept_encoding
(
int
port
)
{
{
HINTERNET
ses
,
con
,
req
;
HINTERNET
ses
,
con
,
req
;
char
buf
[
1000
];
BOOL
ret
;
BOOL
ret
;
ses
=
InternetOpenA
(
"winetest"
,
INTERNET_OPEN_TYPE_DIRECT
,
NULL
,
NULL
,
0
);
ses
=
InternetOpenA
(
"winetest"
,
INTERNET_OPEN_TYPE_DIRECT
,
NULL
,
NULL
,
0
);
...
@@ -4258,7 +4275,7 @@ static void test_accept_encoding(int port)
...
@@ -4258,7 +4275,7 @@ static void test_accept_encoding(int port)
con
=
InternetConnectA
(
ses
,
"localhost"
,
port
,
NULL
,
NULL
,
INTERNET_SERVICE_HTTP
,
0
,
0
);
con
=
InternetConnectA
(
ses
,
"localhost"
,
port
,
NULL
,
NULL
,
INTERNET_SERVICE_HTTP
,
0
,
0
);
ok
(
con
!=
NULL
,
"InternetConnect failed
\n
"
);
ok
(
con
!=
NULL
,
"InternetConnect failed
\n
"
);
req
=
HttpOpenRequestA
(
con
,
"GET"
,
"/
test_accept_encoding_http10
"
,
"HTTP/1.0"
,
NULL
,
NULL
,
0
,
0
);
req
=
HttpOpenRequestA
(
con
,
"GET"
,
"/
echo_request
"
,
"HTTP/1.0"
,
NULL
,
NULL
,
0
,
0
);
ok
(
req
!=
NULL
,
"HttpOpenRequest failed
\n
"
);
ok
(
req
!=
NULL
,
"HttpOpenRequest failed
\n
"
);
ret
=
HttpAddRequestHeadersA
(
req
,
"Accept-Encoding: gzip
\r\n
"
,
~
0u
,
HTTP_ADDREQ_FLAG_REPLACE
|
HTTP_ADDREQ_FLAG_ADD
);
ret
=
HttpAddRequestHeadersA
(
req
,
"Accept-Encoding: gzip
\r\n
"
,
~
0u
,
HTTP_ADDREQ_FLAG_REPLACE
|
HTTP_ADDREQ_FLAG_ADD
);
...
@@ -4268,16 +4285,20 @@ static void test_accept_encoding(int port)
...
@@ -4268,16 +4285,20 @@ static void test_accept_encoding(int port)
ok
(
ret
,
"HttpSendRequestA failed
\n
"
);
ok
(
ret
,
"HttpSendRequestA failed
\n
"
);
test_status_code
(
req
,
200
);
test_status_code
(
req
,
200
);
receive_simple_request
(
req
,
buf
,
sizeof
(
buf
));
ok
(
strstr
(
buf
,
"Accept-Encoding: gzip"
)
!=
NULL
,
"Accept-Encoding header not found in %s
\n
"
,
buf
);
InternetCloseHandle
(
req
);
InternetCloseHandle
(
req
);
req
=
HttpOpenRequestA
(
con
,
"GET"
,
"/
test_accept_encoding_http10
"
,
"HTTP/1.0"
,
NULL
,
NULL
,
0
,
0
);
req
=
HttpOpenRequestA
(
con
,
"GET"
,
"/
echo_request
"
,
"HTTP/1.0"
,
NULL
,
NULL
,
0
,
0
);
ok
(
req
!=
NULL
,
"HttpOpenRequest failed
\n
"
);
ok
(
req
!=
NULL
,
"HttpOpenRequest failed
\n
"
);
ret
=
HttpSendRequestA
(
req
,
"Accept-Encoding: gzip"
,
~
0u
,
NULL
,
0
);
ret
=
HttpSendRequestA
(
req
,
"Accept-Encoding: gzip"
,
~
0u
,
NULL
,
0
);
ok
(
ret
,
"HttpSendRequestA failed
\n
"
);
ok
(
ret
,
"HttpSendRequestA failed
\n
"
);
test_status_code
(
req
,
200
);
test_status_code
(
req
,
200
);
receive_simple_request
(
req
,
buf
,
sizeof
(
buf
));
ok
(
strstr
(
buf
,
"Accept-Encoding: gzip"
)
!=
NULL
,
"Accept-Encoding header not found in %s
\n
"
,
buf
);
InternetCloseHandle
(
req
);
InternetCloseHandle
(
req
);
InternetCloseHandle
(
con
);
InternetCloseHandle
(
con
);
...
...
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