2 * test status notifications
4 * Copyright 2008 Hans Leidekker for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
29 static const WCHAR user_agent
[] = {'w','i','n','e','t','e','s','t',0};
36 winhttp_receive_response
,
45 enum api function
; /* api responsible for notification */
46 unsigned int status
; /* status received */
49 int skipped_for_proxy
;
55 const struct notification
*test
;
62 static BOOL
proxy_active(void)
64 WINHTTP_PROXY_INFO proxy_info
;
67 if (WinHttpGetDefaultProxyConfiguration(&proxy_info
))
69 active
= (proxy_info
.lpszProxy
!= NULL
);
71 GlobalFree(proxy_info
.lpszProxy
);
72 if (proxy_info
.lpszProxyBypass
!= NULL
)
73 GlobalFree(proxy_info
.lpszProxyBypass
);
81 static void CALLBACK
check_notification( HINTERNET handle
, DWORD_PTR context
, DWORD status
, LPVOID buffer
, DWORD buflen
)
83 BOOL status_ok
, function_ok
;
84 struct info
*info
= (struct info
*)context
;
85 unsigned int i
= info
->index
;
87 if (status
== WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
)
89 DWORD size
= sizeof(struct info
*);
90 WinHttpQueryOption( handle
, WINHTTP_OPTION_CONTEXT_VALUE
, &info
, &size
);
92 ok(i
< info
->count
, "unexpected notification 0x%08x\n", status
);
93 if (i
>= info
->count
) return;
95 status_ok
= (info
->test
[i
].status
== status
);
96 function_ok
= (info
->test
[i
].function
== info
->function
);
97 if (!info
->test
[i
].ignore
&& !info
->test
[i
].todo
)
99 ok(status_ok
, "%u: expected status 0x%08x got 0x%08x\n", info
->line
, info
->test
[i
].status
, status
);
100 ok(function_ok
, "%u: expected function %u got %u\n", info
->line
, info
->test
[i
].function
, info
->function
);
102 else if (!info
->test
[i
].ignore
)
104 todo_wine
ok(status_ok
, "%u: expected status 0x%08x got 0x%08x\n", info
->line
, info
->test
[i
].status
, status
);
107 todo_wine
ok(function_ok
, "%u: expected function %u got %u\n", info
->line
, info
->test
[i
].function
, info
->function
);
110 if (status_ok
) info
->index
++;
113 while (info
->test
[info
->index
].skipped_for_proxy
)
117 if (status
& (WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS
| WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
))
119 SetEvent( info
->wait
);
123 static const struct notification cache_test
[] =
125 { winhttp_connect
, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
, 0 },
126 { winhttp_open_request
, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
, 0 },
127 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME
, 0 },
128 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED
, 0 },
129 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER
, 0 },
130 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER
, 0 },
131 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST
, 0 },
132 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_REQUEST_SENT
, 0 },
133 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE
, 0 },
134 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED
, 0 },
135 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION
, 0, 1 },
136 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED
, 0, 1 },
137 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
, 0, 1 },
138 { winhttp_open_request
, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
, 0 },
139 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER
, 0 },
140 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER
, 0 },
141 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST
, 0 },
142 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_REQUEST_SENT
, 0 },
143 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE
, 0 },
144 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED
, 0 },
145 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION
, 0, 1 },
146 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED
, 0, 1 },
147 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
, 0, 1 },
148 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
, 1, 1 },
149 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
, 1, 1 }
152 static void setup_test( struct info
*info
, enum api function
, unsigned int line
)
154 info
->function
= function
;
158 static void test_connection_cache( void )
160 static const WCHAR codeweavers
[] = {'w','w','w','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
162 HANDLE ses
, con
, req
;
165 struct info info
, *context
= &info
;
167 info
.test
= cache_test
;
168 info
.count
= sizeof(cache_test
) / sizeof(cache_test
[0]);
172 ses
= WinHttpOpen( user_agent
, 0, NULL
, NULL
, 0 );
173 ok(ses
!= NULL
, "failed to open session %u\n", GetLastError());
175 WinHttpSetStatusCallback( ses
, check_notification
, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS
, 0 );
177 ret
= WinHttpSetOption( ses
, WINHTTP_OPTION_CONTEXT_VALUE
, &context
, sizeof(struct info
*) );
178 ok(ret
, "failed to set context value %u\n", GetLastError());
180 setup_test( &info
, winhttp_connect
, __LINE__
);
181 con
= WinHttpConnect( ses
, codeweavers
, 0, 0 );
182 ok(con
!= NULL
, "failed to open a connection %u\n", GetLastError());
184 setup_test( &info
, winhttp_open_request
, __LINE__
);
185 req
= WinHttpOpenRequest( con
, NULL
, NULL
, NULL
, NULL
, NULL
, 0 );
186 ok(req
!= NULL
, "failed to open a request %u\n", GetLastError());
188 setup_test( &info
, winhttp_send_request
, __LINE__
);
189 ret
= WinHttpSendRequest( req
, NULL
, 0, NULL
, 0, 0, 0 );
190 ok(ret
, "failed to send request %u\n", GetLastError());
192 setup_test( &info
, winhttp_receive_response
, __LINE__
);
193 ret
= WinHttpReceiveResponse( req
, NULL
);
194 ok(ret
, "failed to receive response %u\n", GetLastError());
196 size
= sizeof(status
);
197 ret
= WinHttpQueryHeaders( req
, WINHTTP_QUERY_STATUS_CODE
| WINHTTP_QUERY_FLAG_NUMBER
, NULL
, &status
, &size
, NULL
);
198 ok(ret
, "failed unexpectedly %u\n", GetLastError());
199 ok(status
== 200, "request failed unexpectedly %u\n", status
);
201 setup_test( &info
, winhttp_close_handle
, __LINE__
);
202 WinHttpCloseHandle( req
);
204 setup_test( &info
, winhttp_open_request
, __LINE__
);
205 req
= WinHttpOpenRequest( con
, NULL
, NULL
, NULL
, NULL
, NULL
, 0 );
206 ok(req
!= NULL
, "failed to open a request %u\n", GetLastError());
208 ret
= WinHttpSetOption( req
, WINHTTP_OPTION_CONTEXT_VALUE
, &context
, sizeof(struct info
*) );
209 ok(ret
, "failed to set context value %u\n", GetLastError());
211 setup_test( &info
, winhttp_send_request
, __LINE__
);
212 ret
= WinHttpSendRequest( req
, NULL
, 0, NULL
, 0, 0, 0 );
213 ok(ret
, "failed to send request %u\n", GetLastError());
215 setup_test( &info
, winhttp_receive_response
, __LINE__
);
216 ret
= WinHttpReceiveResponse( req
, NULL
);
217 ok(ret
, "failed to receive response %u\n", GetLastError());
219 size
= sizeof(status
);
220 ret
= WinHttpQueryHeaders( req
, WINHTTP_QUERY_STATUS_CODE
| WINHTTP_QUERY_FLAG_NUMBER
, NULL
, &status
, &size
, NULL
);
221 ok(ret
, "failed unexpectedly %u\n", GetLastError());
222 ok(status
== 200, "request failed unexpectedly %u\n", status
);
224 setup_test( &info
, winhttp_close_handle
, __LINE__
);
225 WinHttpCloseHandle( req
);
227 setup_test( &info
, winhttp_close_handle
, __LINE__
);
228 WinHttpCloseHandle( req
);
229 WinHttpCloseHandle( con
);
230 WinHttpCloseHandle( ses
);
232 Sleep(2000); /* make sure connection is evicted from cache */
236 ses
= WinHttpOpen( user_agent
, 0, NULL
, NULL
, 0 );
237 ok(ses
!= NULL
, "failed to open session %u\n", GetLastError());
239 WinHttpSetStatusCallback( ses
, check_notification
, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS
, 0 );
241 ret
= WinHttpSetOption( ses
, WINHTTP_OPTION_CONTEXT_VALUE
, &context
, sizeof(struct info
*) );
242 ok(ret
, "failed to set context value %u\n", GetLastError());
244 setup_test( &info
, winhttp_connect
, __LINE__
);
245 con
= WinHttpConnect( ses
, codeweavers
, 0, 0 );
246 ok(con
!= NULL
, "failed to open a connection %u\n", GetLastError());
248 setup_test( &info
, winhttp_open_request
, __LINE__
);
249 req
= WinHttpOpenRequest( con
, NULL
, NULL
, NULL
, NULL
, NULL
, 0 );
250 ok(req
!= NULL
, "failed to open a request %u\n", GetLastError());
252 ret
= WinHttpSetOption( req
, WINHTTP_OPTION_CONTEXT_VALUE
, &context
, sizeof(struct info
*) );
253 ok(ret
, "failed to set context value %u\n", GetLastError());
255 setup_test( &info
, winhttp_send_request
, __LINE__
);
256 ret
= WinHttpSendRequest( req
, NULL
, 0, NULL
, 0, 0, 0 );
257 ok(ret
, "failed to send request %u\n", GetLastError());
259 setup_test( &info
, winhttp_receive_response
, __LINE__
);
260 ret
= WinHttpReceiveResponse( req
, NULL
);
261 ok(ret
, "failed to receive response %u\n", GetLastError());
263 size
= sizeof(status
);
264 ret
= WinHttpQueryHeaders( req
, WINHTTP_QUERY_STATUS_CODE
| WINHTTP_QUERY_FLAG_NUMBER
, NULL
, &status
, &size
, NULL
);
265 ok(ret
, "failed unexpectedly %u\n", GetLastError());
266 ok(status
== 200, "request failed unexpectedly %u\n", status
);
268 setup_test( &info
, winhttp_close_handle
, __LINE__
);
269 WinHttpCloseHandle( req
);
271 setup_test( &info
, winhttp_open_request
, __LINE__
);
272 req
= WinHttpOpenRequest( con
, NULL
, NULL
, NULL
, NULL
, NULL
, 0 );
273 ok(req
!= NULL
, "failed to open a request %u\n", GetLastError());
275 ret
= WinHttpSetOption( req
, WINHTTP_OPTION_CONTEXT_VALUE
, &context
, sizeof(struct info
*) );
276 ok(ret
, "failed to set context value %u\n", GetLastError());
278 setup_test( &info
, winhttp_send_request
, __LINE__
);
279 ret
= WinHttpSendRequest( req
, NULL
, 0, NULL
, 0, 0, 0 );
280 ok(ret
, "failed to send request %u\n", GetLastError());
282 setup_test( &info
, winhttp_receive_response
, __LINE__
);
283 ret
= WinHttpReceiveResponse( req
, NULL
);
284 ok(ret
, "failed to receive response %u\n", GetLastError());
286 size
= sizeof(status
);
287 ret
= WinHttpQueryHeaders( req
, WINHTTP_QUERY_STATUS_CODE
| WINHTTP_QUERY_FLAG_NUMBER
, NULL
, &status
, &size
, NULL
);
288 ok(ret
, "failed unexpectedly %u\n", GetLastError());
289 ok(status
== 200, "request failed unexpectedly %u\n", status
);
291 setup_test( &info
, winhttp_close_handle
, __LINE__
);
292 WinHttpCloseHandle( req
);
293 WinHttpCloseHandle( con
);
294 WinHttpCloseHandle( ses
);
296 Sleep(2000); /* make sure connection is evicted from cache */
299 static const struct notification redirect_test
[] =
301 { winhttp_connect
, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
, 0 },
302 { winhttp_open_request
, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
, 0 },
303 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME
, 0 },
304 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED
, 0 },
305 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER
, 0 },
306 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER
, 0 },
307 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST
, 0 },
308 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_REQUEST_SENT
, 0 },
309 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE
, 0 },
310 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED
, 0 },
311 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_REDIRECT
, 0 },
312 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME
, 0, 0, 1 },
313 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED
, 0, 0, 1 },
314 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER
, 0, 0, 1 },
315 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER
, 0, 0, 1 },
316 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST
, 0 },
317 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_REQUEST_SENT
, 0 },
318 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE
, 0 },
319 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED
, 0 },
320 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION
, 0, 1 },
321 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED
, 0, 1 },
322 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
, 0, 1 },
323 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
, 1, 1 },
324 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
, 1, 1 }
327 static void test_redirect( void )
329 static const WCHAR codeweavers
[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
331 HANDLE ses
, con
, req
;
334 struct info info
, *context
= &info
;
336 info
.test
= redirect_test
;
337 info
.count
= sizeof(redirect_test
) / sizeof(redirect_test
[0]);
341 ses
= WinHttpOpen( user_agent
, 0, NULL
, NULL
, 0 );
342 ok(ses
!= NULL
, "failed to open session %u\n", GetLastError());
344 WinHttpSetStatusCallback( ses
, check_notification
, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS
, 0 );
346 ret
= WinHttpSetOption( ses
, WINHTTP_OPTION_CONTEXT_VALUE
, &context
, sizeof(struct info
*) );
347 ok(ret
, "failed to set context value %u\n", GetLastError());
349 setup_test( &info
, winhttp_connect
, __LINE__
);
350 con
= WinHttpConnect( ses
, codeweavers
, 0, 0 );
351 ok(con
!= NULL
, "failed to open a connection %u\n", GetLastError());
353 setup_test( &info
, winhttp_open_request
, __LINE__
);
354 req
= WinHttpOpenRequest( con
, NULL
, NULL
, NULL
, NULL
, NULL
, 0 );
355 ok(req
!= NULL
, "failed to open a request %u\n", GetLastError());
357 setup_test( &info
, winhttp_send_request
, __LINE__
);
358 ret
= WinHttpSendRequest( req
, NULL
, 0, NULL
, 0, 0, 0 );
359 ok(ret
, "failed to send request %u\n", GetLastError());
361 setup_test( &info
, winhttp_receive_response
, __LINE__
);
362 ret
= WinHttpReceiveResponse( req
, NULL
);
363 ok(ret
, "failed to receive response %u\n", GetLastError());
365 size
= sizeof(status
);
366 ret
= WinHttpQueryHeaders( req
, WINHTTP_QUERY_STATUS_CODE
| WINHTTP_QUERY_FLAG_NUMBER
, NULL
, &status
, &size
, NULL
);
367 ok(ret
, "failed unexpectedly %u\n", GetLastError());
368 ok(status
== 200, "request failed unexpectedly %u\n", status
);
370 setup_test( &info
, winhttp_close_handle
, __LINE__
);
371 WinHttpCloseHandle( req
);
372 WinHttpCloseHandle( con
);
373 WinHttpCloseHandle( ses
);
376 static const struct notification async_test
[] =
378 { winhttp_connect
, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
, 0 },
379 { winhttp_open_request
, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
, 0 },
380 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME
, 0 },
381 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED
, 0 },
382 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER
, 0 },
383 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER
, 0 },
384 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST
, 0 },
385 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_REQUEST_SENT
, 0 },
386 { winhttp_send_request
, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE
, 0 },
387 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE
, 0 },
388 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED
, 0 },
389 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_REDIRECT
, 0 },
390 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME
, 0, 0, 1 },
391 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED
, 0, 0, 1 },
392 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER
, 0, 0, 1 },
393 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER
, 0, 0, 1 },
394 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST
, 0 },
395 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_REQUEST_SENT
, 0 },
396 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE
, 0 },
397 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED
, 0 },
398 { winhttp_receive_response
, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE
, 0 },
399 { winhttp_query_data
, WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE
, 0 },
400 { winhttp_read_data
, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE
, 0, 1 },
401 { winhttp_read_data
, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED
, 0, 1 },
402 { winhttp_read_data
, WINHTTP_CALLBACK_STATUS_READ_COMPLETE
, 0, 1 },
403 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION
, 0, 1 },
404 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED
, 0, 1 },
405 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
, 0, 1 },
406 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
, 1, 1 },
407 { winhttp_close_handle
, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
, 1, 1 }
410 static void test_async( void )
412 static const WCHAR codeweavers
[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
414 HANDLE ses
, con
, req
;
417 struct info info
, *context
= &info
;
420 info
.test
= async_test
;
421 info
.count
= sizeof(async_test
) / sizeof(async_test
[0]);
423 info
.wait
= CreateEvent( NULL
, FALSE
, FALSE
, NULL
);
425 ses
= WinHttpOpen( user_agent
, 0, NULL
, NULL
, WINHTTP_FLAG_ASYNC
);
426 ok(ses
!= NULL
, "failed to open session %u\n", GetLastError());
428 WinHttpSetStatusCallback( ses
, check_notification
, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS
, 0 );
430 ret
= WinHttpSetOption( ses
, WINHTTP_OPTION_CONTEXT_VALUE
, &context
, sizeof(struct info
*) );
431 ok(ret
, "failed to set context value %u\n", GetLastError());
433 setup_test( &info
, winhttp_connect
, __LINE__
);
434 con
= WinHttpConnect( ses
, codeweavers
, 0, 0 );
435 ok(con
!= NULL
, "failed to open a connection %u\n", GetLastError());
437 setup_test( &info
, winhttp_open_request
, __LINE__
);
438 req
= WinHttpOpenRequest( con
, NULL
, NULL
, NULL
, NULL
, NULL
, 0 );
439 ok(req
!= NULL
, "failed to open a request %u\n", GetLastError());
441 setup_test( &info
, winhttp_send_request
, __LINE__
);
442 ret
= WinHttpSendRequest( req
, NULL
, 0, NULL
, 0, 0, 0 );
443 ok(ret
, "failed to send request %u\n", GetLastError());
445 WaitForSingleObject( info
.wait
, INFINITE
);
447 setup_test( &info
, winhttp_receive_response
, __LINE__
);
448 ret
= WinHttpReceiveResponse( req
, NULL
);
449 ok(ret
, "failed to receive response %u\n", GetLastError());
451 WaitForSingleObject( info
.wait
, INFINITE
);
453 size
= sizeof(status
);
454 ret
= WinHttpQueryHeaders( req
, WINHTTP_QUERY_STATUS_CODE
| WINHTTP_QUERY_FLAG_NUMBER
, NULL
, &status
, &size
, NULL
);
455 ok(ret
, "failed unexpectedly %u\n", GetLastError());
456 ok(status
== 200, "request failed unexpectedly %u\n", status
);
458 setup_test( &info
, winhttp_query_data
, __LINE__
);
459 ret
= WinHttpQueryDataAvailable( req
, NULL
);
460 ok(ret
, "failed to query data available %u\n", GetLastError());
462 WaitForSingleObject( info
.wait
, INFINITE
);
464 setup_test( &info
, winhttp_read_data
, __LINE__
);
465 ret
= WinHttpReadData( req
, buffer
, sizeof(buffer
), NULL
);
466 ok(ret
, "failed to query data available %u\n", GetLastError());
468 WaitForSingleObject( info
.wait
, INFINITE
);
470 setup_test( &info
, winhttp_close_handle
, __LINE__
);
471 WinHttpCloseHandle( req
);
472 WinHttpCloseHandle( con
);
473 WinHttpCloseHandle( ses
);
475 WaitForSingleObject( info
.wait
, INFINITE
);
476 CloseHandle( info
.wait
);
479 START_TEST (notification
)
481 test_connection_cache();
483 Sleep(2000); /* make sure previous connection is evicted from cache */