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
eeb3e86f
Commit
eeb3e86f
authored
Mar 01, 2011
by
Juan Lang
Committed by
Alexandre Julliard
Mar 02, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet/tests: Test retrieving http requests from cache.
parent
2098006d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
0 deletions
+91
-0
http.c
dlls/wininet/tests/http.c
+91
-0
No files found.
dlls/wininet/tests/http.c
View file @
eeb3e86f
...
...
@@ -1202,6 +1202,19 @@ static void test_http_cache(void)
ok
(
file
!=
INVALID_HANDLE_VALUE
,
"Could not create file: %u
\n
"
,
GetLastError
());
CloseHandle
(
file
);
/* Send the same request, requiring it to be retrieved from the cache */
request
=
HttpOpenRequest
(
connect
,
"GET"
,
"/hello.html"
,
NULL
,
NULL
,
NULL
,
INTERNET_FLAG_FROM_CACHE
,
0
);
ret
=
HttpSendRequest
(
request
,
NULL
,
0
,
NULL
,
0
);
ok
(
ret
,
"HttpSendRequest failed
\n
"
);
size
=
sizeof
(
buf
);
ret
=
InternetReadFile
(
request
,
buf
,
sizeof
(
buf
),
&
size
);
ok
(
ret
,
"InternetReadFile failed: %u
\n
"
,
GetLastError
());
ok
(
size
==
100
,
"size = %u
\n
"
,
size
);
ok
(
InternetCloseHandle
(
request
),
"Close request handle failed
\n
"
);
request
=
HttpOpenRequestA
(
connect
,
NULL
,
"/"
,
NULL
,
NULL
,
types
,
INTERNET_FLAG_NO_CACHE_WRITE
,
0
);
ok
(
request
!=
NULL
,
"Failed to open request handle err %u
\n
"
,
GetLastError
());
...
...
@@ -1602,6 +1615,7 @@ static const char page1[] =
struct
server_info
{
HANDLE
hEvent
;
int
port
;
int
num_testH_retrievals
;
};
static
DWORD
CALLBACK
server_thread
(
LPVOID
param
)
...
...
@@ -1792,6 +1806,17 @@ static DWORD CALLBACK server_thread(LPVOID param)
{
send
(
c
,
page1
,
sizeof
page1
-
1
,
0
);
}
if
(
strstr
(
buffer
,
"GET /testH"
))
{
si
->
num_testH_retrievals
++
;
if
(
!
strstr
(
buffer
,
"Content-Length: 0"
))
{
send
(
c
,
okmsg
,
sizeof
okmsg
-
1
,
0
);
send
(
c
,
page1
,
sizeof
page1
-
1
,
0
);
}
else
send
(
c
,
notokmsg
,
sizeof
notokmsg
-
1
,
0
);
}
shutdown
(
c
,
2
);
closesocket
(
c
);
...
...
@@ -2575,6 +2600,70 @@ static void test_options(int port)
InternetCloseHandle
(
ses
);
}
static
void
test_url_caching
(
int
port
,
int
*
num_retrievals
)
{
HINTERNET
hi
,
hc
,
hr
;
DWORD
r
,
count
;
char
buffer
[
0x100
];
ok
(
*
num_retrievals
==
0
,
"expected 0 retrievals prior to test
\n
"
);
hi
=
InternetOpen
(
NULL
,
INTERNET_OPEN_TYPE_DIRECT
,
NULL
,
NULL
,
0
);
ok
(
hi
!=
NULL
,
"open failed
\n
"
);
hc
=
InternetConnect
(
hi
,
"localhost"
,
port
,
NULL
,
NULL
,
INTERNET_SERVICE_HTTP
,
0
,
0
);
ok
(
hc
!=
NULL
,
"connect failed
\n
"
);
/* Pre-load the cache: */
hr
=
HttpOpenRequest
(
hc
,
"GET"
,
"/testH"
,
NULL
,
NULL
,
NULL
,
0
,
0
);
ok
(
hr
!=
NULL
,
"HttpOpenRequest failed
\n
"
);
r
=
HttpSendRequest
(
hr
,
NULL
,
0
,
NULL
,
0
);
ok
(
r
,
"HttpSendRequest failed
\n
"
);
ok
(
*
num_retrievals
==
1
,
"expected 1 retrievals
\n
"
);
count
=
0
;
memset
(
buffer
,
0
,
sizeof
buffer
);
SetLastError
(
0xdeadbeef
);
r
=
InternetReadFile
(
hr
,
buffer
,
sizeof
buffer
,
&
count
);
ok
(
r
,
"InternetReadFile failed %u
\n
"
,
GetLastError
());
ok
(
count
==
sizeof
page1
-
1
,
"count was wrong
\n
"
);
ok
(
!
memcmp
(
buffer
,
page1
,
sizeof
page1
),
"http data wrong
\n
"
);
InternetCloseHandle
(
hr
);
/* Send the same request, requiring it to be retrieved from the cache */
hr
=
HttpOpenRequest
(
hc
,
"GET"
,
"/testH"
,
NULL
,
NULL
,
NULL
,
INTERNET_FLAG_FROM_CACHE
,
0
);
ok
(
hr
!=
NULL
,
"HttpOpenRequest failed
\n
"
);
r
=
HttpSendRequest
(
hr
,
NULL
,
0
,
NULL
,
0
);
/* Older Windows versions succeed with this request, newer ones fail with
* ERROR_FILE_NOT_FOUND. Accept either, as the older version allows us
* to verify that the server isn't contacted.
*/
if
(
!
r
)
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"expected ERROR_FILE_NOT_FOUND, got %d
\n
"
,
GetLastError
());
else
{
/* The server shouldn't be contacted for this request. */
todo_wine
ok
(
*
num_retrievals
==
1
,
"expected 1 retrievals
\n
"
);
count
=
0
;
memset
(
buffer
,
0
,
sizeof
buffer
);
SetLastError
(
0xdeadbeef
);
r
=
InternetReadFile
(
hr
,
buffer
,
sizeof
buffer
,
&
count
);
ok
(
r
,
"InternetReadFile failed %u
\n
"
,
GetLastError
());
ok
(
count
==
sizeof
page1
-
1
,
"count was wrong
\n
"
);
ok
(
!
memcmp
(
buffer
,
page1
,
sizeof
page1
),
"http data wrong
\n
"
);
}
InternetCloseHandle
(
hc
);
InternetCloseHandle
(
hi
);
}
static
void
test_http_connection
(
void
)
{
struct
server_info
si
;
...
...
@@ -2583,6 +2672,7 @@ static void test_http_connection(void)
si
.
hEvent
=
CreateEvent
(
NULL
,
0
,
0
,
NULL
);
si
.
port
=
7531
;
si
.
num_testH_retrievals
=
0
;
hThread
=
CreateThread
(
NULL
,
0
,
server_thread
,
(
LPVOID
)
&
si
,
0
,
&
id
);
ok
(
hThread
!=
NULL
,
"create thread failed
\n
"
);
...
...
@@ -2611,6 +2701,7 @@ static void test_http_connection(void)
test_HttpSendRequestW
(
si
.
port
);
test_last_error
(
si
.
port
);
test_options
(
si
.
port
);
test_url_caching
(
si
.
port
,
&
si
.
num_testH_retrievals
);
/* send the basic request again to shutdown the server thread */
test_basic_request
(
si
.
port
,
"GET"
,
"/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