winhttp/tests: Only advance to the next notification test if the function is ok.
[wine/wine-gecko.git] / dlls / winhttp / tests / notification.c
blobf2a3692e3be505ad2988f08b6298d948cc9293b9
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};
31 enum api
33 winhttp_connect = 1,
34 winhttp_open_request,
35 winhttp_send_request,
36 winhttp_receive_response,
37 winhttp_query_data,
38 winhttp_read_data,
39 winhttp_write_data,
40 winhttp_close_handle
43 struct notification
45 enum api function; /* api responsible for notification */
46 unsigned int status; /* status received */
47 BOOL todo;
48 BOOL ignore;
49 BOOL skipped_for_proxy;
52 struct info
54 enum api function;
55 const struct notification *test;
56 unsigned int count;
57 unsigned int index;
58 HANDLE wait;
59 unsigned int line;
62 static BOOL proxy_active(void)
64 WINHTTP_PROXY_INFO proxy_info;
65 BOOL active = FALSE;
67 if (WinHttpGetDefaultProxyConfiguration(&proxy_info))
69 active = (proxy_info.lpszProxy != NULL);
70 if (active)
71 GlobalFree(proxy_info.lpszProxy);
72 if (proxy_info.lpszProxyBypass != NULL)
73 GlobalFree(proxy_info.lpszProxyBypass);
75 else
76 active = FALSE;
78 return active;
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);
105 if (status_ok)
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 && function_ok) info->index++;
111 if (proxy_active())
113 while (info->test[info->index].skipped_for_proxy)
114 info->index++;
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 },
126 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
127 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME },
128 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED },
129 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER },
130 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER },
131 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
132 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
133 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
134 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
135 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE },
136 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE },
137 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE },
138 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
139 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER },
140 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER },
141 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
142 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
143 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
144 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
145 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE },
146 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE },
147 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE },
148 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE },
149 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE }
152 static void setup_test( struct info *info, enum api function, unsigned int line )
154 info->function = function;
155 info->line = line;
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;
163 DWORD size, status;
164 BOOL ret;
165 struct info info, *context = &info;
167 info.test = cache_test;
168 info.count = sizeof(cache_test) / sizeof(cache_test[0]);
169 info.index = 0;
170 info.wait = NULL;
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 */
234 info.index = 0;
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 },
302 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
303 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME },
304 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED },
305 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER },
306 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER },
307 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
308 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
309 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
310 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
311 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT },
312 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, FALSE, TRUE },
313 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, FALSE, TRUE },
314 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, FALSE, FALSE, TRUE },
315 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, FALSE, FALSE, TRUE },
316 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
317 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
318 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
319 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
320 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE },
321 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE },
322 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE },
323 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE },
324 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE }
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;
332 DWORD size, status;
333 BOOL ret;
334 struct info info, *context = &info;
336 info.test = redirect_test;
337 info.count = sizeof(redirect_test) / sizeof(redirect_test[0]);
338 info.index = 0;
339 info.wait = NULL;
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 },
379 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED },
380 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, TRUE },
381 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, TRUE },
382 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER },
383 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER },
384 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
385 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
386 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE },
387 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
388 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
389 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT },
390 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, FALSE, TRUE },
391 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, FALSE, TRUE },
392 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, FALSE, FALSE, TRUE },
393 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, FALSE, FALSE, TRUE },
394 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST },
395 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT },
396 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE },
397 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED },
398 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE },
399 { winhttp_query_data, WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE },
400 { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, FALSE, TRUE },
401 { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, FALSE, TRUE },
402 { winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, FALSE, TRUE },
403 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE },
404 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE },
405 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE },
406 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE },
407 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE }
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;
415 DWORD size, status;
416 BOOL ret;
417 struct info info, *context = &info;
418 char buffer[1024];
420 info.test = async_test;
421 info.count = sizeof(async_test) / sizeof(async_test[0]);
422 info.index = 0;
423 info.wait = CreateEventW( 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();
482 test_redirect();
483 Sleep(2000); /* make sure previous connection is evicted from cache */
484 test_async();