winhttp: Verify the async parameter type in IWinHttpRequest::Open.
[wine/multimedia.git] / dlls / winhttp / tests / notification.c
blobffbea03bbe3d108725bff7767545db6792601088
1 /*
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
21 #include <stdarg.h>
22 #include <stdlib.h>
23 #include <windef.h>
24 #include <winbase.h>
25 #include <winhttp.h>
27 #include "wine/test.h"
29 static const WCHAR user_agent[] = {'w','i','n','e','t','e','s','t',0};
30 static const WCHAR test_winehq[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
32 enum api
34 winhttp_connect = 1,
35 winhttp_open_request,
36 winhttp_send_request,
37 winhttp_receive_response,
38 winhttp_query_data,
39 winhttp_read_data,
40 winhttp_write_data,
41 winhttp_close_handle
44 struct notification
46 enum api function; /* api responsible for notification */
47 unsigned int status; /* status received */
48 BOOL todo;
49 BOOL ignore;
50 BOOL skipped_for_proxy;
53 struct info
55 enum api function;
56 const struct notification *test;
57 unsigned int count;
58 unsigned int index;
59 HANDLE wait;
60 unsigned int line;
63 static BOOL proxy_active(void)
65 WINHTTP_PROXY_INFO proxy_info;
66 BOOL active = FALSE;
68 if (WinHttpGetDefaultProxyConfiguration(&proxy_info))
70 active = (proxy_info.lpszProxy != NULL);
71 if (active)
72 GlobalFree(proxy_info.lpszProxy);
73 if (proxy_info.lpszProxyBypass != NULL)
74 GlobalFree(proxy_info.lpszProxyBypass);
76 else
77 active = FALSE;
79 return active;
82 static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID buffer, DWORD buflen )
84 BOOL status_ok, function_ok;
85 struct info *info = (struct info *)context;
86 unsigned int i = info->index;
88 if (status == WINHTTP_CALLBACK_STATUS_HANDLE_CREATED)
90 DWORD size = sizeof(struct info *);
91 WinHttpQueryOption( handle, WINHTTP_OPTION_CONTEXT_VALUE, &info, &size );
93 ok(i < info->count, "%u: unexpected notification 0x%08x\n", info->line, status);
94 if (i >= info->count) return;
96 status_ok = (info->test[i].status == status);
97 function_ok = (info->test[i].function == info->function);
98 if (!info->test[i].ignore && !info->test[i].todo)
100 ok(status_ok, "%u: expected status 0x%08x got 0x%08x\n", info->line, info->test[i].status, status);
101 ok(function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function);
103 else if (!info->test[i].ignore)
105 todo_wine ok(status_ok, "%u: expected status 0x%08x got 0x%08x\n", info->line, info->test[i].status, status);
106 if (status_ok)
108 todo_wine ok(function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function);
111 if (status_ok && function_ok) info->index++;
112 if (proxy_active())
114 while (info->test[info->index].skipped_for_proxy)
115 info->index++;
118 if (status & (WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING))
120 SetEvent( info->wait );
124 static const struct notification cache_test[] =
126 { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
127 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
128 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME },
129 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED },
130 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER },
131 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER },
132 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
133 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
134 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
135 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
136 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE },
137 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE },
138 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE },
139 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
140 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER },
141 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER },
142 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
143 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
144 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
145 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
146 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE },
147 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE },
148 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE },
149 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE },
150 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE }
153 static void setup_test( struct info *info, enum api function, unsigned int line )
155 info->function = function;
156 info->line = line;
159 static void test_connection_cache( void )
161 HANDLE ses, con, req;
162 DWORD size, status;
163 BOOL ret;
164 struct info info, *context = &info;
166 info.test = cache_test;
167 info.count = sizeof(cache_test) / sizeof(cache_test[0]);
168 info.index = 0;
169 info.wait = NULL;
171 ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
172 ok(ses != NULL, "failed to open session %u\n", GetLastError());
174 WinHttpSetStatusCallback( ses, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
176 ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
177 ok(ret, "failed to set context value %u\n", GetLastError());
179 setup_test( &info, winhttp_connect, __LINE__ );
180 con = WinHttpConnect( ses, test_winehq, 0, 0 );
181 ok(con != NULL, "failed to open a connection %u\n", GetLastError());
183 setup_test( &info, winhttp_open_request, __LINE__ );
184 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
185 ok(req != NULL, "failed to open a request %u\n", GetLastError());
187 setup_test( &info, winhttp_send_request, __LINE__ );
188 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
189 ok(ret, "failed to send request %u\n", GetLastError());
191 setup_test( &info, winhttp_receive_response, __LINE__ );
192 ret = WinHttpReceiveResponse( req, NULL );
193 ok(ret, "failed to receive response %u\n", GetLastError());
195 size = sizeof(status);
196 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
197 ok(ret, "failed unexpectedly %u\n", GetLastError());
198 ok(status == 200, "request failed unexpectedly %u\n", status);
200 setup_test( &info, winhttp_close_handle, __LINE__ );
201 WinHttpCloseHandle( req );
203 setup_test( &info, winhttp_open_request, __LINE__ );
204 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
205 ok(req != NULL, "failed to open a request %u\n", GetLastError());
207 ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
208 ok(ret, "failed to set context value %u\n", GetLastError());
210 setup_test( &info, winhttp_send_request, __LINE__ );
211 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
212 ok(ret, "failed to send request %u\n", GetLastError());
214 setup_test( &info, winhttp_receive_response, __LINE__ );
215 ret = WinHttpReceiveResponse( req, NULL );
216 ok(ret, "failed to receive response %u\n", GetLastError());
218 size = sizeof(status);
219 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
220 ok(ret, "failed unexpectedly %u\n", GetLastError());
221 ok(status == 200, "request failed unexpectedly %u\n", status);
223 setup_test( &info, winhttp_close_handle, __LINE__ );
224 WinHttpCloseHandle( req );
226 setup_test( &info, winhttp_close_handle, __LINE__ );
227 WinHttpCloseHandle( req );
228 WinHttpCloseHandle( con );
229 WinHttpCloseHandle( ses );
231 Sleep(2000); /* make sure connection is evicted from cache */
233 info.index = 0;
235 ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
236 ok(ses != NULL, "failed to open session %u\n", GetLastError());
238 WinHttpSetStatusCallback( ses, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
240 ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
241 ok(ret, "failed to set context value %u\n", GetLastError());
243 setup_test( &info, winhttp_connect, __LINE__ );
244 con = WinHttpConnect( ses, test_winehq, 0, 0 );
245 ok(con != NULL, "failed to open a connection %u\n", GetLastError());
247 setup_test( &info, winhttp_open_request, __LINE__ );
248 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
249 ok(req != NULL, "failed to open a request %u\n", GetLastError());
251 ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
252 ok(ret, "failed to set context value %u\n", GetLastError());
254 setup_test( &info, winhttp_send_request, __LINE__ );
255 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
256 ok(ret, "failed to send request %u\n", GetLastError());
258 setup_test( &info, winhttp_receive_response, __LINE__ );
259 ret = WinHttpReceiveResponse( req, NULL );
260 ok(ret, "failed to receive response %u\n", GetLastError());
262 size = sizeof(status);
263 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
264 ok(ret, "failed unexpectedly %u\n", GetLastError());
265 ok(status == 200, "request failed unexpectedly %u\n", status);
267 setup_test( &info, winhttp_close_handle, __LINE__ );
268 WinHttpCloseHandle( req );
270 setup_test( &info, winhttp_open_request, __LINE__ );
271 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
272 ok(req != NULL, "failed to open a request %u\n", GetLastError());
274 ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
275 ok(ret, "failed to set context value %u\n", GetLastError());
277 setup_test( &info, winhttp_send_request, __LINE__ );
278 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
279 ok(ret, "failed to send request %u\n", GetLastError());
281 setup_test( &info, winhttp_receive_response, __LINE__ );
282 ret = WinHttpReceiveResponse( req, NULL );
283 ok(ret, "failed to receive response %u\n", GetLastError());
285 size = sizeof(status);
286 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
287 ok(ret, "failed unexpectedly %u\n", GetLastError());
288 ok(status == 200, "request failed unexpectedly %u\n", status);
290 setup_test( &info, winhttp_close_handle, __LINE__ );
291 WinHttpCloseHandle( req );
292 WinHttpCloseHandle( con );
293 WinHttpCloseHandle( ses );
295 Sleep(2000); /* make sure connection is evicted from cache */
298 static const struct notification redirect_test[] =
300 { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
301 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
302 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, TRUE },
303 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, TRUE },
304 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER },
305 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER },
306 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
307 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
308 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
309 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
310 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT },
311 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, TRUE, TRUE },
312 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, TRUE, TRUE },
313 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, FALSE, FALSE, TRUE },
314 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, FALSE, FALSE, TRUE },
315 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
316 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
317 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
318 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
319 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE },
320 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE },
321 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE },
322 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE },
323 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE }
326 static void test_redirect( void )
328 HANDLE ses, con, req;
329 DWORD size, status;
330 BOOL ret;
331 struct info info, *context = &info;
333 info.test = redirect_test;
334 info.count = sizeof(redirect_test) / sizeof(redirect_test[0]);
335 info.index = 0;
336 info.wait = NULL;
338 ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
339 ok(ses != NULL, "failed to open session %u\n", GetLastError());
341 WinHttpSetStatusCallback( ses, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
343 ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
344 ok(ret, "failed to set context value %u\n", GetLastError());
346 setup_test( &info, winhttp_connect, __LINE__ );
347 con = WinHttpConnect( ses, test_winehq, 0, 0 );
348 ok(con != NULL, "failed to open a connection %u\n", GetLastError());
350 setup_test( &info, winhttp_open_request, __LINE__ );
351 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
352 ok(req != NULL, "failed to open a request %u\n", GetLastError());
354 setup_test( &info, winhttp_send_request, __LINE__ );
355 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
356 ok(ret, "failed to send request %u\n", GetLastError());
358 setup_test( &info, winhttp_receive_response, __LINE__ );
359 ret = WinHttpReceiveResponse( req, NULL );
360 ok(ret, "failed to receive response %u\n", GetLastError());
362 size = sizeof(status);
363 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
364 ok(ret, "failed unexpectedly %u\n", GetLastError());
365 ok(status == 200, "request failed unexpectedly %u\n", status);
367 setup_test( &info, winhttp_close_handle, __LINE__ );
368 WinHttpCloseHandle( req );
369 WinHttpCloseHandle( con );
370 WinHttpCloseHandle( ses );
373 static const struct notification async_test[] =
375 { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
376 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
377 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, TRUE },
378 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, TRUE },
379 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER },
380 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER },
381 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
382 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
383 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE },
384 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
385 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
386 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT },
387 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, TRUE, TRUE },
388 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, TRUE, TRUE },
389 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, FALSE, FALSE, TRUE },
390 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, FALSE, FALSE, TRUE },
391 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
392 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
393 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
394 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
395 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE },
396 { winhttp_query_data, WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE },
397 { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, FALSE, TRUE },
398 { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, FALSE, TRUE },
399 { winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, FALSE, TRUE },
400 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE },
401 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE },
402 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE },
403 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE },
404 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE }
407 static void test_async( void )
409 HANDLE ses, con, req;
410 DWORD size, status;
411 BOOL ret;
412 struct info info, *context = &info;
413 char buffer[1024];
415 info.test = async_test;
416 info.count = sizeof(async_test) / sizeof(async_test[0]);
417 info.index = 0;
418 info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
420 ses = WinHttpOpen( user_agent, 0, NULL, NULL, WINHTTP_FLAG_ASYNC );
421 ok(ses != NULL, "failed to open session %u\n", GetLastError());
423 WinHttpSetStatusCallback( ses, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
425 ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
426 ok(ret, "failed to set context value %u\n", GetLastError());
428 setup_test( &info, winhttp_connect, __LINE__ );
429 con = WinHttpConnect( ses, test_winehq, 0, 0 );
430 ok(con != NULL, "failed to open a connection %u\n", GetLastError());
432 setup_test( &info, winhttp_open_request, __LINE__ );
433 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
434 ok(req != NULL, "failed to open a request %u\n", GetLastError());
436 setup_test( &info, winhttp_send_request, __LINE__ );
437 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
438 ok(ret, "failed to send request %u\n", GetLastError());
440 WaitForSingleObject( info.wait, INFINITE );
442 setup_test( &info, winhttp_receive_response, __LINE__ );
443 ret = WinHttpReceiveResponse( req, NULL );
444 ok(ret, "failed to receive response %u\n", GetLastError());
446 WaitForSingleObject( info.wait, INFINITE );
448 size = sizeof(status);
449 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
450 ok(ret, "failed unexpectedly %u\n", GetLastError());
451 ok(status == 200, "request failed unexpectedly %u\n", status);
453 setup_test( &info, winhttp_query_data, __LINE__ );
454 ret = WinHttpQueryDataAvailable( req, NULL );
455 ok(ret, "failed to query data available %u\n", GetLastError());
457 WaitForSingleObject( info.wait, INFINITE );
459 setup_test( &info, winhttp_read_data, __LINE__ );
460 ret = WinHttpReadData( req, buffer, sizeof(buffer), NULL );
461 ok(ret, "failed to query data available %u\n", GetLastError());
463 WaitForSingleObject( info.wait, INFINITE );
465 setup_test( &info, winhttp_close_handle, __LINE__ );
466 WinHttpCloseHandle( req );
467 WinHttpCloseHandle( con );
468 WinHttpCloseHandle( ses );
470 WaitForSingleObject( info.wait, INFINITE );
471 CloseHandle( info.wait );
474 START_TEST (notification)
476 test_connection_cache();
477 test_redirect();
478 Sleep(2000); /* make sure previous connection is evicted from cache */
479 test_async();