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
11b8243f
Commit
11b8243f
authored
Apr 08, 2024
by
Paul Gofman
Committed by
Alexandre Julliard
Apr 09, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp/tests: Add some tests for actual connection caching.
parent
5f931797
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
12 deletions
+102
-12
winhttp.c
dlls/winhttp/tests/winhttp.c
+102
-12
No files found.
dlls/winhttp/tests/winhttp.c
View file @
11b8243f
...
@@ -2197,6 +2197,12 @@ static const char okmsg[] =
...
@@ -2197,6 +2197,12 @@ static const char okmsg[] =
"Server: winetest
\r\n
"
"Server: winetest
\r\n
"
"
\r\n
"
;
"
\r\n
"
;
static
const
char
okmsg_length0
[]
=
"HTTP/1.1 200 OK
\r\n
"
"Server: winetest
\r\n
"
"Content-length: 0
\r\n
"
"
\r\n
"
;
static
const
char
notokmsg
[]
=
static
const
char
notokmsg
[]
=
"HTTP/1.1 400 Bad Request
\r\n
"
"HTTP/1.1 400 Bad Request
\r\n
"
"
\r\n
"
;
"
\r\n
"
;
...
@@ -2324,6 +2330,24 @@ static void create_websocket_accept(const char *key, char *buf, unsigned int buf
...
@@ -2324,6 +2330,24 @@ static void create_websocket_accept(const char *key, char *buf, unsigned int buf
CryptBinaryToStringA
(
(
BYTE
*
)
sha1
,
sizeof
(
sha1
),
CRYPT_STRING_BASE64
,
buf
,
&
len
);
CryptBinaryToStringA
(
(
BYTE
*
)
sha1
,
sizeof
(
sha1
),
CRYPT_STRING_BASE64
,
buf
,
&
len
);
}
}
static
int
server_receive_request
(
int
c
,
char
*
buffer
,
size_t
buffer_size
)
{
int
i
,
r
;
memset
(
buffer
,
0
,
buffer_size
);
for
(
i
=
0
;
i
<
buffer_size
-
1
;
i
++
)
{
r
=
recv
(
c
,
&
buffer
[
i
],
1
,
0
);
if
(
r
!=
1
)
break
;
if
(
i
<
4
)
continue
;
if
(
buffer
[
i
-
2
]
==
'\n'
&&
buffer
[
i
]
==
'\n'
&&
buffer
[
i
-
3
]
==
'\r'
&&
buffer
[
i
-
1
]
==
'\r'
)
break
;
}
return
r
;
}
static
DWORD
CALLBACK
server_thread
(
LPVOID
param
)
static
DWORD
CALLBACK
server_thread
(
LPVOID
param
)
{
{
struct
server_info
*
si
=
param
;
struct
server_info
*
si
=
param
;
...
@@ -2357,18 +2381,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
...
@@ -2357,18 +2381,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
do
do
{
{
if
(
c
==
-
1
)
c
=
accept
(
s
,
NULL
,
NULL
);
if
(
c
==
-
1
)
c
=
accept
(
s
,
NULL
,
NULL
);
server_receive_request
(
c
,
buffer
,
sizeof
(
buffer
));
memset
(
buffer
,
0
,
sizeof
buffer
);
for
(
i
=
0
;
i
<
sizeof
buffer
-
1
;
i
++
)
{
r
=
recv
(
c
,
&
buffer
[
i
],
1
,
0
);
if
(
r
!=
1
)
break
;
if
(
i
<
4
)
continue
;
if
(
buffer
[
i
-
2
]
==
'\n'
&&
buffer
[
i
]
==
'\n'
&&
buffer
[
i
-
3
]
==
'\r'
&&
buffer
[
i
-
1
]
==
'\r'
)
break
;
}
if
(
strstr
(
buffer
,
"GET /basic"
))
if
(
strstr
(
buffer
,
"GET /basic"
))
{
{
send
(
c
,
okmsg
,
sizeof
okmsg
-
1
,
0
);
send
(
c
,
okmsg
,
sizeof
okmsg
-
1
,
0
);
...
@@ -2569,6 +2582,23 @@ static DWORD CALLBACK server_thread(LPVOID param)
...
@@ -2569,6 +2582,23 @@ static DWORD CALLBACK server_thread(LPVOID param)
}
}
send
(
c
,
okmsg
,
sizeof
(
okmsg
)
-
1
,
0
);
send
(
c
,
okmsg
,
sizeof
(
okmsg
)
-
1
,
0
);
}
}
if
(
strstr
(
buffer
,
"GET /cached"
))
{
send
(
c
,
okmsg_length0
,
sizeof
okmsg_length0
-
1
,
0
);
r
=
server_receive_request
(
c
,
buffer
,
sizeof
(
buffer
));
ok
(
r
>
0
,
"got %d.
\n
"
,
r
);
ok
(
!!
strstr
(
buffer
,
"GET /cached"
),
"request not found.
\n
"
);
send
(
c
,
okmsg_length0
,
sizeof
okmsg_length0
-
1
,
0
);
r
=
server_receive_request
(
c
,
buffer
,
sizeof
(
buffer
));
todo_wine
ok
(
!
r
,
"got %d, buffer[0] %d.
\n
"
,
r
,
buffer
[
0
]);
}
if
(
strstr
(
buffer
,
"GET /notcached"
))
{
send
(
c
,
okmsg
,
sizeof
okmsg
-
1
,
0
);
r
=
server_receive_request
(
c
,
buffer
,
sizeof
(
buffer
));
ok
(
!
r
,
"got %d, buffer[0] %d.
\n
"
,
r
,
buffer
[
0
]
);
}
shutdown
(
c
,
2
);
shutdown
(
c
,
2
);
closesocket
(
c
);
closesocket
(
c
);
c
=
-
1
;
c
=
-
1
;
...
@@ -5884,6 +5914,65 @@ static void test_client_cert_authentication(void)
...
@@ -5884,6 +5914,65 @@ static void test_client_cert_authentication(void)
WinHttpCloseHandle
(
ses
);
WinHttpCloseHandle
(
ses
);
}
}
static
void
test_connection_cache
(
int
port
)
{
HINTERNET
ses
,
con
,
req
;
DWORD
status
,
size
;
char
buffer
[
256
];
BOOL
ret
;
ses
=
WinHttpOpen
(
L"winetest"
,
WINHTTP_ACCESS_TYPE_NO_PROXY
,
NULL
,
NULL
,
0
);
ok
(
ses
!=
NULL
,
"failed to open session %lu
\n
"
,
GetLastError
());
con
=
WinHttpConnect
(
ses
,
L"localhost"
,
port
,
0
);
ok
(
con
!=
NULL
,
"failed to open a connection %lu
\n
"
,
GetLastError
());
req
=
WinHttpOpenRequest
(
con
,
L"GET"
,
L"/cached"
,
NULL
,
NULL
,
NULL
,
0
);
ok
(
req
!=
NULL
,
"failed to open a request %lu
\n
"
,
GetLastError
());
ret
=
WinHttpSendRequest
(
req
,
NULL
,
0
,
NULL
,
0
,
0
,
0
);
ok
(
ret
,
"failed to send request %lu
\n
"
,
GetLastError
());
ret
=
WinHttpReceiveResponse
(
req
,
NULL
);
ok
(
ret
,
"failed to receive response %lu
\n
"
,
GetLastError
());
size
=
sizeof
(
status
);
ret
=
WinHttpQueryHeaders
(
req
,
WINHTTP_QUERY_STATUS_CODE
|
WINHTTP_QUERY_FLAG_NUMBER
,
NULL
,
&
status
,
&
size
,
NULL
);
ok
(
ret
,
"failed to query status code %lu
\n
"
,
GetLastError
());
ok
(
status
==
HTTP_STATUS_OK
,
"request failed unexpectedly %lu
\n
"
,
status
);
ret
=
WinHttpReadData
(
req
,
buffer
,
sizeof
buffer
,
&
size
);
ok
(
ret
,
"failed to read data %lu
\n
"
,
GetLastError
());
ok
(
!
size
,
"got size %lu.
\n
"
,
size
);
WinHttpCloseHandle
(
req
);
req
=
WinHttpOpenRequest
(
con
,
L"GET"
,
L"/cached"
,
NULL
,
NULL
,
NULL
,
0
);
ok
(
req
!=
NULL
,
"failed to open a request %lu
\n
"
,
GetLastError
());
ret
=
WinHttpSendRequest
(
req
,
L"Connection: close"
,
~
0ul
,
NULL
,
0
,
0
,
0
);
ok
(
ret
,
"failed to send request %lu
\n
"
,
GetLastError
());
ret
=
WinHttpReceiveResponse
(
req
,
NULL
);
ok
(
ret
,
"failed to receive response %lu
\n
"
,
GetLastError
());
size
=
sizeof
(
status
);
ret
=
WinHttpQueryHeaders
(
req
,
WINHTTP_QUERY_STATUS_CODE
|
WINHTTP_QUERY_FLAG_NUMBER
,
NULL
,
&
status
,
&
size
,
NULL
);
ok
(
ret
,
"failed to query status code %lu
\n
"
,
GetLastError
());
ok
(
status
==
HTTP_STATUS_OK
,
"request failed unexpectedly %lu
\n
"
,
status
);
ret
=
WinHttpReadData
(
req
,
buffer
,
sizeof
buffer
,
&
size
);
ok
(
ret
,
"failed to read data %lu
\n
"
,
GetLastError
());
ok
(
!
size
,
"got size %lu.
\n
"
,
size
);
WinHttpCloseHandle
(
req
);
req
=
WinHttpOpenRequest
(
con
,
L"GET"
,
L"/notcached"
,
NULL
,
NULL
,
NULL
,
0
);
ok
(
req
!=
NULL
,
"failed to open a request %lu
\n
"
,
GetLastError
());
ret
=
WinHttpSendRequest
(
req
,
L"Connection: close"
,
~
0ul
,
NULL
,
0
,
0
,
0
);
ok
(
ret
,
"failed to send request %lu
\n
"
,
GetLastError
());
ret
=
WinHttpReceiveResponse
(
req
,
NULL
);
ok
(
ret
,
"failed to receive response %lu
\n
"
,
GetLastError
());
size
=
sizeof
(
status
);
ret
=
WinHttpQueryHeaders
(
req
,
WINHTTP_QUERY_STATUS_CODE
|
WINHTTP_QUERY_FLAG_NUMBER
,
NULL
,
&
status
,
&
size
,
NULL
);
ok
(
ret
,
"failed to query status code %lu
\n
"
,
GetLastError
());
ok
(
status
==
HTTP_STATUS_OK
,
"request failed unexpectedly %lu
\n
"
,
status
);
WinHttpCloseHandle
(
req
);
WinHttpCloseHandle
(
con
);
WinHttpCloseHandle
(
ses
);
}
START_TEST
(
winhttp
)
START_TEST
(
winhttp
)
{
{
struct
server_info
si
;
struct
server_info
si
;
...
@@ -5951,6 +6040,7 @@ START_TEST (winhttp)
...
@@ -5951,6 +6040,7 @@ START_TEST (winhttp)
test_websocket
(
si
.
port
);
test_websocket
(
si
.
port
);
test_redirect
(
si
.
port
);
test_redirect
(
si
.
port
);
test_WinHttpGetProxyForUrl
(
si
.
port
);
test_WinHttpGetProxyForUrl
(
si
.
port
);
test_connection_cache
(
si
.
port
);
/* send the basic request again to shutdown the server thread */
/* send the basic request again to shutdown the server thread */
test_basic_request
(
si
.
port
,
NULL
,
L"/quit"
);
test_basic_request
(
si
.
port
,
NULL
,
L"/quit"
);
...
...
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