ReactOS 0.4.16-dev-2491-g3dc6630
winhttp.c
Go to the documentation of this file.
1/*
2 * WinHTTP - tests
3 *
4 * Copyright 2008 Google (Zac Brown)
5 * Copyright 2015 Dmitry Timoshkov
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#define COBJMACROS
23#include <stdarg.h>
24#include <windef.h>
25#include <winsock2.h>
26#include <ws2tcpip.h>
27#include <winhttp.h>
28#include <wincrypt.h>
29#include <winreg.h>
30#include <initguid.h>
31#include <httprequest.h>
32#include <httprequestid.h>
33
34#include "wine/test.h"
35
36DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
37
38static DWORD (WINAPI *pWinHttpWebSocketClose)(HINTERNET,USHORT,void*,DWORD);
39static HINTERNET (WINAPI *pWinHttpWebSocketCompleteUpgrade)(HINTERNET,DWORD_PTR);
40static DWORD (WINAPI *pWinHttpWebSocketQueryCloseStatus)(HINTERNET,USHORT*,void*,DWORD,DWORD*);
41static DWORD (WINAPI *pWinHttpWebSocketReceive)(HINTERNET,void*,DWORD,DWORD*,WINHTTP_WEB_SOCKET_BUFFER_TYPE*);
42static DWORD (WINAPI *pWinHttpWebSocketSend)(HINTERNET,WINHTTP_WEB_SOCKET_BUFFER_TYPE,void*,DWORD);
43static DWORD (WINAPI *pWinHttpWebSocketShutdown)(HINTERNET,USHORT,void*,DWORD);
44
45static BOOL proxy_active(void)
46{
47 WINHTTP_PROXY_INFO proxy_info;
48 BOOL active = FALSE;
49
50 SetLastError(0xdeadbeef);
52 {
53 ok( GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
54 "got %lu\n", GetLastError() );
55 active = (proxy_info.lpszProxy != NULL);
56 if (active)
57 GlobalFree(proxy_info.lpszProxy);
58 if (proxy_info.lpszProxyBypass != NULL)
59 GlobalFree(proxy_info.lpszProxyBypass);
60 }
61 else
62 active = FALSE;
63
64 return active;
65}
66
67static void test_WinHttpQueryOption(void)
68{
69 BOOL ret;
70 HINTERNET session, request, connection;
72
73 SetLastError(0xdeadbeef);
74 session = WinHttpOpen(L"winetest", 0, 0, 0, 0);
75 ok( session != NULL, "WinHttpOpen failed to open session, error %lu\n", GetLastError() );
76
77 SetLastError(0xdeadbeef);
79 ok( !ret, "should fail to set redirect policy %lu\n", GetLastError() );
80 ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError() );
81
82 size = 0xdeadbeef;
83 SetLastError(0xdeadbeef);
85 ok(!ret, "should fail to query option\n");
86 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError() );
87 ok( size == 4, "expected 4, got %lu\n", size );
88
89 feature = 0xdeadbeef;
90 size = sizeof(feature) - 1;
91 SetLastError(0xdeadbeef);
93 ok(!ret, "should fail to query option\n");
94 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError() );
95 ok( size == 4, "expected 4, got %lu\n", size );
96
97 feature = 0xdeadbeef;
98 size = sizeof(feature) + 1;
99 SetLastError(0xdeadbeef);
101 ok(ret, "failed to query option %lu\n", GetLastError());
102 ok(GetLastError() == ERROR_SUCCESS, "got %lu\n", GetLastError());
103 ok(size == sizeof(feature), "WinHttpQueryOption should set the size: %lu\n", size);
104 ok(feature == 0, "got unexpected WINHTTP_OPTION_WORKER_THREAD_COUNT %#lx\n", feature);
105
106 feature = 0xdeadbeef;
107 size = sizeof(feature) + 1;
108 SetLastError(0xdeadbeef);
110 ok(ret, "failed to query option %lu\n", GetLastError());
111 ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
112 "got %lu\n", GetLastError());
113 ok(size == sizeof(feature), "WinHttpQueryOption should set the size: %lu\n", size);
115 "expected WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP, got %#lx\n", feature);
116
117 SetLastError(0xdeadbeef);
119 ok(!ret, "should fail to set redirect policy %lu\n", GetLastError());
121 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
122
124 SetLastError(0xdeadbeef);
126 ok(!ret, "should fail to set redirect policy %lu\n", GetLastError());
128 "expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError());
129
131 SetLastError(0xdeadbeef);
133 ok(!ret, "should fail to set redirect policy %lu\n", GetLastError());
135 "expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError());
136
138 SetLastError(0xdeadbeef);
140 ok(ret, "failed to set redirect policy %lu\n", GetLastError());
141
142 feature = 0xdeadbeef;
143 size = sizeof(feature);
144 SetLastError(0xdeadbeef);
146 ok(ret, "failed to query option %lu\n", GetLastError());
148 "expected WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS, got %#lx\n", feature);
149
151 SetLastError(0xdeadbeef);
153 ok(!ret, "should fail to set disable feature for a session\n");
155 "expected ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, got %lu\n", GetLastError());
156
157 SetLastError(0xdeadbeef);
158 connection = WinHttpConnect(session, L"test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, 0);
159 ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %lu\n", GetLastError());
160
162 SetLastError(0xdeadbeef);
164 ok(!ret, "should fail to set disable feature for a connection\n");
166 "expected ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, got %lu\n", GetLastError());
167
168 SetLastError(0xdeadbeef);
172 {
173 skip("Network unreachable, skipping the test\n");
174 goto done;
175 }
176
177 feature = 0xdeadbeef;
178 size = sizeof(feature);
179 SetLastError(0xdeadbeef);
181 ok(ret, "query WINHTTP_OPTION_WORKER_THREAD_COUNT failed for a request\n");
182 ok(GetLastError() == ERROR_SUCCESS, "got unexpected error %lu\n", GetLastError());
183 ok(size == sizeof(feature), "WinHttpQueryOption should set the size: %lu\n", size);
184 ok(feature == 0, "got unexpected WINHTTP_OPTION_WORKER_THREAD_COUNT %#lx\n", feature);
185
186 feature = 0xdeadbeef;
187 size = sizeof(feature);
188 SetLastError(0xdeadbeef);
190 ok(ret, "query WINHTTP_OPTION_WORKER_THREAD_COUNT failed for a request\n");
191 ok(GetLastError() == ERROR_SUCCESS, "got unexpected error %lu\n", GetLastError());
192 ok(size == sizeof(feature), "WinHttpQueryOption should set the size: %lu\n", size);
193 ok(feature == 0, "got unexpected WINHTTP_OPTION_WORKER_THREAD_COUNT %#lx\n", feature);
194
195 feature = 0xdeadbeef;
196 size = sizeof(feature);
197 SetLastError(0xdeadbeef);
199 ok(!ret, "should fail to query disable feature for a request\n");
201 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
202
203 feature = 0;
204 size = sizeof(feature);
205 SetLastError(0xdeadbeef);
207 ok(ret, "failed to set feature %lu\n", GetLastError());
208
209 feature = 0xffffffff;
210 size = sizeof(feature);
211 SetLastError(0xdeadbeef);
213 ok(ret, "failed to set feature %lu\n", GetLastError());
214
216 size = sizeof(feature);
217 SetLastError(0xdeadbeef);
219 ok(ret, "failed to set feature %lu\n", GetLastError());
220
221 size = 0;
222 SetLastError(0xdeadbeef);
224 ok(!ret, "should fail to query disable feature for a request\n");
226 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
227
228 feature = 0xdeadbeef;
229 size = sizeof(feature);
230 SetLastError(0xdeadbeef);
232 ok(!ret, "should fail to query enabled features for a request\n");
233 ok(feature == 0xdeadbeef, "expect feature 0xdeadbeef, got %#lx\n", feature);
234 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
235
237 SetLastError(0xdeadbeef);
239 ok(!ret, "should fail to enable WINHTTP_ENABLE_SSL_REVOCATION with invalid parameters\n");
240 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
241
242 SetLastError(0xdeadbeef);
244 ok(!ret, "should fail to enable WINHTTP_ENABLE_SSL_REVOCATION with invalid parameters\n");
245 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
246
247 SetLastError(0xdeadbeef);
249 ok(ret, "failed to set feature\n");
250 ok(GetLastError() == NO_ERROR || broken(GetLastError() == 0xdeadbeef), /* Doesn't set error code on Vista or older */
251 "expected NO_ERROR, got %lu\n", GetLastError());
252
253 feature = 0xdeadbeef;
254 SetLastError(0xdeadbeef);
256 ok(!ret, "should fail to enable WINHTTP_ENABLE_SSL_REVOCATION with invalid parameters\n");
257 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
258
259 feature = 6;
260 size = sizeof(feature);
262 ok(ret, "failed to set WINHTTP_OPTION_CONNECT_RETRIES %lu\n", GetLastError());
263
264 SetLastError(0xdeadbeef);
266 ok(ret, "WinHttpCloseHandle failed on closing request: %lu\n", GetLastError());
267
268done:
269 SetLastError(0xdeadbeef);
270 ret = WinHttpCloseHandle(connection);
271 ok(ret, "WinHttpCloseHandle failed on closing connection: %lu\n", GetLastError());
272 SetLastError(0xdeadbeef);
274 ok(ret, "WinHttpCloseHandle failed on closing session: %lu\n", GetLastError());
275}
276
277static void test_WinHttpOpenRequest (void)
278{
279 BOOL ret;
280 HINTERNET session, request, connection;
281 DWORD err;
282
283 SetLastError(0xdeadbeef);
286 err = GetLastError();
287 ok(session != NULL, "WinHttpOpen failed to open session.\n");
288 ok(err == ERROR_SUCCESS, "got %lu\n", err);
289
290 /* Test with a bad server name */
291 SetLastError(0xdeadbeef);
293 err = GetLastError();
294 ok (connection == NULL, "WinHttpConnect succeeded in opening connection to NULL server argument.\n");
295 ok(err == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %lu.\n", err);
296
297 /* Test with a valid server name */
298 SetLastError(0xdeadbeef);
299 connection = WinHttpConnect (session, L"test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, 0);
300 err = GetLastError();
301 ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %lu.\n", err);
302 ok(err == ERROR_SUCCESS || broken(err == WSAEINVAL) /* < win7 */, "got %lu\n", err);
303
304 SetLastError(0xdeadbeef);
307 err = GetLastError();
309 {
310 skip("Network unreachable, skipping.\n");
311 goto done;
312 }
313 ok(request != NULL, "WinHttpOpenrequest failed to open a request, error: %lu.\n", err);
314 ok(err == ERROR_SUCCESS, "got %lu\n", err);
315
316 SetLastError(0xdeadbeef);
318 err = GetLastError();
320 {
321 skip("Connection failed, skipping.\n");
322 goto done;
323 }
324 ok(ret, "WinHttpSendRequest failed: %lu\n", err);
325 ok(err == ERROR_SUCCESS, "got %lu\n", err);
326
327 SetLastError(0xdeadbeef);
329 err = GetLastError();
330 ok(ret, "WinHttpCloseHandle failed on closing request, got %lu.\n", err);
331 ok(err == ERROR_SUCCESS, "got %lu\n", err);
332
333 done:
334 ret = WinHttpCloseHandle(connection);
335 ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret);
337 ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n", ret);
338
339}
340
342{
343 HINTERNET ses, con, req;
344 DWORD err;
345 BOOL ret;
346
347 ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
348 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
349
350 con = WinHttpConnect(ses, L"test.winehq.org", 80, 0);
351 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
352
353 req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
354 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
355
356 ret = WinHttpSendRequest(req, L"", 0, NULL, 0, 0, 0);
357 err = GetLastError();
359 {
360 skip("connection failed, skipping\n");
361 goto done;
362 }
363 ok(ret, "failed to send request %lu\n", GetLastError());
364
365 done:
369}
370
371static void test_WinHttpSendRequest (void)
372{
373 static const WCHAR content_type[] = L"Content-Type: application/x-www-form-urlencoded";
374 static char post_data[] = "mode=Test";
375 static const char test_post[] = "mode => Test\0\n";
376 HINTERNET session, request, connection;
377 DWORD header_len, optional_len, total_len, bytes_rw, size, err, disable, len;
379 BOOL ret;
380 CHAR buffer[256];
381 WCHAR method[8];
382 int i;
383
384 header_len = -1L;
385 total_len = optional_len = sizeof(post_data);
386 memset(buffer, 0xff, sizeof(buffer));
387
390 ok(session != NULL, "WinHttpOpen failed to open session.\n");
391
392 connection = WinHttpConnect (session, L"test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, 0);
393 ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %lu\n", GetLastError());
394
395 request = WinHttpOpenRequest(connection, L"POST", L"tests/post.php", NULL, WINHTTP_NO_REFERER,
398 {
399 skip("Network unreachable, skipping.\n");
400 goto done;
401 }
402 ok(request != NULL, "WinHttpOpenrequest failed to open a request, error: %lu\n", GetLastError());
403 if (!request) goto done;
404
405 method[0] = 0;
406 len = sizeof(method);
408 ok(ret, "got %lu\n", GetLastError());
409 ok(len == lstrlenW(L"POST") * sizeof(WCHAR), "got %lu\n", len);
410 ok(!lstrcmpW(method, L"POST"), "got %s\n", wine_dbgstr_w(method));
411
412 context = 0xdeadbeef;
414 ok(ret, "WinHttpSetOption failed: %lu\n", GetLastError());
415
416 /* writing more data than promised by the content-length header causes an error when the connection
417 is reused, so disable keep-alive */
420 ok(ret, "WinHttpSetOption failed: %lu\n", GetLastError());
421
422 context++;
423 ret = WinHttpSendRequest(request, content_type, header_len, post_data, optional_len, total_len, context);
424 err = GetLastError();
426 {
427 skip("connection failed, skipping\n");
428 goto done;
429 }
430 ok(ret == TRUE, "WinHttpSendRequest failed: %lu\n", GetLastError());
431
432 context = 0;
433 size = sizeof(context);
435 ok(ret, "WinHttpQueryOption failed: %lu\n", GetLastError());
436 ok(context == 0xdeadbef0, "expected 0xdeadbef0, got %#Ix\n", context);
437
438 for (i = 3; post_data[i]; i++)
439 {
440 bytes_rw = -1;
441 SetLastError(0xdeadbeef);
442 ret = WinHttpWriteData(request, &post_data[i], 1, &bytes_rw);
443 if (ret)
444 {
445 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %lu\n", GetLastError());
446 ok(bytes_rw == 1, "WinHttpWriteData failed, wrote %lu bytes instead of 1 byte\n", bytes_rw);
447 }
448 else /* Since we already passed all optional data in WinHttpSendRequest Win7 fails our WinHttpWriteData call */
449 {
450 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER got %lu\n", GetLastError());
451 ok(bytes_rw == -1, "Expected bytes_rw to remain unchanged.\n");
452 }
453 }
454
455 SetLastError(0xdeadbeef);
458 "Expected ERROR_SUCCESS got %lu\n", GetLastError());
459 ok(ret == TRUE, "WinHttpReceiveResponse failed: %lu\n", GetLastError());
460
461 SetLastError(0xdeadbeef);
464
465 SetLastError(0xdeadbeef);
467 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %lu\n", GetLastError());
468
469 bytes_rw = -1;
470 ret = WinHttpReadData(request, buffer, sizeof(buffer) - 1, &bytes_rw);
471 ok(ret == TRUE, "WinHttpReadData failed: %lu\n", GetLastError());
472
473 ok(bytes_rw == sizeof(test_post) - 1, "Read %lu bytes\n", bytes_rw);
474 ok(!memcmp(buffer, test_post, sizeof(test_post) - 1), "Data read did not match.\n");
475
476 done:
478 ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n", ret);
479 ret = WinHttpCloseHandle(connection);
480 ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret);
482 ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n", ret);
483}
484
485static void test_connect_error(void)
486{
487 static const WCHAR content_type[] = L"Content-Type: application/x-www-form-urlencoded";
488 DWORD header_len, optional_len, total_len, err, t1, t2;
489 HINTERNET session, request, connection;
490 static char post_data[] = "mode=Test";
491 BOOL ret;
492
493 header_len = ~0u;
494 total_len = optional_len = sizeof(post_data);
495
498 ok(!!session, "WinHttpOpen failed to open session.\n");
499
500 connection = WinHttpConnect (session, L"127.0.0.1", 12345, 0);
501 ok(!!connection, "WinHttpConnect failed to open a connection, error %lu.\n", GetLastError());
502
503 request = WinHttpOpenRequest(connection, L"POST", L"tests/post.php", NULL, WINHTTP_NO_REFERER,
505 ok(!!request, "WinHttpOpenrequest failed to open a request, error: %lu\n", GetLastError());
506
507 t1 = GetTickCount();
508 ret = WinHttpSendRequest(request, content_type, header_len, post_data, optional_len, total_len, 0);
509 t2 = GetTickCount();
510 err = GetLastError();
511 ok(!ret, "WinHttpSendRequest() succeeded.\n");
512 ok(err == ERROR_WINHTTP_CANNOT_CONNECT, "Got unexpected err %lu.\n", err);
513 ok(t2 - t1 < 5000, "Unexpected connect failure delay %lums.\n", t2 - t1);
514
516 WinHttpCloseHandle(connection);
518}
519
521{
522 BOOL ret;
523 static const SYSTEMTIME time = {2008, 7, 1, 28, 10, 5, 52, 0};
524 WCHAR time_string[WINHTTP_TIME_FORMAT_BUFSIZE+1];
525 DWORD err;
526
527 SetLastError(0xdeadbeef);
529 err = GetLastError();
530 ok(!ret, "WinHttpTimeFromSystemTime succeeded\n");
531 ok(err == ERROR_INVALID_PARAMETER, "got %lu\n", err);
532
533 SetLastError(0xdeadbeef);
534 ret = WinHttpTimeFromSystemTime(NULL, time_string);
535 err = GetLastError();
536 ok(!ret, "WinHttpTimeFromSystemTime succeeded\n");
537 ok(err == ERROR_INVALID_PARAMETER, "got %lu\n", err);
538
539 SetLastError(0xdeadbeef);
540 ret = WinHttpTimeFromSystemTime(&time, time_string);
541 err = GetLastError();
542 ok(ret, "WinHttpTimeFromSystemTime failed: %lu\n", err);
543 ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got %lu\n", err);
544 ok(!memcmp(time_string, L"Mon, 28 Jul 2008 10:05:52 GMT", sizeof(L"Mon, 28 Jul 2008 10:05:52 GMT")),
545 "Time string returned did not match expected time string.\n");
546}
547
549{
550 BOOL ret;
552 static const SYSTEMTIME expected_time = {2008, 7, 1, 28, 10, 5, 52, 0};
553 DWORD err;
554
555 SetLastError(0xdeadbeef);
556 ret = WinHttpTimeToSystemTime(L"Mon, 28 Jul 2008 10:05:52 GMT\n", NULL);
557 err = GetLastError();
558 ok(!ret, "WinHttpTimeToSystemTime succeeded\n");
559 ok(err == ERROR_INVALID_PARAMETER, "got %lu\n", err);
560
561 SetLastError(0xdeadbeef);
563 err = GetLastError();
564 ok(!ret, "WinHttpTimeToSystemTime succeeded\n");
565 ok(err == ERROR_INVALID_PARAMETER, "got %lu\n", err);
566
567 SetLastError(0xdeadbeef);
568 ret = WinHttpTimeToSystemTime(L"Mon, 28 Jul 2008 10:05:52 GMT\n", &time);
569 err = GetLastError();
570 ok(ret, "WinHttpTimeToSystemTime failed: %lu\n", err);
571 ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got %lu\n", err);
572 ok(memcmp(&time, &expected_time, sizeof(SYSTEMTIME)) == 0,
573 "Returned SYSTEMTIME structure did not match expected SYSTEMTIME structure.\n");
574
575 SetLastError(0xdeadbeef);
576 ret = WinHttpTimeToSystemTime(L" mon 28 jul 2008 10 05 52\n", &time);
577 err = GetLastError();
578 ok(ret, "WinHttpTimeToSystemTime failed: %lu\n", err);
579 ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got %lu\n", err);
580 ok(memcmp(&time, &expected_time, sizeof(SYSTEMTIME)) == 0,
581 "Returned SYSTEMTIME structure did not match expected SYSTEMTIME structure.\n");
582}
583
584static void test_WinHttpAddHeaders(void)
585{
586 static const WCHAR test_header_begin[] =
587 {'P','O','S','T',' ','/','p','o','s','t','t','e','s','t','.','p','h','p',' ','H','T','T','P','/','1'};
588 HINTERNET session, request, connection;
592 DWORD err, index, len, oldlen;
593
594 static const WCHAR test_headers[][14] =
595 {
596 L"Warning:test1",
597 L"Warning:test2",
598 L"Warning:test3",
599 L"Warning:test4",
600 L"Warning:test5",
601 L"Warning:test6",
602 L"Warning:test7",
603 L"",
604 L":",
605 L"a:",
606 L":b",
607 L"cd",
608 L" e :f",
609 L"field: value ",
610 L"name: value",
611 L"name:",
612 L"g : value",
613 };
614 static const WCHAR test_indices[][6] =
615 {
616 L"test1",
617 L"test2",
618 L"test3",
619 L"test4",
620 };
621
624 ok(session != NULL, "WinHttpOpen failed to open session.\n");
625
626 connection = WinHttpConnect (session, L"test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, 0);
627 ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %lu\n", GetLastError());
628
629 request = WinHttpOpenRequest(connection, L"POST", L"/posttest.php", NULL, WINHTTP_NO_REFERER,
632 {
633 skip("Network unreachable, skipping.\n");
634 goto done;
635 }
636 ok(request != NULL, "WinHttpOpenRequest failed to open a request, error: %lu\n", GetLastError());
637
638 index = 0;
639 len = sizeof(buffer);
641 L"Warning", buffer, &len, &index);
642 ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded, found 'Warning' header.\n");
643 SetLastError(0xdeadbeef);
645 err = GetLastError();
646 ok(ret, "WinHttpAddRequestHeaders failed to add new header, got %d with error %lu\n", ret, err);
647 ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got %lu\n", err);
648
649 index = 0;
650 len = sizeof(buffer);
652 L"Warning", buffer, &len, &index);
653 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
654 ok(index == 1, "WinHttpQueryHeaders failed: header index not incremented\n");
655 ok(!memcmp(buffer, test_indices[0], sizeof(test_indices[0])),
656 "WinHttpQueryHeaders failed: incorrect string returned\n");
657 ok(len == 5 * sizeof(WCHAR), "WinHttpQueryHeaders failed: invalid length returned, expected 5, got %lu\n", len);
658
660 L"Warning", buffer, &len, &index);
661 ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded, second index should not exist.\n");
662
663 /* Try to fetch the header info with a buffer that's big enough to fit the
664 * string but not the NULL terminator.
665 */
666 index = 0;
667 len = 5*sizeof(WCHAR);
668 memset(check_buffer, 0xab, sizeof(check_buffer));
669 memcpy(buffer, check_buffer, sizeof(buffer));
671 L"Warning", buffer, &len, &index);
672 ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded with a buffer that's too small.\n");
673 ok(memcmp(buffer, check_buffer, sizeof(buffer)) == 0,
674 "WinHttpQueryHeaders failed, modified the buffer when it should not have.\n");
675 ok(len == 6 * sizeof(WCHAR), "WinHttpQueryHeaders returned invalid length, expected 12, got %lu\n", len);
676
677 /* Try with a NULL buffer */
678 index = 0;
679 len = sizeof(buffer);
680 SetLastError(0xdeadbeef);
682 L"Warning", NULL, &len, &index);
683 ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
684 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError());
685 ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %lu\n", len);
686 ok(index == 0, "WinHttpQueryHeaders incorrectly incremented header index.\n");
687
688 /* Try with a NULL buffer and a length that's too small */
689 index = 0;
690 len = 10;
691 SetLastError(0xdeadbeef);
693 L"Warning", NULL, &len, &index);
694 ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
696 "WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError());
697 ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %lu\n", len);
698 ok(index == 0, "WinHttpQueryHeaders incorrectly incremented header index.\n");
699
700 index = 0;
701 len = 0;
702 SetLastError(0xdeadbeef);
704 L"Warning", NULL, &len, &index);
705 ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
707 "WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError());
708 ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %lu\n", len);
709 ok(index == 0, "WinHttpQueryHeaders failed: index was incremented.\n");
710
711 /* valid query */
712 oldlen = len;
713 index = 0;
714 len = sizeof(buffer);
715 memset(buffer, 0xff, sizeof(buffer));
717 L"Warning", buffer, &len, &index);
718 ok(ret == TRUE, "WinHttpQueryHeaders failed: got %d\n", ret);
719 ok(len + sizeof(WCHAR) <= oldlen, "WinHttpQueryHeaders resulting length longer than advertized.\n");
720 ok((len < sizeof(buffer) - sizeof(WCHAR)) && !buffer[len / sizeof(WCHAR)],
721 "WinHttpQueryHeaders did not append NULL terminator\n");
722 ok(len == lstrlenW(buffer) * sizeof(WCHAR), "WinHttpQueryHeaders returned incorrect length.\n");
723 ok(!memcmp(buffer, test_header_begin, sizeof(test_header_begin)), "invalid beginning of header string.\n");
724 ok(!memcmp(buffer + lstrlenW(buffer) - 4, L"\r\n\r\n", sizeof(L"\r\n\r\n")),
725 "WinHttpQueryHeaders returned invalid end of header string.\n");
726 ok(index == 0, "WinHttpQueryHeaders incremented header index.\n");
727
728 index = 0;
729 len = 0;
730 SetLastError(0xdeadbeef);
732 L"Warning", NULL, &len, &index);
733 ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
735 "WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError());
736 ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %lu\n", len);
737 ok(index == 0, "WinHttpQueryHeaders failed: index was incremented.\n");
738
739 oldlen = len;
740 index = 0;
741 len = sizeof(buffer);
742 memset(buffer, 0xff, sizeof(buffer));
744 L"Warning", buffer, &len, &index);
745 ok(ret == TRUE, "WinHttpQueryHeaders failed %lu\n", GetLastError());
746 ok(len + sizeof(WCHAR) <= oldlen, "resulting length longer than advertized\n");
747 ok((len < sizeof(buffer) - sizeof(WCHAR)) && !buffer[len / sizeof(WCHAR)] && !buffer[len / sizeof(WCHAR) - 1],
748 "no double NULL terminator\n");
749 ok(!memcmp(buffer, test_header_begin, sizeof(test_header_begin)), "invalid beginning of header string.\n");
750 ok(index == 0, "header index was incremented\n");
751
752 /* tests for more indices */
754 ok(ret == TRUE, "WinHttpAddRequestHeaders failed to add duplicate header: %d\n", ret);
755
756 index = 0;
757 len = sizeof(buffer);
759 L"Warning", buffer, &len, &index);
760 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
761 ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
762 ok(memcmp(buffer, test_indices[0], sizeof(test_indices[0])) == 0, "WinHttpQueryHeaders returned incorrect string.\n");
763
764 len = sizeof(buffer);
766 L"Warning", buffer, &len, &index);
767 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
768 ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
769 ok(memcmp(buffer, test_indices[1], sizeof(test_indices[1])) == 0, "WinHttpQueryHeaders returned incorrect string.\n");
770
772 ok(ret == TRUE, "WinHttpAddRequestHeaders failed to add duplicate header.\n");
773
774 index = 0;
775 len = sizeof(buffer);
777 L"Warning", buffer, &len, &index);
778 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
779 ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
780 reverse = (memcmp(buffer, test_indices[1], sizeof(test_indices[1])) != 0); /* Win7 returns values in reverse order of adding */
781 ok(!memcmp(buffer, test_indices[reverse ? 2 : 1], sizeof(test_indices[reverse ? 2 : 1])),
782 "WinHttpQueryHeaders returned incorrect string.\n");
783
784 len = sizeof(buffer);
786 L"Warning", buffer, &len, &index);
787 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
788 ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
789 ok(!memcmp(buffer, test_indices[reverse ? 1 : 2], sizeof(test_indices[reverse ? 1 : 2])),
790 "WinHttpQueryHeaders returned incorrect string.\n");
791
792 /* add if new flag */
794 ok(ret == FALSE, "WinHttpAddRequestHeaders incorrectly replaced existing header.\n");
795
796 index = 0;
797 len = sizeof(buffer);
799 L"Warning", buffer, &len, &index);
800 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
801 ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
802 ok(!memcmp(buffer, test_indices[reverse ? 2 : 1], sizeof(test_indices[reverse ? 2 : 1])),
803 "WinHttpQueryHeaders returned incorrect string.\n");
804
805 len = sizeof(buffer);
807 L"Warning", buffer, &len, &index);
808 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
809 ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
810 ok(!memcmp(buffer, test_indices[reverse ? 1 : 2], sizeof(test_indices[reverse ? 1 : 2])),
811 "WinHttpQueryHeaders returned incorrect string.\n");
812
813 len = sizeof(buffer);
815 L"Warning", buffer, &len, &index);
816 ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
817
818 /* coalesce flag */
820 ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE.\n");
821
822 index = 0;
823 len = sizeof(buffer);
825 L"Warning", buffer, &len, &index);
826 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
827 ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
828 ok(!memcmp(buffer, reverse ? L"test3, test4" : L"test2, test4",
829 reverse ? sizeof(L"test3, test4") : sizeof(L"test2, test4")),
830 "WinHttpQueryHeaders returned incorrect string.\n");
831
832 len = sizeof(buffer);
834 L"Warning", buffer, &len, &index);
835 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
836 ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
837 ok(!memcmp(buffer, test_indices[reverse ? 1 : 2], sizeof(test_indices[reverse ? 1 : 2])),
838 "WinHttpQueryHeaders returned incorrect string.\n");
839
840 len = sizeof(buffer);
842 L"Warning", buffer, &len, &index);
843 ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
844
845 /* coalesce with comma flag */
847 ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA.\n");
848
849 index = 0;
850 len = sizeof(buffer);
852 L"Warning", buffer, &len, &index);
853 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
854 ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
855
856 ok(!memcmp(buffer, reverse ? L"test3, test4, test5" : L"test2, test4, test5",
857 reverse ? sizeof(L"test3, test4, test5") : sizeof(L"test2, test4, test5")),
858 "WinHttpQueryHeaders returned incorrect string.\n");
859
860 len = sizeof(buffer);
862 L"Warning", buffer, &len, &index);
863 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
864 ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
865 ok(!memcmp(buffer, test_indices[reverse ? 1 : 2], sizeof(test_indices[reverse ? 1 : 2])),
866 "WinHttpQueryHeaders returned incorrect string.\n");
867
868 len = sizeof(buffer);
870 L"Warning", buffer, &len, &index);
871 ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
872
873
874 /* coalesce with semicolon flag */
876 ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON.\n");
877
878 index = 0;
879 len = sizeof(buffer);
881 L"Warning", buffer, &len, &index);
882 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
883 ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
884
885 ok(!memcmp(buffer, reverse ? L"test3, test4, test5; test6" : L"test2, test4, test5; test6",
886 reverse ? sizeof(L"test3, test4, test5; test6") : sizeof(L"test2, test4, test5; test6")),
887 "WinHttpQueryHeaders returned incorrect string.\n");
888
889 len = sizeof(buffer);
891 L"Warning", buffer, &len, &index);
892 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
893 ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
894 ok(!memcmp(buffer, test_indices[reverse ? 1 : 2], sizeof(test_indices[reverse ? 1 : 2])),
895 "WinHttpQueryHeaders returned incorrect string.\n");
896
897 len = sizeof(buffer);
899 L"Warning", buffer, &len, &index);
900 ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
901
902 /* add and replace flags */
904 ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE.\n");
905
906 index = 0;
907 len = sizeof(buffer);
909 L"Warning", buffer, &len, &index);
910 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
911 ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
912 ok(!memcmp(buffer, test_indices[reverse ? 3 : 2], sizeof(test_indices[reverse ? 3 : 2])),
913 "WinHttpQueryHeaders returned incorrect string.\n");
914
915 len = sizeof(buffer);
917 L"Warning", buffer, &len, &index);
918 ok(ret == TRUE, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
919 ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
920 ok(!memcmp(buffer, test_indices[reverse ? 1 : 3], sizeof(test_indices[reverse ? 1 : 3])),
921 "WinHttpQueryHeaders returned incorrect string.\n");
922
923 len = sizeof(buffer);
925 L"Warning", buffer, &len, &index);
926 ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
927
929 ok(!ret, "WinHttpAddRequestHeaders failed\n");
930
932 ok(ret, "WinHttpAddRequestHeaders failed\n");
933
934 index = 0;
935 memset(buffer, 0xff, sizeof(buffer));
936 len = sizeof(buffer);
938 L"a", buffer, &len, &index);
939 ok(ret, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
940 ok(!memcmp(buffer, L"", sizeof(L"")), "unexpected result\n");
941
943 ok(!ret, "WinHttpAddRequestHeaders failed\n");
944
946 ok(!ret, "WinHttpAddRequestHeaders failed\n");
947
949 ok(!ret, "WinHttpAddRequestHeaders failed\n");
950
952 ok(ret, "WinHttpAddRequestHeaders failed\n");
953
955 ok(!ret, "adding %s succeeded.\n", debugstr_w(test_headers[16]));
956
957 index = 0;
958 buffer[0] = 0;
959 len = sizeof(buffer);
961 L"field", buffer, &len, &index);
962 ok(ret, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
963 ok(!memcmp(buffer, L"value ", sizeof(L"value ")) || !memcmp(buffer, L"value", sizeof(L"value")),
964 "unexpected result\n");
965
966 SetLastError(0xdeadbeef);
967 ret = WinHttpAddRequestHeaders(request, L"Range: bytes=0-773\r\n", 0,
969 err = GetLastError();
970 ok(!ret, "unexpected success\n");
971 ok(err == ERROR_INVALID_PARAMETER, "got %lu\n", err);
972
973 ret = WinHttpAddRequestHeaders(request, L"Range: bytes=0-773\r\n", ~0u,
975 ok(ret, "failed to add header: %lu\n", GetLastError());
976
977 index = 0;
978 len = sizeof(buffer);
980 L"Range", buffer, &len, &index);
981 ok(ret, "failed to get range header %lu\n", GetLastError());
982 ok(!memcmp(buffer, L"bytes=0-773", sizeof(L"bytes=0-773")), "incorrect string returned\n");
983 ok(len == lstrlenW(L"bytes=0-773") * sizeof(WCHAR), "wrong length %lu\n", len);
984 ok(index == 1, "wrong index %lu\n", index);
985 index = 0;
986 len = sizeof(buffer);
988 L"name", buffer, &len, &index);
989 ok(!ret, "unexpected success\n");
990
991 SetLastError(0xdeadbeef);
993 err = GetLastError();
994 ok(!ret, "unexpected success\n");
995 ok(err == ERROR_WINHTTP_HEADER_NOT_FOUND, "got %lu\n", err);
996
998 ok(ret, "got %lu\n", GetLastError());
999
1000 index = 0;
1001 len = sizeof(buffer);
1003 L"name", buffer, &len, &index);
1004 ok(ret, "got %lu\n", GetLastError());
1005 ok(index == 1, "wrong index %lu\n", index);
1006 ok(!memcmp(buffer, L"value", sizeof(L"value")), "incorrect string\n");
1007
1009 ok(ret, "got %lu\n", GetLastError());
1010
1011 index = 0;
1012 len = sizeof(buffer);
1013 SetLastError(0xdeadbeef);
1015 L"name", buffer, &len, &index);
1016 err = GetLastError();
1017 ok(!ret, "unexpected success\n");
1018 ok(err == ERROR_WINHTTP_HEADER_NOT_FOUND, "got %lu\n", err);
1019
1020 ret = WinHttpAddRequestHeaders(request, test_headers[14], -1L, 0);
1021 ok(ret, "got %lu\n", GetLastError());
1022
1023 index = 0;
1024 len = sizeof(buffer);
1026 L"name", buffer, &len, &index);
1027 ok(ret, "got %lu\n", GetLastError());
1028 ok(index == 1, "wrong index %lu\n", index);
1029 ok(!memcmp(buffer, L"value", sizeof(L"value")), "incorrect string\n");
1030
1032 ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n", ret);
1033 done:
1034 ret = WinHttpCloseHandle(connection);
1035 ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret);
1037 ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n", ret);
1038
1039}
1040
1042{
1043 DWORD flags = *(DWORD *)buf;
1044
1045 if (!flags)
1046 {
1047 trace("WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR\n");
1048 return;
1049 }
1050#define X(x) if (flags & x) trace("%s\n", #x);
1058#undef X
1059}
1060
1061static void test_secure_connection(void)
1062{
1063 static const char data_start[] = "<!DOCTYPE html PUBLIC";
1064 HINTERNET ses, con, req;
1065 DWORD size, status, policy, bitness, read_size, err, available_size, protocols, flags;
1066 BOOL ret;
1069 char buffer[32];
1070
1071 ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
1072 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
1073
1076 ok(ret, "failed to set redirect policy %lu\n", GetLastError());
1077
1080 err = GetLastError();
1081 ok(ret || err == ERROR_INVALID_PARAMETER /* < win7 */, "failed to set protocols %lu\n", err);
1082
1083 con = WinHttpConnect(ses, L"test.winehq.org", 443, 0);
1084 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
1085
1086 SetLastError( 0xdeadbeef );
1089 err = GetLastError();
1090 ok(!ret, "unexpected success\n");
1092
1093 /* try without setting WINHTTP_FLAG_SECURE */
1094 req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
1095 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
1096
1098 err = GetLastError();
1099 ok(!ret, "unexpected success\n");
1101 "setting client cert context returned %lu\n", err);
1102
1103 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
1104 err = GetLastError();
1106 {
1107 skip("Connection failed, skipping.\n");
1108 goto cleanup;
1109 }
1110 ok(ret, "failed to send request %lu\n", GetLastError());
1111
1113 ok(ret, "failed to receive response %lu\n", GetLastError());
1114
1115 status = 0xdeadbeef;
1116 size = sizeof(status);
1118 ok(ret, "header query failed %lu\n", GetLastError());
1119 ok(status == HTTP_STATUS_BAD_REQUEST, "got %lu\n", status);
1120
1121 WinHttpCloseHandle(req);
1122
1124 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
1125
1126 flags = 0xdeadbeef;
1127 size = sizeof(flags);
1129 ok(ret, "failed to query security flags %lu\n", GetLastError());
1130 ok(!flags, "got %#lx\n", flags);
1131
1134 ok(ret, "failed to set security flags %lu\n", GetLastError());
1135
1138 ok(!ret, "success\n");
1139
1142 ok(!ret, "success\n");
1143
1147 ok(ret, "failed to set security flags %lu\n", GetLastError());
1148
1149 flags = 0;
1151 ok(ret, "failed to set security flags %lu\n", GetLastError());
1152
1154 err = GetLastError();
1155 ok(ret || broken(!ret && err == ERROR_INVALID_PARAMETER) /* winxp */, "failed to set client cert context %lu\n", err);
1156
1158
1159 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
1160 err = GetLastError();
1163 {
1164 skip("secure connection failed, skipping remaining secure tests\n");
1165 goto cleanup;
1166 }
1167 ok(ret, "failed to send request %lu\n", GetLastError());
1168
1169 size = sizeof(cert);
1171 ok(ret, "failed to retrieve certificate context %lu\n", GetLastError());
1173
1174 size = sizeof(bitness);
1176 ok(ret, "failed to retrieve key bitness %lu\n", GetLastError());
1177
1178 size = sizeof(info);
1180 ok(ret, "failed to retrieve certificate info %lu\n", GetLastError());
1181
1182 if (ret)
1183 {
1184 trace("lpszSubjectInfo %s\n", wine_dbgstr_w(info.lpszSubjectInfo));
1185 trace("lpszIssuerInfo %s\n", wine_dbgstr_w(info.lpszIssuerInfo));
1186 trace("lpszProtocolName %s\n", wine_dbgstr_w(info.lpszProtocolName));
1187 trace("lpszSignatureAlgName %s\n", wine_dbgstr_w(info.lpszSignatureAlgName));
1188 trace("lpszEncryptionAlgName %s\n", wine_dbgstr_w(info.lpszEncryptionAlgName));
1189 trace("dwKeySize %lu\n", info.dwKeySize);
1190 LocalFree( info.lpszSubjectInfo );
1191 LocalFree( info.lpszIssuerInfo );
1192 }
1193
1196 {
1197 skip("connection error, skipping remaining secure tests\n");
1198 goto cleanup;
1199 }
1200 ok(ret, "failed to receive response %lu\n", GetLastError());
1201
1202 available_size = 0;
1203 ret = WinHttpQueryDataAvailable(req, &available_size);
1204 ok(ret, "failed to query available data %lu\n", GetLastError());
1205 ok(available_size > 2014, "available_size = %lu\n", available_size);
1206
1207 status = 0xdeadbeef;
1208 size = sizeof(status);
1210 ok(ret, "failed unexpectedly %lu\n", GetLastError());
1211 ok(status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status);
1212
1213 size = 0;
1215 ok(!ret, "succeeded unexpectedly\n");
1216
1217 read_size = 0;
1218 for (;;)
1219 {
1220 size = 0;
1221 ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
1222 ok(ret == TRUE, "WinHttpReadData failed: %lu\n", GetLastError());
1223 if (!size) break;
1224 read_size += size;
1225
1226 if (read_size <= 32)
1227 ok(!memcmp(buffer, data_start, sizeof(data_start)-1), "not expected: %.32s\n", buffer);
1228 }
1229 ok(read_size >= available_size, "read_size = %lu, available_size = %lu\n", read_size, available_size);
1230
1231 size = sizeof(cert);
1233 ok(ret, "failed to retrieve certificate context %lu\n", GetLastError());
1235
1236cleanup:
1237 WinHttpCloseHandle(req);
1238 WinHttpCloseHandle(con);
1239 WinHttpCloseHandle(ses);
1240}
1241
1243{
1244 HINTERNET ses, con, req;
1246 WCHAR *version;
1247 BOOL ret;
1248
1249 ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
1250 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
1251
1252 con = WinHttpConnect(ses, L"test.winehq.org", 0, 0);
1253 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
1254
1255 req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
1256 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
1257
1258 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
1259 error = GetLastError();
1261 {
1262 skip("connection failed, skipping\n");
1263 goto done;
1264 }
1265 ok(ret, "failed to send request %lu\n", GetLastError());
1266
1268 ok(ret, "failed to receive response %lu\n", GetLastError());
1269
1270 status = 0xdeadbeef;
1271 size = sizeof(status);
1273 ok(ret, "failed unexpectedly %lu\n", GetLastError());
1274 ok(status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status);
1275
1276 WinHttpCloseHandle(req);
1277
1278 req = WinHttpOpenRequest(con, L"", L"", L"", NULL, NULL, 0);
1279 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
1280
1281 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
1282 error = GetLastError();
1284 {
1285 skip("connection failed, skipping\n");
1286 goto done;
1287 }
1288 ok(ret, "failed to send request %lu\n", GetLastError());
1289
1291 ok(ret, "failed to receive response %lu\n", GetLastError());
1292
1293 size = 0;
1294 SetLastError(0xdeadbeef);
1296 error = GetLastError();
1297 ok(!ret, "succeeded unexpectedly\n");
1298 ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", error);
1299
1302 ok(ret, "failed unexpectedly %lu\n", GetLastError());
1303 ok(lstrlenW(version) == size / sizeof(WCHAR), "unexpected size %lu\n", size);
1305
1306 status = 0xdeadbeef;
1307 size = sizeof(status);
1309 ok(ret, "failed unexpectedly %lu\n", GetLastError());
1310 ok(status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status);
1311
1312done:
1313 WinHttpCloseHandle(req);
1314 WinHttpCloseHandle(con);
1315 WinHttpCloseHandle(ses);
1316}
1317
1318static const WCHAR Connections[] = {
1319 'S','o','f','t','w','a','r','e','\\',
1320 'M','i','c','r','o','s','o','f','t','\\',
1321 'W','i','n','d','o','w','s','\\',
1322 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1323 'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
1324 'C','o','n','n','e','c','t','i','o','n','s',0 };
1325static const WCHAR WinHttpSettings[] = {
1326 'W','i','n','H','t','t','p','S','e','t','t','i','n','g','s',0 };
1327
1329{
1330 LONG l;
1331 HKEY key;
1332 DWORD ret = 0;
1333
1335 if (!l)
1336 {
1337 DWORD size = 0;
1338
1340 if (!l)
1341 {
1342 if (size <= len)
1344 &size );
1345 if (!l)
1346 ret = size;
1347 }
1348 RegCloseKey( key );
1349 }
1350 return ret;
1351}
1352
1354{
1355 HKEY hkey;
1357 {
1358 if (len) RegSetValueExW( hkey, WinHttpSettings, 0, type, buf, len );
1359 else RegDeleteValueW( hkey, WinHttpSettings );
1360 RegCloseKey( hkey );
1361 }
1362}
1363
1365{
1366 BOOL wow64;
1368 if (sizeof(void *) > sizeof(int) || wow64)
1369 {
1372 }
1373 else
1375}
1376
1378{
1379 static WCHAR wideString[] = { 0x226f, 0x575b, 0 };
1380 static WCHAR normalString[] = { 'f','o','o',0 };
1381 DWORD type, len;
1382 BYTE *saved_proxy_settings = NULL;
1384 BOOL ret;
1385
1386 /* FIXME: it would be simpler to read the current settings using
1387 * WinHttpGetDefaultProxyConfiguration and save them using
1388 * WinHttpSetDefaultProxyConfiguration, but they appear to have a bug.
1389 *
1390 * If a proxy is configured in the registry, e.g. via 'proxcfg -p "foo"',
1391 * the access type reported by WinHttpGetDefaultProxyConfiguration is 1,
1392 * WINHTTP_ACCESS_TYPE_NO_PROXY, whereas it should be
1393 * WINHTTP_ACCESS_TYPE_NAMED_PROXY.
1394 * If WinHttpSetDefaultProxyConfiguration is called with dwAccessType = 1,
1395 * the lpszProxy and lpszProxyBypass values are ignored.
1396 * Thus, if a proxy is set with proxycfg, then calling
1397 * WinHttpGetDefaultProxyConfiguration followed by
1398 * WinHttpSetDefaultProxyConfiguration results in the proxy settings
1399 * getting deleted from the registry.
1400 *
1401 * Instead I read the current registry value and restore it directly.
1402 */
1404 if (len)
1405 {
1406 saved_proxy_settings = HeapAlloc( GetProcessHeap(), 0, len );
1407 len = get_default_proxy_reg_value( saved_proxy_settings, len, &type );
1408 }
1409
1410 if (0)
1411 {
1412 /* Crashes on Vista and higher */
1413 SetLastError(0xdeadbeef);
1416 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1417 }
1418
1419 /* test with invalid access type */
1420 info.dwAccessType = 0xdeadbeef;
1421 info.lpszProxy = info.lpszProxyBypass = NULL;
1422 SetLastError(0xdeadbeef);
1425 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1426
1427 /* at a minimum, the proxy server must be set */
1429 info.lpszProxy = info.lpszProxyBypass = NULL;
1430 SetLastError(0xdeadbeef);
1433 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1434 info.lpszProxyBypass = normalString;
1435 SetLastError(0xdeadbeef);
1438 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1439
1440 /* the proxy server can't have wide characters */
1441 info.lpszProxy = wideString;
1442 SetLastError(0xdeadbeef);
1445 skip("couldn't set default proxy configuration: access denied\n");
1446 else
1448 broken(ret), /* Earlier winhttp versions on W2K/XP */
1449 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1450
1451 info.lpszProxy = normalString;
1452 SetLastError(0xdeadbeef);
1455 skip("couldn't set default proxy configuration: access denied\n");
1456 else
1457 {
1458 ok(ret, "WinHttpSetDefaultProxyConfiguration failed: %lu\n", GetLastError());
1459 ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
1460 "got %lu\n", GetLastError());
1461 }
1462 set_default_proxy_reg_value( saved_proxy_settings, len, type );
1463}
1464
1465static void test_timeouts(void)
1466{
1467 BOOL ret;
1468 DWORD value, size;
1469 HINTERNET ses, req, con;
1470
1471 ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
1472 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
1473
1474 SetLastError(0xdeadbeef);
1475 ret = WinHttpSetTimeouts(ses, -2, 0, 0, 0);
1477 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1478
1479 SetLastError(0xdeadbeef);
1480 ret = WinHttpSetTimeouts(ses, 0, -2, 0, 0);
1482 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1483
1484 SetLastError(0xdeadbeef);
1485 ret = WinHttpSetTimeouts(ses, 0, 0, -2, 0);
1487 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1488
1489 SetLastError(0xdeadbeef);
1490 ret = WinHttpSetTimeouts(ses, 0, 0, 0, -2);
1492 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1493
1494 SetLastError(0xdeadbeef);
1495 ret = WinHttpSetTimeouts(ses, -1, -1, -1, -1);
1496 ok(ret, "%lu\n", GetLastError());
1497 ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
1498 "expected ERROR_SUCCESS, got %lu\n", GetLastError());
1499
1500 SetLastError(0xdeadbeef);
1501 ret = WinHttpSetTimeouts(ses, 0, 0, 0, 0);
1502 ok(ret, "%lu\n", GetLastError());
1503
1504 SetLastError(0xdeadbeef);
1505 ret = WinHttpSetTimeouts(ses, 0x0123, 0x4567, 0x89ab, 0xcdef);
1506 ok(ret, "%lu\n", GetLastError());
1507
1508 SetLastError(0xdeadbeef);
1509 value = 0xdeadbeef;
1510 size = sizeof(DWORD);
1512 ok(ret, "%lu\n", GetLastError());
1513 ok(value == 0x0123, "Expected 0x0123, got %lu\n", value);
1514
1515 SetLastError(0xdeadbeef);
1516 value = 0xdeadbeef;
1517 size = sizeof(DWORD);
1519 ok(ret, "%lu\n", GetLastError());
1520 ok(value == 0x4567, "Expected 0x4567, got %lu\n", value);
1521
1522 SetLastError(0xdeadbeef);
1523 value = 0xdeadbeef;
1524 size = sizeof(DWORD);
1526 ok(ret, "%lu\n", GetLastError());
1527 ok(value == 0x89ab, "Expected 0x89ab, got %lu\n", value);
1528
1529 SetLastError(0xdeadbeef);
1530 value = 0xdeadbeef;
1531 size = sizeof(DWORD);
1533 ok(ret, "%lu\n", GetLastError());
1534 ok(value == 0xcdef, "Expected 0xcdef, got %lu\n", value);
1535
1536 SetLastError(0xdeadbeef);
1537 value = 0;
1539 ok(ret, "%lu\n", GetLastError());
1540
1541 SetLastError(0xdeadbeef);
1542 value = 0xdeadbeef;
1543 size = sizeof(DWORD);
1545 ok(ret, "%lu\n", GetLastError());
1546 ok(value == 0, "Expected 0, got %lu\n", value);
1547
1548 SetLastError(0xdeadbeef);
1549 value = 0;
1551 ok(ret, "%lu\n", GetLastError());
1552
1553 SetLastError(0xdeadbeef);
1554 value = 0xdeadbeef;
1555 size = sizeof(DWORD);
1557 ok(ret, "%lu\n", GetLastError());
1558 ok(value == 0, "Expected 0, got %lu\n", value);
1559
1560 SetLastError(0xdeadbeef);
1561 value = 0;
1563 ok(ret, "%lu\n", GetLastError());
1564
1565 SetLastError(0xdeadbeef);
1566 value = 0xdeadbeef;
1567 size = sizeof(DWORD);
1569 ok(ret, "%lu\n", GetLastError());
1570 ok(value == 0, "Expected 0, got %lu\n", value);
1571
1572 SetLastError(0xdeadbeef);
1573 value = 0;
1575 ok(ret, "%lu\n", GetLastError());
1576
1577 SetLastError(0xdeadbeef);
1578 value = 0xdeadbeef;
1579 size = sizeof(DWORD);
1581 ok(ret, "%lu\n", GetLastError());
1582 ok(value == 0, "Expected 0, got %lu\n", value);
1583
1584 SetLastError(0xdeadbeef);
1585 value = 0xbeefdead;
1587 ok(ret, "%lu\n", GetLastError());
1588
1589 SetLastError(0xdeadbeef);
1590 value = 0xdeadbeef;
1591 size = sizeof(DWORD);
1593 ok(ret, "%lu\n", GetLastError());
1594 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1595
1596 SetLastError(0xdeadbeef);
1597 value = 0xbeefdead;
1599 ok(ret, "%lu\n", GetLastError());
1600
1601 SetLastError(0xdeadbeef);
1602 value = 0xdeadbeef;
1603 size = sizeof(DWORD);
1605 ok(ret, "%lu\n", GetLastError());
1606 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1607
1608 SetLastError(0xdeadbeef);
1609 value = 0xbeefdead;
1611 ok(ret, "%lu\n", GetLastError());
1612
1613 SetLastError(0xdeadbeef);
1614 value = 0xdeadbeef;
1615 size = sizeof(DWORD);
1617 ok(ret, "%lu\n", GetLastError());
1618 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1619
1620 SetLastError(0xdeadbeef);
1621 value = 0xbeefdead;
1623 ok(ret, "%lu\n", GetLastError());
1624
1625 SetLastError(0xdeadbeef);
1626 value = 0xdeadbeef;
1627 size = sizeof(DWORD);
1629 ok(ret, "%lu\n", GetLastError());
1630 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1631
1632 con = WinHttpConnect(ses, L"test.winehq.org", 0, 0);
1633 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
1634
1635 /* Timeout values should match the last one set for session */
1636 SetLastError(0xdeadbeef);
1637 value = 0xdeadbeef;
1638 size = sizeof(DWORD);
1640 ok(ret, "%lu\n", GetLastError());
1641 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1642
1643 SetLastError(0xdeadbeef);
1644 value = 0xdeadbeef;
1645 size = sizeof(DWORD);
1647 ok(ret, "%lu\n", GetLastError());
1648 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1649
1650 SetLastError(0xdeadbeef);
1651 value = 0xdeadbeef;
1652 size = sizeof(DWORD);
1654 ok(ret, "%lu\n", GetLastError());
1655 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1656
1657 SetLastError(0xdeadbeef);
1658 value = 0xdeadbeef;
1659 size = sizeof(DWORD);
1661 ok(ret, "%lu\n", GetLastError());
1662 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1663
1664 SetLastError(0xdeadbeef);
1665 ret = WinHttpSetTimeouts(con, -2, 0, 0, 0);
1667 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1668
1669 SetLastError(0xdeadbeef);
1670 ret = WinHttpSetTimeouts(con, 0, -2, 0, 0);
1672 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1673
1674 SetLastError(0xdeadbeef);
1675 ret = WinHttpSetTimeouts(con, 0, 0, -2, 0);
1677 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1678
1679 SetLastError(0xdeadbeef);
1680 ret = WinHttpSetTimeouts(con, 0, 0, 0, -2);
1682 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1683
1684 SetLastError(0xdeadbeef);
1685 ret = WinHttpSetTimeouts(con, -1, -1, -1, -1);
1687 "expected ERROR_WINHTTP_INVALID_TYPE, got %lu\n", GetLastError());
1688
1689 SetLastError(0xdeadbeef);
1690 ret = WinHttpSetTimeouts(con, 0, 0, 0, 0);
1692 "expected ERROR_WINHTTP_INVALID_TYPE, got %lu\n", GetLastError());
1693
1694 SetLastError(0xdeadbeef);
1695 value = 0;
1698 "expected ERROR_WINHTTP_INVALID_TYPE, got %lu\n", GetLastError());
1699
1700 SetLastError(0xdeadbeef);
1701 value = 0;
1704 "expected ERROR_WINHTTP_INVALID_TYPE, got %lu\n", GetLastError());
1705
1706 SetLastError(0xdeadbeef);
1707 value = 0;
1710 "expected ERROR_WINHTTP_INVALID_TYPE, got %lu\n", GetLastError());
1711
1712 SetLastError(0xdeadbeef);
1713 value = 0;
1716 "expected ERROR_WINHTTP_INVALID_TYPE, got %lu\n", GetLastError());
1717
1718 /* Changing timeout values for session should affect the values for connection */
1719 SetLastError(0xdeadbeef);
1720 value = 0xdead;
1722 ok(ret, "%lu\n", GetLastError());
1723
1724 SetLastError(0xdeadbeef);
1725 value = 0xdeadbeef;
1726 size = sizeof(DWORD);
1728 ok(ret, "%lu\n", GetLastError());
1729 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1730
1731 SetLastError(0xdeadbeef);
1732 value = 0xdead;
1734 ok(ret, "%lu\n", GetLastError());
1735
1736 SetLastError(0xdeadbeef);
1737 value = 0xdeadbeef;
1738 size = sizeof(DWORD);
1740 ok(ret, "%lu\n", GetLastError());
1741 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1742
1743 SetLastError(0xdeadbeef);
1744 value = 0xdead;
1746 ok(ret, "%lu\n", GetLastError());
1747
1748 SetLastError(0xdeadbeef);
1749 value = 0xdeadbeef;
1750 size = sizeof(DWORD);
1752 ok(ret, "%lu\n", GetLastError());
1753 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1754
1755 SetLastError(0xdeadbeef);
1756 value = 0xdead;
1758 ok(ret, "%lu\n", GetLastError());
1759
1760 SetLastError(0xdeadbeef);
1761 value = 0xdeadbeef;
1762 size = sizeof(DWORD);
1764 ok(ret, "%lu\n", GetLastError());
1765 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1766
1767 req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
1768 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
1769
1770 /* Timeout values should match the last one set for session */
1771 SetLastError(0xdeadbeef);
1772 value = 0xdeadbeef;
1773 size = sizeof(DWORD);
1775 ok(ret, "%lu\n", GetLastError());
1776 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1777
1778 SetLastError(0xdeadbeef);
1779 value = 0xdeadbeef;
1780 size = sizeof(DWORD);
1782 ok(ret, "%lu\n", GetLastError());
1783 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1784
1785 SetLastError(0xdeadbeef);
1786 value = 0xdeadbeef;
1787 size = sizeof(DWORD);
1789 ok(ret, "%lu\n", GetLastError());
1790 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1791
1792 SetLastError(0xdeadbeef);
1793 value = 0xdeadbeef;
1794 size = sizeof(DWORD);
1796 ok(ret, "%lu\n", GetLastError());
1797 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1798
1799 SetLastError(0xdeadbeef);
1800 ret = WinHttpSetTimeouts(req, -2, 0, 0, 0);
1802 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1803
1804 SetLastError(0xdeadbeef);
1805 ret = WinHttpSetTimeouts(req, 0, -2, 0, 0);
1807 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1808
1809 SetLastError(0xdeadbeef);
1810 ret = WinHttpSetTimeouts(req, 0, 0, -2, 0);
1812 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1813
1814 SetLastError(0xdeadbeef);
1815 ret = WinHttpSetTimeouts(req, 0, 0, 0, -2);
1817 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
1818
1819 SetLastError(0xdeadbeef);
1820 ret = WinHttpSetTimeouts(req, -1, -1, -1, -1);
1821 ok(ret, "%lu\n", GetLastError());
1822
1823 SetLastError(0xdeadbeef);
1824 ret = WinHttpSetTimeouts(req, 0, 0, 0, 0);
1825 ok(ret, "%lu\n", GetLastError());
1826
1827 SetLastError(0xdeadbeef);
1828 ret = WinHttpSetTimeouts(req, 0xcdef, 0x89ab, 0x4567, 0x0123);
1829 ok(ret, "%lu\n", GetLastError());
1830
1831 SetLastError(0xdeadbeef);
1832 value = 0xdeadbeef;
1833 size = sizeof(DWORD);
1835 ok(ret, "%lu\n", GetLastError());
1836 ok(value == 0xcdef, "Expected 0xcdef, got %lu\n", value);
1837
1838 SetLastError(0xdeadbeef);
1839 value = 0xdeadbeef;
1840 size = sizeof(DWORD);
1842 ok(ret, "%lu\n", GetLastError());
1843 ok(value == 0x89ab, "Expected 0x89ab, got %lu\n", value);
1844
1845 SetLastError(0xdeadbeef);
1846 value = 0xdeadbeef;
1847 size = sizeof(DWORD);
1849 ok(ret, "%lu\n", GetLastError());
1850 ok(value == 0x4567, "Expected 0x4567, got %lu\n", value);
1851
1852 SetLastError(0xdeadbeef);
1853 value = 0xdeadbeef;
1854 size = sizeof(DWORD);
1856 ok(ret, "%lu\n", GetLastError());
1857 ok(value == 0x0123, "Expected 0x0123, got %lu\n", value);
1858
1859 SetLastError(0xdeadbeef);
1860 value = 0;
1862 ok(ret, "%lu\n", GetLastError());
1863
1864 SetLastError(0xdeadbeef);
1865 value = 0xdeadbeef;
1866 size = sizeof(DWORD);
1868 ok(ret, "%lu\n", GetLastError());
1869 ok(value == 0, "Expected 0, got %lu\n", value);
1870
1871 SetLastError(0xdeadbeef);
1872 value = 0;
1874 ok(ret, "%lu\n", GetLastError());
1875
1876 SetLastError(0xdeadbeef);
1877 value = 0xdeadbeef;
1878 size = sizeof(DWORD);
1880 ok(ret, "%lu\n", GetLastError());
1881 ok(value == 0, "Expected 0, got %lu\n", value);
1882
1883 SetLastError(0xdeadbeef);
1884 value = 0;
1886 ok(ret, "%lu\n", GetLastError());
1887
1888 SetLastError(0xdeadbeef);
1889 value = 0xdeadbeef;
1890 size = sizeof(DWORD);
1892 ok(ret, "%lu\n", GetLastError());
1893 ok(value == 0, "Expected 0, got %lu\n", value);
1894
1895 SetLastError(0xdeadbeef);
1896 value = 0;
1898 ok(ret, "%lu\n", GetLastError());
1899
1900 SetLastError(0xdeadbeef);
1901 value = 0xdeadbeef;
1902 size = sizeof(DWORD);
1904 ok(ret, "%lu\n", GetLastError());
1905 ok(value == 0, "Expected 0, got %lu\n", value);
1906
1907 SetLastError(0xdeadbeef);
1908 value = 0xbeefdead;
1910 ok(ret, "%lu\n", GetLastError());
1911
1912 SetLastError(0xdeadbeef);
1913 value = 0xdeadbeef;
1914 size = sizeof(DWORD);
1916 ok(ret, "%lu\n", GetLastError());
1917 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1918
1919 SetLastError(0xdeadbeef);
1920 value = 0xbeefdead;
1922 ok(ret, "%lu\n", GetLastError());
1923
1924 SetLastError(0xdeadbeef);
1925 value = 0xdeadbeef;
1926 size = sizeof(DWORD);
1928 ok(ret, "%lu\n", GetLastError());
1929 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1930
1931 SetLastError(0xdeadbeef);
1932 value = 0xbeefdead;
1934 ok(ret, "%lu\n", GetLastError());
1935
1936 SetLastError(0xdeadbeef);
1937 value = 0xdeadbeef;
1938 size = sizeof(DWORD);
1940 ok(ret, "%lu\n", GetLastError());
1941 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1942
1943 SetLastError(0xdeadbeef);
1944 value = 0xbeefdead;
1946 ok(ret, "%lu\n", GetLastError());
1947
1948 SetLastError(0xdeadbeef);
1949 value = 0xdeadbeef;
1950 size = sizeof(DWORD);
1952 ok(ret, "%lu\n", GetLastError());
1953 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
1954
1955 /* Changing timeout values for session should not affect the values for a request,
1956 * neither should the other way around.
1957 */
1958 SetLastError(0xdeadbeef);
1959 value = 0xbeefdead;
1961 ok(ret, "%lu\n", GetLastError());
1962
1963 SetLastError(0xdeadbeef);
1964 value = 0xdeadbeef;
1965 size = sizeof(DWORD);
1967 ok(ret, "%lu\n", GetLastError());
1968 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1969
1970 SetLastError(0xdeadbeef);
1971 value = 0xbeefdead;
1973 ok(ret, "%lu\n", GetLastError());
1974
1975 SetLastError(0xdeadbeef);
1976 value = 0xdeadbeef;
1977 size = sizeof(DWORD);
1979 ok(ret, "%lu\n", GetLastError());
1980 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1981
1982 SetLastError(0xdeadbeef);
1983 value = 0xbeefdead;
1985 ok(ret, "%lu\n", GetLastError());
1986
1987 SetLastError(0xdeadbeef);
1988 value = 0xdeadbeef;
1989 size = sizeof(DWORD);
1991 ok(ret, "%lu\n", GetLastError());
1992 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
1993
1994 SetLastError(0xdeadbeef);
1995 value = 0xbeefdead;
1997 ok(ret, "%lu\n", GetLastError());
1998
1999 SetLastError(0xdeadbeef);
2000 value = 0xdeadbeef;
2001 size = sizeof(DWORD);
2003 ok(ret, "%lu\n", GetLastError());
2004 ok(value == 0xdead, "Expected 0xdead, got %lu\n", value);
2005
2006 SetLastError(0xdeadbeef);
2007 value = 0xbeef;
2009 ok(ret, "%lu\n", GetLastError());
2010
2011 SetLastError(0xdeadbeef);
2012 value = 0xdeadbeef;
2013 size = sizeof(DWORD);
2015 ok(ret, "%lu\n", GetLastError());
2016 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
2017
2018 SetLastError(0xdeadbeef);
2019 value = 0xbeef;
2021 ok(ret, "%lu\n", GetLastError());
2022
2023 SetLastError(0xdeadbeef);
2024 value = 0xdeadbeef;
2025 size = sizeof(DWORD);
2027 ok(ret, "%lu\n", GetLastError());
2028 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
2029
2030 SetLastError(0xdeadbeef);
2031 value = 0xbeef;
2033 ok(ret, "%lu\n", GetLastError());
2034
2035 SetLastError(0xdeadbeef);
2036 value = 0xdeadbeef;
2037 size = sizeof(DWORD);
2039 ok(ret, "%lu\n", GetLastError());
2040 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
2041
2042 SetLastError(0xdeadbeef);
2043 value = 0xbeef;
2045 ok(ret, "%lu\n", GetLastError());
2046
2047 SetLastError(0xdeadbeef);
2048 value = 0xdeadbeef;
2049 size = sizeof(DWORD);
2051 ok(ret, "%lu\n", GetLastError());
2052 ok(value == 0xbeefdead, "Expected 0xbeefdead, got %lu\n", value);
2053
2054 /* response timeout */
2055 SetLastError(0xdeadbeef);
2056 value = 0xdeadbeef;
2057 size = sizeof(value);
2059 ok(ret, "%lu\n", GetLastError());
2060 ok(value == ~0u, "got %lu\n", value);
2061
2062 SetLastError(0xdeadbeef);
2063 value = 30000;
2065 ok(ret, "%lu\n", GetLastError());
2066
2067 SetLastError(0xdeadbeef);
2068 value = 0xdeadbeef;
2069 size = sizeof(value);
2071 ok(ret, "%lu\n", GetLastError());
2072 todo_wine ok(value == 0xbeefdead, "got %lu\n", value);
2073
2074 SetLastError(0xdeadbeef);
2075 value = 0xdeadbeef;
2076 size = sizeof(value);
2078 ok(ret, "%lu\n", GetLastError());
2079 ok(value == ~0u, "got %lu\n", value);
2080
2081 SetLastError(0xdeadbeef);
2082 value = 30000;
2084 ok(!ret, "expected failure\n");
2086
2087 SetLastError(0xdeadbeef);
2088 value = 0xdeadbeef;
2089 size = sizeof(value);
2091 ok(ret, "%lu\n", GetLastError());
2092 ok(value == ~0u, "got %lu\n", value);
2093
2094 SetLastError(0xdeadbeef);
2095 value = 48878;
2097 ok(ret, "%lu\n", GetLastError());
2098
2099 SetLastError(0xdeadbeef);
2100 value = 0xdeadbeef;
2101 size = sizeof(value);
2103 ok(ret, "%lu\n", GetLastError());
2104 todo_wine ok(value == 48879, "got %lu\n", value);
2105
2106 SetLastError(0xdeadbeef);
2107 value = 48880;
2109 ok(ret, "%lu\n", GetLastError());
2110
2111 SetLastError(0xdeadbeef);
2112 value = 0xdeadbeef;
2113 size = sizeof(value);
2115 ok(ret, "%lu\n", GetLastError());
2116 ok(value == 48880, "got %lu\n", value);
2117
2118 WinHttpCloseHandle(req);
2119 WinHttpCloseHandle(con);
2120 WinHttpCloseHandle(ses);
2121}
2122
2123static void test_resolve_timeout(void)
2124{
2125 HINTERNET ses, con, req;
2126 DWORD timeout;
2127 BOOL ret;
2128
2129 if (! proxy_active())
2130 {
2131 ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
2132 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
2133
2134 timeout = 10000;
2136 ok(ret, "failed to set resolve timeout %lu\n", GetLastError());
2137
2138 con = WinHttpConnect(ses, L"nxdomain.winehq.org", 0, 0);
2139 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
2140
2141 req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
2142 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
2143
2144 SetLastError(0xdeadbeef);
2145 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2146 if (ret)
2147 {
2148 skip("nxdomain returned success. Broken ISP redirects?\n");
2149 goto done;
2150 }
2152 "expected ERROR_WINHTTP_NAME_NOT_RESOLVED got %lu\n", GetLastError());
2153
2157 "got %lu\n", GetLastError() );
2158
2159 WinHttpCloseHandle(req);
2160 WinHttpCloseHandle(con);
2161 WinHttpCloseHandle(ses);
2162 }
2163 else
2164 skip("Skipping host resolution tests, host resolution performed by proxy\n");
2165
2166 ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
2167 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
2168
2169 timeout = 10000;
2171 ok(ret, "failed to set resolve timeout %lu\n", GetLastError());
2172
2173 con = WinHttpConnect(ses, L"test.winehq.org", 0, 0);
2174 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
2175
2176 req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
2177 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
2178
2179 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2181 {
2182 skip("connection failed, skipping\n");
2183 goto done;
2184 }
2185 ok(ret, "failed to send request\n");
2186
2187 done:
2188 WinHttpCloseHandle(req);
2189 WinHttpCloseHandle(con);
2190 WinHttpCloseHandle(ses);
2191}
2192
2193static const char page1[] =
2194"<HTML>\r\n"
2195"<HEAD><TITLE>winhttp test page</TITLE></HEAD>\r\n"
2196"<BODY>The quick brown fox jumped over the lazy dog<P></BODY>\r\n"
2197"</HTML>\r\n\r\n";
2198
2199static const char okmsg[] =
2200"HTTP/1.1 200 OK\r\n"
2201"Server: winetest\r\n"
2202"\r\n";
2203
2204static const char okmsg_length0[] =
2205"HTTP/1.1 200 OK\r\n"
2206"Server: winetest\r\n"
2207"Content-length: 0\r\n"
2208"\r\n";
2209
2210static const char notokmsg[] =
2211"HTTP/1.1 400 Bad Request\r\n"
2212"\r\n";
2213
2214static const char cookiemsg[] =
2215"HTTP/1.1 200 OK\r\n"
2216"Set-Cookie: name = value \r\n"
2217"Set-Cookie: NAME = value \r\n"
2218"\r\n";
2219
2220static const char cookiemsg2[] =
2221"HTTP/1.1 200 OK\r\n"
2222"Set-Cookie: name2=value; Domain = localhost; Path=/cookie5;Expires=Wed, 13 Jan 2021 22:23:01 GMT; HttpOnly; \r\n"
2223"\r\n";
2224
2225static const char nocontentmsg[] =
2226"HTTP/1.1 204 No Content\r\n"
2227"Server: winetest\r\n"
2228"\r\n";
2229
2230static const char notmodified[] =
2231"HTTP/1.1 304 Not Modified\r\n"
2232"\r\n";
2233
2234static const char noauthmsg[] =
2235"HTTP/1.1 401 Unauthorized\r\n"
2236"Server: winetest\r\n"
2237"Connection: close\r\n"
2238"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
2239"Content-Length: 12\r\n"
2240"Content-Type: text/plain\r\n"
2241"\r\n";
2242
2243static const char okauthmsg[] =
2244"HTTP/1.1 200 OK\r\n"
2245"Server: winetest\r\n"
2246"Connection: close\r\n"
2247"Content-Length: 11\r\n"
2248"Content-Type: text/plain\r\n"
2249"\r\n";
2250
2251static const char headmsg[] =
2252"HTTP/1.1 200 OK\r\n"
2253"Content-Length: 100\r\n"
2254"\r\n";
2255
2256static const char multiauth[] =
2257"HTTP/1.1 401 Unauthorized\r\n"
2258"Server: winetest\r\n"
2259"WWW-Authenticate: Bearer\r\n"
2260"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
2261"WWW-Authenticate: NTLM\r\n"
2262"Content-Length: 10\r\n"
2263"Content-Type: text/plain\r\n"
2264"\r\n";
2265
2266static const char largeauth[] =
2267"HTTP/1.1 401 Unauthorized\r\n"
2268"Server: winetest\r\n"
2269"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
2270"WWW-Authenticate: NTLM\r\n"
2271"Content-Length: 10240\r\n"
2272"Content-Type: text/plain\r\n"
2273"\r\n";
2274
2275static const char passportauth[] =
2276"HTTP/1.1 302 Found\r\n"
2277"Content-Length: 0\r\n"
2278"Location: /\r\n"
2279"WWW-Authenticate: Passport1.4\r\n"
2280"\r\n";
2281
2282static const char switchprotocols[] =
2283"HTTP/1.1 101 Switching Protocols\r\n"
2284"Server: winetest\r\n"
2285"Upgrade: websocket\r\n"
2286"Connection: Upgrade\r\n";
2287
2288static const char redirectmsg[] =
2289"HTTP/1.1 307 Temporary Redirect\r\n"
2290"Content-Length: 0\r\n"
2291"Location: /temporary\r\n"
2292"Connection: close\r\n\r\n";
2293
2294static const char badreplyheadermsg[] =
2295"HTTP/1.1 200 OK\r\n"
2296"Server: winetest\r\n"
2297"SpaceAfterHdr : bad\r\n"
2298"OkHdr: ok\r\n"
2299"\r\n";
2300
2301static const char proxy_pac[] =
2302"function FindProxyForURL(url, host) {\r\n"
2303" url = url.replace(/[:/]/g, '_');\r\n"
2304" return 'PROXY ' + url + '_' + host + ':8080';\r\n"
2305"}\r\n\r\n";
2306
2307static const char unauthorized[] = "Unauthorized";
2308static const char hello_world[] = "Hello World";
2309static const char auth_unseen[] = "Auth Unseen";
2310
2311struct server_info
2312{
2313 HANDLE event;
2314 int port;
2315};
2316
2317#define BIG_BUFFER_LEN 0x2250
2318
2319static void create_websocket_accept(const char *key, char *buf, unsigned int buflen)
2320{
2321 HCRYPTPROV provider;
2323 BYTE sha1[20];
2324 char data[128];
2325 DWORD len;
2326
2327 strcpy(data, key);
2328 strcat(data, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
2329
2331 CryptCreateHash(provider, CALG_SHA1, 0, 0, &hash);
2333
2334 len = sizeof(sha1);
2337 CryptReleaseContext(provider, 0);
2338
2339 buf[0] = 0;
2340 len = buflen;
2342}
2343
2344static int server_receive_request(int c, char *buffer, size_t buffer_size)
2345{
2346 int i, r;
2347
2349 for(i = 0; i < buffer_size - 1; i++)
2350 {
2351 r = recv(c, &buffer[i], 1, 0);
2352 if (r != 1)
2353 break;
2354 if (i < 4) continue;
2355 if (buffer[i - 2] == '\n' && buffer[i] == '\n' &&
2356 buffer[i - 3] == '\r' && buffer[i - 1] == '\r')
2357 break;
2358 }
2359 return r;
2360}
2361
2363{
2364 struct server_info *si = param;
2365 int r, c = -1, i, on;
2366 SOCKET s;
2367 struct sockaddr_in sa;
2368 char buffer[0x100];
2369 WSADATA wsaData;
2370 int last_request = 0;
2371
2372 WSAStartup(MAKEWORD(1,1), &wsaData);
2373
2374 s = socket(AF_INET, SOCK_STREAM, 0);
2375 if (s == INVALID_SOCKET)
2376 return 1;
2377
2378 on = 1;
2379 setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof on);
2380
2381 memset(&sa, 0, sizeof sa);
2382 sa.sin_family = AF_INET;
2383 sa.sin_port = htons(si->port);
2384 sa.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
2385
2386 r = bind(s, (struct sockaddr *)&sa, sizeof(sa));
2387 if (r < 0)
2388 return 1;
2389
2390 listen(s, 0);
2391 SetEvent(si->event);
2392 do
2393 {
2394 if (c == -1) c = accept(s, NULL, NULL);
2396 if (strstr(buffer, "GET /basic"))
2397 {
2398 send(c, okmsg, sizeof okmsg - 1, 0);
2399 send(c, page1, sizeof page1 - 1, 0);
2400 }
2401 if (strstr(buffer, "/auth_with_creds"))
2402 {
2403 send(c, okauthmsg, sizeof okauthmsg - 1, 0);
2404 if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2405 send(c, hello_world, sizeof hello_world - 1, 0);
2406 else
2407 send(c, auth_unseen, sizeof auth_unseen - 1, 0);
2408 continue;
2409 }
2410 if (strstr(buffer, "/auth"))
2411 {
2412 if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2413 {
2414 send(c, okauthmsg, sizeof okauthmsg - 1, 0);
2415 send(c, hello_world, sizeof hello_world - 1, 0);
2416 }
2417 else
2418 {
2419 send(c, noauthmsg, sizeof noauthmsg - 1, 0);
2420 send(c, unauthorized, sizeof unauthorized - 1, 0);
2421 }
2422 continue;
2423 }
2424 if (strstr(buffer, "/big"))
2425 {
2426 char msg[BIG_BUFFER_LEN];
2427 memset(msg, 'm', sizeof(msg));
2428 send(c, okmsg, sizeof(okmsg) - 1, 0);
2429 send(c, msg, sizeof(msg), 0);
2430 }
2431 if (strstr(buffer, "/no_headers"))
2432 {
2433 send(c, page1, sizeof page1 - 1, 0);
2434 }
2435 if (strstr(buffer, "GET /no_content"))
2436 {
2437 send(c, nocontentmsg, sizeof nocontentmsg - 1, 0);
2438 continue;
2439 }
2440 if (strstr(buffer, "GET /not_modified"))
2441 {
2442 if (strstr(buffer, "If-Modified-Since:")) send(c, notmodified, sizeof notmodified - 1, 0);
2443 else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2444 continue;
2445 }
2446 if (strstr(buffer, "HEAD /head"))
2447 {
2448 send(c, headmsg, sizeof headmsg - 1, 0);
2449 continue;
2450 }
2451 if (strstr(buffer, "GET /multiauth"))
2452 {
2453 send(c, multiauth, sizeof multiauth - 1, 0);
2454 }
2455 if (strstr(buffer, "GET /largeauth"))
2456 {
2457 if (strstr(buffer, "Authorization: NTLM"))
2458 send(c, okmsg, sizeof(okmsg) - 1, 0);
2459 else
2460 {
2461 send(c, largeauth, sizeof largeauth - 1, 0);
2462#ifdef __REACTOS__
2463 memset(buffer, 'A', sizeof(buffer));
2464 for (i = 0; i < (10240 / sizeof(buffer)); i++) send(c, buffer, sizeof(buffer), 0);
2465#else
2466 for (i = 0; i < 10240; i++) send(c, "A", 1, 0);
2467#endif
2468 continue;
2469 }
2470 }
2471 if (strstr(buffer, "GET /cookie5"))
2472 {
2473 if (strstr(buffer, "Cookie: name2=value\r\n"))
2474 send(c, okmsg, sizeof(okmsg) - 1, 0);
2475 else
2476 send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2477 }
2478 if (strstr(buffer, "GET /cookie4"))
2479 {
2480 send(c, cookiemsg2, sizeof(cookiemsg2) - 1, 0);
2481 }
2482 if (strstr(buffer, "GET /cookie3"))
2483 {
2484 if (strstr(buffer, "Cookie: name=value2; NAME=value; name=value\r\n") ||
2485 broken(strstr(buffer, "Cookie: name=value2; name=value; NAME=value\r\n") != NULL))
2486 send(c, okmsg, sizeof(okmsg) - 1, 0);
2487 else
2488 send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2489 }
2490 if (strstr(buffer, "GET /cookie2"))
2491 {
2492 if (strstr(buffer, "Cookie: NAME=value; name=value\r\n") ||
2493 broken(strstr(buffer, "Cookie: name=value; NAME=value\r\n") != NULL))
2494 send(c, okmsg, sizeof(okmsg) - 1, 0);
2495 else
2496 send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2497 }
2498 else if (strstr(buffer, "GET /cookie"))
2499 {
2500 if (!strstr(buffer, "Cookie: name=value\r\n")) send(c, cookiemsg, sizeof(cookiemsg) - 1, 0);
2501 else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2502 }
2503 else if (strstr(buffer, "GET /escape"))
2504 {
2505 static const char res[] = "%0D%0A%1F%7F%3C%20%one?%1F%7F%20!%22%23$%&'()*+,-./:;%3C=%3E?@%5B%5C%5D"
2506 "%5E_%60%7B%7C%7D~%0D%0A ";
2507 static const char res2[] = "%0D%0A%1F%7F%3C%20%25two?%1F%7F%20!%22%23$%25&'()*+,-./:;%3C=%3E?@%5B%5C%5D"
2508 "%5E_%60%7B%7C%7D~%0D%0A ";
2509 static const char res3[] = "\x1f\x7f<%20%three?\x1f\x7f%20!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
2510 static const char res4[] = "%0D%0A%1F%7F%3C%20%four?\x1f\x7f%20!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
2511 static const char res5[] = "&text=one%C2%80%7F~";
2512 static const char res6[] = "&text=two%C2%80\x7f~";
2513 static const char res7[] = "&text=%E5%90%9B%E3%81%AE%E5%90%8D%E3%81%AF";
2514
2515 if (strstr(buffer + 11, res) || strstr(buffer + 11, res2) || strstr(buffer + 11, res3) ||
2516 strstr(buffer + 11, res4) || strstr(buffer + 11, res5) || strstr(buffer + 11, res6) ||
2517 strstr(buffer + 11, res7))
2518 {
2519 send(c, okmsg, sizeof(okmsg) - 1, 0);
2520 }
2521 else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2522 }
2523 else if (strstr(buffer, "GET /passport"))
2524 {
2525 send(c, passportauth, sizeof(passportauth) - 1, 0);
2526 }
2527 else if (strstr(buffer, "GET /websocket"))
2528 {
2529 char headers[256], key[32], accept[64];
2530 const char *pos = strstr(buffer, "Sec-WebSocket-Key: ");
2531 if (pos && strstr(buffer, "Connection: Upgrade\r\n") &&
2532 (strstr(buffer, "Upgrade: websocket\r\n") || strstr(buffer, "Upgrade: Websocket\r\n")) &&
2533 strstr(buffer, "Host: ") && strstr(buffer, "Sec-WebSocket-Version: 13\r\n"))
2534 {
2536 memcpy(key, pos + 19, 24);
2537 key[24] = 0;
2538
2540
2541 strcat(headers, "Sec-WebSocket-Accept: ");
2543 strcat(headers, "\r\n\r\n");
2544
2545 send(c, headers, strlen(headers), 0);
2546 continue;
2547 }
2548 else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2549 }
2550 else if (strstr(buffer, "POST /redirect"))
2551 {
2552 send(c, redirectmsg, sizeof redirectmsg - 1, 0);
2553 }
2554 else if (strstr(buffer, "POST /temporary"))
2555 {
2556 char buf[32];
2557 recv(c, buf, sizeof(buf), 0);
2558 send(c, okmsg, sizeof okmsg - 1, 0);
2559 send(c, page1, sizeof page1 - 1, 0);
2560 }
2561 if (strstr(buffer, "GET /quit"))
2562 {
2563 send(c, okmsg, sizeof okmsg - 1, 0);
2564 send(c, page1, sizeof page1 - 1, 0);
2565 last_request = 1;
2566 }
2567 if (strstr(buffer, "POST /bad_headers"))
2568 {
2569 ok(!!strstr(buffer, "Content-Type: text/html\r\n"), "Header missing from request %s.\n", debugstr_a(buffer));
2570 ok(!!strstr(buffer, "Test1: Value1\r\n"), "Header missing from request %s.\n", debugstr_a(buffer));
2571 ok(!!strstr(buffer, "Test2: Value2\r\n"), "Header missing from request %s.\n", debugstr_a(buffer));
2572 ok(!!strstr(buffer, "Test3: Value3\r\n"), "Header missing from request %s.\n", debugstr_a(buffer));
2573 ok(!!strstr(buffer, "Test4: Value4\r\n"), "Header missing from request %s.\n", debugstr_a(buffer));
2574 ok(!!strstr(buffer, "Test5: Value5\r\n"), "Header missing from request %s.\n", debugstr_a(buffer));
2575 ok(!!strstr(buffer, "Test6: Value6\r\n"), "Header missing from request %s.\n", debugstr_a(buffer));
2576 ok(!!strstr(buffer, "Cookie: 111\r\n"), "Header missing from request %s.\n", debugstr_a(buffer));
2577 send(c, badreplyheadermsg, sizeof(badreplyheadermsg) - 1, 0);
2578 }
2579 if (strstr(buffer, "GET /proxy.pac"))
2580 {
2581 send(c, okmsg, sizeof(okmsg) - 1, 0);
2582 send(c, proxy_pac, sizeof(proxy_pac) - 1, 0);
2583 }
2584
2585 if (strstr(buffer, "PUT /test") || strstr(buffer, "POST /test"))
2586 {
2587 if (strstr(buffer, "Transfer-Encoding: chunked\r\n"))
2588 {
2589 ok(!strstr(buffer, "Content-Length:"), "Unexpected Content-Length in request %s.\n", debugstr_a(buffer));
2590 r = recv(c, buffer, sizeof(buffer), 0);
2591 ok(r == 4, "got %d.\n", r);
2592 buffer[r] = 0;
2593 ok(!strcmp(buffer, "post"), "got %s.\n", debugstr_a(buffer));
2594 }
2595 else
2596 {
2597 ok(!!strstr(buffer, "Content-Length: 0\r\n"), "Header missing from request %s.\n", debugstr_a(buffer));
2598 }
2599 send(c, okmsg, sizeof(okmsg) - 1, 0);
2600 }
2601
2602 if (strstr(buffer, "GET /cached"))
2603 {
2604 send(c, okmsg_length0, sizeof okmsg_length0 - 1, 0);
2605 r = server_receive_request(c, buffer, sizeof(buffer));
2606 ok(r > 0, "got %d.\n", r);
2607 ok(!!strstr(buffer, "GET /cached"), "request not found.\n");
2608 send(c, okmsg_length0, sizeof okmsg_length0 - 1, 0);
2609 r = server_receive_request(c, buffer, sizeof(buffer));
2610 ok(!r, "got %d, buffer[0] %d.\n", r, buffer[0]);
2611 }
2612 if (strstr(buffer, "GET /notcached"))
2613 {
2614 send(c, okmsg, sizeof okmsg - 1, 0);
2615 r = server_receive_request(c, buffer, sizeof(buffer));
2616 ok(!r, "got %d, buffer[0] %d.\n", r, buffer[0] );
2617 }
2618 shutdown(c, 2);
2619 closesocket(c);
2620 c = -1;
2621
2622 } while (!last_request);
2623
2624 closesocket(s);
2625 return 0;
2626}
2627
2628static void test_basic_request(int port, const WCHAR *verb, const WCHAR *path)
2629{
2630 HINTERNET ses, con, req;
2631 char buffer[0x100];
2632 WCHAR buffer2[0x100];
2633 DWORD count, status, size, error, supported, first, target;
2634 BOOL ret;
2635
2636 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
2637 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
2638
2639 SetLastError(0xdeadbeef);
2640 ret = WinHttpSetOption(ses, 0, buffer, sizeof(buffer));
2642
2643 SetLastError(0xdeadbeef);
2644 ret = WinHttpQueryOption(ses, 0, buffer, &size);
2645 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %lu\n", GetLastError());
2646
2647 con = WinHttpConnect(ses, L"localhost", port, 0);
2648 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
2649
2650 SetLastError(0xdeadbeef);
2651 ret = WinHttpSetOption(con, 0, buffer, sizeof(buffer));
2653
2654 SetLastError(0xdeadbeef);
2655 ret = WinHttpQueryOption(con, 0, buffer, &size);
2656 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %lu\n", GetLastError());
2657
2658 req = WinHttpOpenRequest(con, verb, path, NULL, NULL, NULL, 0);
2659 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
2660
2661 SetLastError(0xdeadbeef);
2662 ret = WinHttpSetOption(req, 0, buffer, sizeof(buffer));
2664
2665 SetLastError(0xdeadbeef);
2666 ret = WinHttpQueryOption(req, 0, buffer, &size);
2667 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %lu\n", GetLastError());
2668
2669 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2670 ok(ret, "failed to send request %lu\n", GetLastError());
2671
2673 ok(ret, "failed to receive response %lu\n", GetLastError());
2674
2675 status = 0xdeadbeef;
2676 size = sizeof(status);
2678 ok(ret, "failed to query status code %lu\n", GetLastError());
2679 ok(status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status);
2680
2681 supported = first = target = 0xdeadbeef;
2682 SetLastError(0xdeadbeef);
2683 ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
2684 error = GetLastError();
2685 ok(!ret, "unexpected success\n");
2686 ok(error == ERROR_INVALID_OPERATION, "expected ERROR_INVALID_OPERATION, got %lu\n", error);
2687 ok(supported == 0xdeadbeef, "got %lu\n", supported);
2688 ok(first == 0xdeadbeef, "got %lu\n", first);
2689 ok(target == 0xdeadbeef, "got %lu\n", target);
2690
2691 size = sizeof(buffer2);
2692 memset(buffer2, 0, sizeof(buffer2));
2694 ok(ret, "failed to query for raw headers: %lu\n", GetLastError());
2695 ok(!memcmp(buffer2 + lstrlenW(buffer2) - 4, L"\r\n\r\n", sizeof(L"\r\n\r\n")),
2696 "WinHttpQueryHeaders returned invalid end of header string\n");
2697
2698 size = sizeof(buffer2);
2699 memset(buffer2, 0, sizeof(buffer2));
2701 ok(ret, "failed to query for raw headers: %lu\n", GetLastError());
2702 ok(!memcmp(buffer2 + (size / sizeof(WCHAR)) - 1, L"", sizeof(L"")),
2703 "WinHttpQueryHeaders returned invalid end of header string\n");
2704 ok(buffer2[(size / sizeof(WCHAR)) - 2] != 0, "returned string has too many NULL characters\n");
2705
2706 count = 0;
2707 memset(buffer, 0, sizeof(buffer));
2708 ret = WinHttpReadData(req, buffer, sizeof buffer, &count);
2709 ok(ret, "failed to read data %lu\n", GetLastError());
2710 if (verb && !wcscmp(verb, L"PUT"))
2711 {
2712 ok(!count, "got count %ld\n", count);
2713 }
2714 else
2715 {
2716 ok(count == sizeof page1 - 1, "got count %ld\n", count);
2717 ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
2718 }
2719
2720 WinHttpCloseHandle(req);
2721 WinHttpCloseHandle(con);
2722 WinHttpCloseHandle(ses);
2723}
2724
2726{
2727 static const WCHAR *methods[] = {L"POST", L"PUT"};
2728 HINTERNET ses, con, req;
2729 char buffer[0x100];
2730 unsigned int i;
2731 DWORD count;
2732 BOOL ret;
2733
2734 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
2735 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
2736
2737 con = WinHttpConnect(ses, L"localhost", port, 0);
2738 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
2739 for (i = 0; i < ARRAY_SIZE(methods); ++i)
2740 {
2741 req = WinHttpOpenRequest(con, methods[i], L"/test", NULL, NULL, NULL, 0);
2742 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
2743
2744 ret = WinHttpAddRequestHeaders(req, L"Transfer-Encoding: chunked", -1, WINHTTP_ADDREQ_FLAG_ADD);
2745 ok(ret, "failed to add header %lu\n", GetLastError());
2746
2747 strcpy(buffer, "post");
2748 ret = WinHttpSendRequest(req, NULL, 0, buffer, 4, 4, 0);
2749 ok(ret, "failed to send request %lu\n", GetLastError());
2751 ok(ret, "failed to receive response %lu\n", GetLastError());
2752 count = 0;
2753 memset(buffer, 0, sizeof(buffer));
2754 ret = WinHttpReadData(req, buffer, sizeof buffer, &count);
2755 ok(ret, "failed to read data %lu\n", GetLastError());
2756 ok(!count, "got count %ld\n", count);
2757 WinHttpCloseHandle(req);
2758 }
2759 WinHttpCloseHandle(con);
2760 WinHttpCloseHandle(ses);
2761}
2762
2764{
2765 HINTERNET ses, con, req;
2766 DWORD status, size, error, supported, first, target;
2767 char buffer[32];
2768 BOOL ret;
2769
2770 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
2771 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
2772
2773 con = WinHttpConnect(ses, L"localhost", port, 0);
2774 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
2775
2776 req = WinHttpOpenRequest(con, NULL, L"/auth", NULL, NULL, NULL, 0);
2777 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
2778
2779 SetLastError(0xdeadbeef);
2781 error = GetLastError();
2782 ok(!ret, "expected failure\n");
2783 ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %lu\n", error);
2784
2785 SetLastError(0xdeadbeef);
2787 error = GetLastError();
2788 ok(!ret, "expected failure\n");
2790
2791 supported = 0xdeadbeef;
2792 SetLastError(0xdeadbeef);
2793 ret = WinHttpQueryAuthSchemes(req, &supported, NULL, NULL);
2794 error = GetLastError();
2795 ok(!ret, "expected failure\n");
2797 ok(supported == 0xdeadbeef, "got %lu\n", supported);
2798
2799 supported = first = 0xdeadbeef;
2800 SetLastError(0xdeadbeef);
2801 ret = WinHttpQueryAuthSchemes(req, &supported, &first, NULL);
2802 error = GetLastError();
2803 ok(!ret, "expected failure\n");
2805 ok(supported == 0xdeadbeef, "got %lu\n", supported);
2806 ok(first == 0xdeadbeef, "got %lu\n", first);
2807
2808 supported = first = target = 0xdeadbeef;
2809 SetLastError(0xdeadbeef);
2810 ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
2811 error = GetLastError();
2812 ok(!ret, "expected failure\n");
2813 ok(error == ERROR_INVALID_OPERATION, "expected ERROR_INVALID_OPERATION, got %lu\n", error);
2814 ok(supported == 0xdeadbeef, "got %lu\n", supported);
2815 ok(first == 0xdeadbeef, "got %lu\n", first);
2816 ok(target == 0xdeadbeef, "got %lu\n", target);
2817
2818 supported = first = target = 0xdeadbeef;
2819 SetLastError(0xdeadbeef);
2820 ret = WinHttpQueryAuthSchemes(NULL, &supported, &first, &target);
2821 error = GetLastError();
2822 ok(!ret, "expected failure\n");
2823 ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %lu\n", error);
2824 ok(supported == 0xdeadbeef, "got %lu\n", supported);
2825 ok(first == 0xdeadbeef, "got %lu\n", first);
2826 ok(target == 0xdeadbeef, "got %lu\n", target);
2827
2828 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2829 ok(ret, "failed to send request %lu\n", GetLastError());
2830
2832 ok(ret, "failed to receive response %lu\n", GetLastError());
2833
2834 status = 0xdeadbeef;
2835 size = sizeof(status);
2837 ok(ret, "failed to query status code %lu\n", GetLastError());
2838 ok(status == HTTP_STATUS_DENIED, "request failed unexpectedly %lu\n", status);
2839
2840 size = 0;
2841 ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
2842 error = GetLastError();
2843 ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %lu\n", GetLastError());
2844 if (ret)
2845 {
2846 ok(size == 12, "expected 12, got %lu\n", size);
2847 ok(!memcmp(buffer, unauthorized, 12), "got %s\n", buffer);
2848 }
2849
2850 supported = first = target = 0xdeadbeef;
2851 SetLastError(0xdeadbeef);
2852 ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
2853 error = GetLastError();
2854 ok(ret, "failed to query authentication schemes %lu\n", error);
2855 ok(error == ERROR_SUCCESS || broken(error == 0xdeadbeef) /* < win7 */, "expected ERROR_SUCCESS, got %lu\n", error);
2856 ok(supported == WINHTTP_AUTH_SCHEME_BASIC, "got %lu\n", supported);
2857 ok(first == WINHTTP_AUTH_SCHEME_BASIC, "got %lu\n", first);
2858 ok(target == WINHTTP_AUTH_TARGET_SERVER, "got %lu\n", target);
2859
2860 SetLastError(0xdeadbeef);
2862 error = GetLastError();
2863 ok(ret, "failed to set credentials %lu\n", error);
2864 ok(error == ERROR_SUCCESS || broken(error == 0xdeadbeef) /* < win7 */, "expected ERROR_SUCCESS, got %lu\n", error);
2865
2867 ok(ret, "failed to set credentials %lu\n", GetLastError());
2868
2870 ok(ret, "failed to set credentials %lu\n", GetLastError());
2871
2872 SetLastError(0xdeadbeef);
2874 error = GetLastError();
2875 ok(!ret, "expected failure\n");
2876 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
2877
2878 SetLastError(0xdeadbeef);
2880 error = GetLastError();
2881 ok(!ret, "expected failure\n");
2882 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
2883
2884 SetLastError(0xdeadbeef);
2886 error = GetLastError();
2887 ok(!ret, "expected failure\n");
2888 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
2889
2890 SetLastError(0xdeadbeef);
2892 error = GetLastError();
2893 ok(!ret, "expected failure\n");
2894 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
2895
2897 ok(ret, "failed to set credentials %lu\n", GetLastError());
2898
2899 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2900 ok(ret, "failed to send request %lu\n", GetLastError());
2901
2903 ok(ret, "failed to receive response %lu\n", GetLastError());
2904
2905 status = 0xdeadbeef;
2906 size = sizeof(status);
2908 ok(ret, "failed to query status code %lu\n", GetLastError());
2909 ok(status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status);
2910
2911 size = 0;
2912 ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
2913 error = GetLastError();
2914 ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %lu\n", GetLastError());
2915 if (ret)
2916 {
2917 ok(size == 11, "expected 11, got %lu\n", size);
2918 ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer);
2919 }
2920
2921 WinHttpCloseHandle(req);
2922 WinHttpCloseHandle(con);
2923 WinHttpCloseHandle(ses);
2924
2925 /* now set the credentials first to show that they get sent with the first request */
2926 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
2927 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
2928
2929 con = WinHttpConnect(ses, L"localhost", port, 0);
2930 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
2931
2932 req = WinHttpOpenRequest(con, NULL, L"/auth_with_creds", NULL, NULL, NULL, 0);
2933 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
2934
2936 ok(ret, "failed to set credentials %lu\n", GetLastError());
2937
2938 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2939 ok(ret, "failed to send request %lu\n", GetLastError());
2940
2942 ok(ret, "failed to receive response %lu\n", GetLastError());
2943
2944 status = 0xdeadbeef;
2945 size = sizeof(status);
2947 ok(ret, "failed to query status code %lu\n", GetLastError());
2948 ok(status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status);
2949
2950 size = 0;
2951 ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
2952 error = GetLastError();
2953 ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %lu\n", GetLastError());
2954 if (ret)
2955 {
2956 ok(size == 11, "expected 11, got %lu\n", size);
2957 ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer);
2958 }
2959
2960 WinHttpCloseHandle(req);
2961 WinHttpCloseHandle(con);
2962 WinHttpCloseHandle(ses);
2963
2964 /* credentials set with WinHttpSetCredentials take precedence over those set through options */
2965
2966 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
2967 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
2968
2969 con = WinHttpConnect(ses, L"localhost", port, 0);
2970 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
2971
2972 req = WinHttpOpenRequest(con, NULL, L"/auth", NULL, NULL, NULL, 0);
2973 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
2974
2976 ok(ret, "failed to set credentials %lu\n", GetLastError());
2977
2978 ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, (void *)L"user", lstrlenW(L"user"));
2979 ok(ret, "failed to set username %lu\n", GetLastError());
2980
2981 ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, (void *)L"pwd2", lstrlenW(L"pwd2"));
2982 ok(ret, "failed to set password %lu\n", GetLastError());
2983
2984 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2985 ok(ret, "failed to send request %lu\n", GetLastError());
2986
2988 ok(ret, "failed to receive response %lu\n", GetLastError());
2989
2990 status = 0xdeadbeef;
2991 size = sizeof(status);
2993 ok(ret, "failed to query status code %lu\n", GetLastError());
2994 ok(status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status);
2995
2996 WinHttpCloseHandle(req);
2997 WinHttpCloseHandle(con);
2998 WinHttpCloseHandle(ses);
2999
3000 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
3001 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
3002
3003 con = WinHttpConnect(ses, L"localhost", port, 0);
3004 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
3005
3006 req = WinHttpOpenRequest(con, NULL, L"/auth", NULL, NULL, NULL, 0);
3007 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
3008
3009 ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, (void *)L"user", lstrlenW(L"user"));
3010 ok(ret, "failed to set username %lu\n", GetLastError());
3011
3012 ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, (void *)L"pwd", lstrlenW(L"pwd"));
3013 ok(ret, "failed to set password %lu\n", GetLastError());
3014
3016 ok(ret, "failed to set credentials %lu\n", GetLastError());
3017
3018 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
3019 ok(ret, "failed to send request %lu\n", GetLastError());
3020
3022 ok(ret, "failed to receive response %lu\n", GetLastError());
3023
3024 status = 0xdeadbeef;
3025 size = sizeof(status);
3027 ok(ret, "failed to query status code %lu\n", GetLastError());
3028 ok(status == HTTP_STATUS_DENIED, "request failed unexpectedly %lu\n", status);
3029
3030 WinHttpCloseHandle(req);
3031 WinHttpCloseHandle(con);
3032 WinHttpCloseHandle(ses);
3033}
3034
3036{
3037 HINTERNET ses, con, req;
3038 DWORD supported, first, target, size, index;
3039 WCHAR buf[512];
3040 BOOL ret;
3041
3042 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
3043 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
3044
3045 con = WinHttpConnect(ses, L"localhost", port, 0);
3046 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
3047
3048 req = WinHttpOpenRequest(con, L"GET", L"/multiauth", NULL, NULL, NULL, 0);
3049 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
3050
3052 WINHTTP_NO_REQUEST_DATA,0, 0, 0 );
3053 ok(ret, "expected success\n");
3054
3056 ok(ret, "expected success\n");
3057
3058 supported = first = target = 0xdeadbeef;
3059 ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
3060 ok(ret, "expected success\n");
3061 ok(supported == (WINHTTP_AUTH_SCHEME_BASIC | WINHTTP_AUTH_SCHEME_NTLM), "got %#lx\n", supported);
3062 ok(target == WINHTTP_AUTH_TARGET_SERVER, "got %#lx\n", target);
3063 ok(first == WINHTTP_AUTH_SCHEME_BASIC, "got %#lx\n", first);
3064
3065 index = 0;
3066 size = sizeof(buf);
3067 ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_CUSTOM, L"WWW-Authenticate", buf, &size, &index);
3068 ok(ret, "expected success\n");
3069 ok(!lstrcmpW(buf, L"Bearer"), "buf = %s\n", wine_dbgstr_w(buf));
3070 ok(size == lstrlenW(buf) * sizeof(WCHAR), "size = %lu\n", size);
3071 ok(index == 1, "index = %lu\n", index);
3072
3073 index = 0;
3074 size = 0xdeadbeef;
3075 ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_CUSTOM, L"WWW-Authenticate", NULL, &size, &index);
3077 "WinHttpQueryHeaders returned %d(%lu)\n", ret, GetLastError());
3078 ok(size == (lstrlenW(buf) + 1) * sizeof(WCHAR), "size = %lu\n", size);
3079 ok(index == 0, "index = %lu\n", index);
3080
3081 WinHttpCloseHandle(req);
3082 WinHttpCloseHandle(con);
3083 WinHttpCloseHandle(ses);
3084}
3085
3087{
3088 HINTERNET ses, con, req;
3089 DWORD status, size;
3090 BOOL ret;
3091
3092 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
3093 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
3094
3095 con = WinHttpConnect(ses, L"localhost", port, 0);
3096 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
3097
3098 req = WinHttpOpenRequest(con, L"GET", L"/largeauth", NULL, NULL, NULL, 0);
3099 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
3100
3102 ok(ret, "expected success\n");
3103
3105 ok(ret, "expected success\n");
3106
3107 size = sizeof(status);
3109 &status, &size, NULL);
3110 ok(ret, "expected success\n");
3111 ok(status == HTTP_STATUS_DENIED, "got %lu\n", status);
3112
3114 ok(ret, "expected success\n");
3115
3117 ok(ret, "expected success %lu\n", GetLastError());
3118
3120 ok(ret, "expected success\n");
3121
3122 size = sizeof(status);
3124 &status, &size, NULL);
3125 ok(ret, "expected success\n");
3126 ok(status == HTTP_STATUS_OK, "got %lu\n", status);
3127
3128 WinHttpCloseHandle(req);
3129 WinHttpCloseHandle(con);
3130 WinHttpCloseHandle(ses);
3131}
3132
3133static void test_no_headers(int port)
3134{
3135 HINTERNET ses, con, req;
3136 DWORD error;
3137 BOOL ret;
3138
3139 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
3140 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
3141
3142 con = WinHttpConnect(ses, L"localhost", port, 0);
3143 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
3144
3145 req = WinHttpOpenRequest(con, NULL, L"/no_headers", NULL, NULL, NULL, 0);
3146 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
3147
3148 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
3149 if (!ret)
3150 {
3151 error = GetLastError();
3153 }
3154 else
3155 {
3156 SetLastError(0xdeadbeef);
3158 error = GetLastError();
3159 ok(!ret, "expected failure\n");
3161 }
3162
3163 WinHttpCloseHandle(req);
3164 WinHttpCloseHandle(con);
3165 WinHttpCloseHandle(ses);
3166}
3167
3168static void test_no_content(int port)
3169{
3170 HINTERNET ses, con, req;
3171 char buf[128];
3172 DWORD size, len = sizeof(buf), bytes_read, status;
3173 BOOL ret;
3174
3175 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
3176 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
3177
3178 con = WinHttpConnect(ses, L"localhost", port, 0);
3179 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
3180
3181 req = WinHttpOpenRequest(con, NULL, L"/no_content", NULL, NULL, NULL, 0);
3182 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
3183
3184 size = 12345;
3185 SetLastError(0xdeadbeef);
3187 todo_wine {
3188 ok(!ret, "expected error\n");
3190 "expected ERROR_WINHTTP_INCORRECT_HANDLE_STATE, got %lu\n", GetLastError());
3191 ok(size == 12345 || broken(size == 0) /* Win <= 2003 */,
3192 "expected 12345, got %lu\n", size);
3193 }
3194
3195 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
3196 ok(ret, "expected success\n");
3197
3199 ok(ret, "expected success\n");
3200
3201 status = 0xdeadbeef;
3202 size = sizeof(status);
3204 NULL, &status, &size, NULL);
3205 ok(ret, "expected success\n");
3206 ok(status == HTTP_STATUS_NO_CONTENT, "expected status 204, got %lu\n", status);
3207
3208 SetLastError(0xdeadbeef);
3209 size = sizeof(status);
3210 status = 12345;
3212 NULL, &status, &size, 0);
3213 ok(!ret, "expected no content-length header\n");
3214 ok(GetLastError() == ERROR_WINHTTP_HEADER_NOT_FOUND, "wrong error %lu\n", GetLastError());
3215 ok(status == 12345, "expected 0, got %lu\n", status);
3216
3217 SetLastError(0xdeadbeef);
3218 size = 12345;
3220 ok(ret, "expected success\n");
3221 ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
3222 "wrong error %lu\n", GetLastError());
3223 ok(!size, "expected 0, got %lu\n", size);
3224
3225 SetLastError(0xdeadbeef);
3226 ret = WinHttpReadData(req, buf, len, &bytes_read);
3227 ok(ret, "expected success\n");
3228 ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
3229 "wrong error %lu\n", GetLastError());
3230 ok(!bytes_read, "expected 0, got %lu\n", bytes_read);
3231
3232 size = 12345;
3234 ok(ret, "expected success\n");
3235 ok(size == 0, "expected 0, got %lu\n", size);
3236
3237 WinHttpCloseHandle(req);
3238
3239 size = 12345;
3240 SetLastError(0xdeadbeef);
3242 ok(!ret, "expected error\n");
3243 ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %#lx\n", GetLastError());
3244 ok(size == 12345, "expected 12345, got %lu\n", size);
3245
3246 WinHttpCloseHandle(con);
3247 WinHttpCloseHandle(ses);
3248}
3249
3250static void test_head_request(int port)
3251{
3252 HINTERNET ses, con, req;
3253 char buf[128];
3255 BOOL ret;
3256
3257 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
3258 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
3259
3260 con = WinHttpConnect(ses, L"localhost", port, 0);
3261 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
3262
3263 req = WinHttpOpenRequest(con, L"HEAD", L"/head", NULL, NULL, NULL, 0);
3264 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
3265
3266 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
3267 ok(ret, "failed to send request %lu\n", GetLastError());
3268
3270 ok(ret, "failed to receive response %lu\n", GetLastError());
3271
3272 status = 0xdeadbeef;
3273 size = sizeof(status);
3275 NULL, &status, &size, NULL);
3276 ok(ret, "failed to get status code %lu\n", GetLastError());
3277 ok(status == HTTP_STATUS_OK, "got %lu\n", status);
3278
3279 len = 0xdeadbeef;
3280 size = sizeof(len);
3282 NULL, &len, &size, 0);
3283 ok(ret, "failed to get content-length header %lu\n", GetLastError());
3284 ok(len == HTTP_STATUS_CONTINUE, "got %lu\n", len);
3285
3286 count = 0xdeadbeef;
3288 ok(ret, "failed to query data available %lu\n", GetLastError());
3289 ok(!count, "got %lu\n", count);
3290
3291 len = sizeof(buf);
3292 count = 0xdeadbeef;
3293 ret = WinHttpReadData(req, buf, len, &count);
3294 ok(ret, "failed to read data %lu\n", GetLastError());
3295 ok(!count, "got %lu\n", count);
3296
3297 count = 0xdeadbeef;
3299 ok(ret, "failed to query data available %lu\n", GetLastError());
3300 ok(!count, "got %lu\n", count);
3301
3302 WinHttpCloseHandle(req);
3303 WinHttpCloseHandle(con);
3304 WinHttpCloseHandle(ses);
3305}
3306
3307static void test_redirect(int port)
3308{
3309 HINTERNET ses, con, req;
3310 char buf[128];
3312 WCHAR url[128], expected[128];
3313 BOOL ret;
3314
3315 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
3316 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
3317
3318 con = WinHttpConnect(ses, L"localhost", port, 0);
3319 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
3320
3321 req = WinHttpOpenRequest(con, L"POST", L"/redirect", NULL, NULL, NULL, 0);
3322 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
3323
3324 url[0] = 0;
3325 size = sizeof(url);
3327 ok(ret, "got %lu\n", GetLastError());
3328 swprintf(expected, ARRAY_SIZE(expected), L"http://localhost:%u/redirect", port);
3329 ok(!wcscmp(url, expected), "expected %s got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(url));
3330
3331 ret = WinHttpSendRequest(req, NULL, 0, (void *)"data", sizeof("data"), sizeof("data"), 0);
3332 ok(ret, "failed to send request %lu\n", GetLastError());
3333
3334 url[0] = 0;
3335 size = sizeof(url);
3337 ok(ret, "got %lu\n", GetLastError());
3338 ok(!wcscmp(url, expected), "expected %s got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(url));
3339
3340 /* Exact buffer size match. */
3341 url[0] = 0;
3342 size = (lstrlenW(expected) + 1) * sizeof(WCHAR);
3344 ok(ret, "got %lu\n", GetLastError());
3345 ok(!wcscmp(url, expected), "expected %s got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(url));
3346
3348 ok(ret, "failed to receive response %lu\n", GetLastError());
3349
3350 url[0] = 0;
3351 size = sizeof(url);
3353 ok(ret, "got %lu\n", GetLastError());
3354 swprintf(expected, ARRAY_SIZE(expected), L"http://localhost:%u/temporary", port);
3355 ok(!wcscmp(url, expected), "expected %s got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(url));
3356
3357 status = 0xdeadbeef;
3358 size = sizeof(status);
3360 NULL, &status, &size, NULL);
3361 ok(ret, "failed to get status code %lu\n", GetLastError());
3362 ok(status == HTTP_STATUS_OK, "got %lu\n", status);
3363
3364 count = 0;
3366 ok(ret, "failed to query data available %lu\n", GetLastError());
3367 ok(count == 128, "got %lu\n", count);
3368
3369 len = sizeof(buf);
3370 count = 0;
3371 ret = WinHttpReadData(req, buf, len, &count);
3372 ok(ret, "failed to read data %lu\n", GetLastError());
3373 ok(count == 128, "got %lu\n", count);
3374
3375 WinHttpCloseHandle(req);
3376 WinHttpCloseHandle(con);
3377 WinHttpCloseHandle(ses);
3378}
3379
3380static void test_websocket(int port)
3381{
3382 HINTERNET session, connection, request, socket, socket2;
3384 DWORD_PTR ctx;
3386 BOOL broken_buffer_sizes = FALSE;
3387 WCHAR header[32];
3388 char buf[128], *large_buf;
3389 USHORT close_status;
3390 BOOL ret;
3391
3392 if (!pWinHttpWebSocketCompleteUpgrade)
3393 {
3394 win_skip("WinHttpWebSocketCompleteUpgrade not supported\n");
3395 return;
3396 }
3397
3398 session = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
3399 ok(session != NULL, "got %lu\n", GetLastError());
3400
3401 connection = WinHttpConnect(session, L"localhost", port, 0);
3402 ok(connection != NULL, "got %lu\n", GetLastError());
3403
3404 request = WinHttpOpenRequest(connection, L"GET", L"/websocket", NULL, NULL, NULL, 0);
3405 ok(request != NULL, "got %lu\n", GetLastError());
3406
3408 ok(ret, "got %lu\n", GetLastError());
3409
3410 size = sizeof(header);
3411 SetLastError(0xdeadbeef);
3413 error = GetLastError();
3414 ok(!ret, "success\n");
3416
3417 size = sizeof(header);
3418 SetLastError(0xdeadbeef);
3420 error = GetLastError();
3421 ok(!ret, "success\n");
3423
3424 index = 0;
3425 size = sizeof(buf);
3426 SetLastError(0xdeadbeef);
3428 L"Sec-WebSocket-Key", buf, &size, &index);
3429 error = GetLastError();
3430 ok(!ret, "success\n");
3431 ok(error == ERROR_WINHTTP_HEADER_NOT_FOUND, "got %lu\n", error);
3432
3433 index = 0;
3434 size = sizeof(buf);
3435 SetLastError(0xdeadbeef);
3437 L"Sec-WebSocket-Version", buf, &size, &index);
3438 error = GetLastError();
3439 ok(!ret, "success\n");
3440 ok(error == ERROR_WINHTTP_HEADER_NOT_FOUND, "got %lu\n", error);
3441
3442 ret = WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, 0);
3443 ok(ret, "got %lu\n", GetLastError());
3444
3445 size = sizeof(header);
3446 SetLastError(0xdeadbeef);
3448 error = GetLastError();
3449 ok(!ret, "success\n");
3451
3452 size = sizeof(header);
3453 SetLastError(0xdeadbeef);
3455 error = GetLastError();
3456 ok(!ret, "success\n");
3458
3459 index = 0;
3460 buf[0] = 0;
3461 size = sizeof(buf);
3463 L"Sec-WebSocket-Key", buf, &size, &index);
3464 ok(ret, "got %lu\n", GetLastError());
3465
3466 index = 0;
3467 buf[0] = 0;
3468 size = sizeof(buf);
3470 L"Sec-WebSocket-Version", buf, &size, &index);
3471 ok(ret, "got %lu\n", GetLastError());
3472
3474 ok(ret, "got %lu\n", GetLastError());
3475
3476 count = 0xdeadbeef;
3478 ok(ret, "got %lu\n", GetLastError());
3479 ok(!count, "got %lu\n", count);
3480
3481 header[0] = 0;
3482 size = sizeof(header);
3484 ok(ret, "got %lu\n", GetLastError());
3485 ok(!wcscmp( header, L"websocket" ), "got %s\n", wine_dbgstr_w(header));
3486
3487 header[0] = 0;
3488 size = sizeof(header);
3490 ok(ret, "got %lu\n", GetLastError());
3491 ok(!wcscmp( header, L"Upgrade" ), "got %s\n", wine_dbgstr_w(header));
3492
3493 status = 0xdeadbeef;
3494 size = sizeof(status);
3496 &size, NULL);
3497 ok(ret, "got %lu\n", GetLastError());
3498 ok(status == HTTP_STATUS_SWITCH_PROTOCOLS, "got %lu\n", status);
3499
3500 len = 0xdeadbeef;
3501 size = sizeof(len);
3503 &size, NULL);
3504 ok(!ret, "success\n");
3505
3506 index = 0;
3507 size = sizeof(buf);
3508 ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM, L"Sec-WebSocket-Accept", buf, &size, &index);
3509 ok(ret, "got %lu\n", GetLastError());
3510
3511 socket = pWinHttpWebSocketCompleteUpgrade(request, 0);
3512 ok(socket != NULL, "got %lu\n", GetLastError());
3513
3514 size = sizeof(header);
3516 error = GetLastError();
3517 ok(!ret, "success\n");
3519
3520 header[0] = 0;
3521 size = sizeof(header);
3523 ok(ret, "got %lu\n", GetLastError());
3524 ok(!wcscmp( header, L"websocket" ), "got %s\n", wine_dbgstr_w(header));
3525
3526 header[0] = 0;
3527 size = sizeof(header);
3529 ok(ret, "got %lu\n", GetLastError());
3530 ok(!wcscmp( header, L"Upgrade" ), "got %s\n", wine_dbgstr_w(header));
3531
3532 index = 0;
3533 size = sizeof(buf);
3534 ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM, L"Sec-WebSocket-Accept", buf, &size, &index);
3535 ok(ret, "got %lu\n", GetLastError());
3536
3537 /* sending request again generates new key */
3538 ret = WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, 0);
3539 ok(ret, "got %lu\n", GetLastError());
3540
3541 /* and creates a new websocket */
3542 socket2 = pWinHttpWebSocketCompleteUpgrade(request, 0);
3543 ok(socket2 != NULL, "got %lu\n", GetLastError());
3544 ok(socket2 != socket, "got same socket\n");
3545
3546 WinHttpCloseHandle(connection);
3547 /* request handle is still valid */
3548 size = sizeof(ctx);
3550 ok(ret, "got %lu\n", GetLastError());
3551
3552 ret = WinHttpCloseHandle(socket2);
3553 ok(ret, "got %lu\n", GetLastError());
3554
3556 ok(ret, "got %lu\n", GetLastError());
3557
3559 ok(ret, "got %lu\n", GetLastError());
3560
3562 ok(ret, "got %lu\n", GetLastError());
3563
3565 ok(ret, "got %lu\n", GetLastError());
3566
3568 ok(ret, "got %lu\n", GetLastError());
3569
3570 session = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
3571 ok(session != NULL, "got %lu\n", GetLastError());
3572
3573 connection = WinHttpConnect(session, L"ws.ifelse.io", 0, 0);
3574 ok(connection != NULL, "got %lu\n", GetLastError());
3575
3576 size = 0xdeadbeef;
3578 ok(ret, "got %lu\n", GetLastError());
3579 ok(size == sizeof(DWORD), "got %lu.\n", size);
3580 ok(value == 32768, "got %lu.\n", value);
3581
3582 value = 65535;
3584 ok(ret, "got %lu\n", GetLastError());
3585
3586 size = 0xdeadbeef;
3588 ok(ret, "got %lu\n", GetLastError());
3589 ok(size == sizeof(DWORD), "got %lu.\n", size);
3590 ok(value == 32768, "got %lu.\n", value);
3591
3592 value = 15;
3594 ok(ret, "got %lu\n", GetLastError());
3595
3596 request = WinHttpOpenRequest(connection, L"GET", L"/", NULL, NULL, NULL, 0);
3597 ok(request != NULL, "got %lu\n", GetLastError());
3598
3599 size = 0xdeadbeef;
3601 ok(ret, "got %lu\n", GetLastError());
3602 ok(size == sizeof(DWORD), "got %lu.\n", size);
3603 ok(value == 65535 || broken( value == WINHTTP_OPTION_WEB_SOCKET_RECEIVE_BUFFER_SIZE ) /* Win8 */, "got %lu.\n", value);
3605 broken_buffer_sizes = TRUE;
3606
3607 size = 0xdeadbeef;
3609 ok(ret, "got %lu\n", GetLastError());
3610 ok(size == sizeof(DWORD), "got %lu.\n", size);
3611 ok(value == 65535 || broken( value == WINHTTP_OPTION_WEB_SOCKET_RECEIVE_BUFFER_SIZE ), "got %lu.\n", value);
3612
3613 value = 1048576;
3615 ok(ret, "got %lu\n", GetLastError());
3616
3617 size = 0xdeadbeef;
3619 ok(ret, "got %lu\n", GetLastError());
3620 ok(size == sizeof(DWORD), "got %lu.\n", size);
3621 ok(value == 65535 || broken( value == WINHTTP_OPTION_WEB_SOCKET_RECEIVE_BUFFER_SIZE ) /* Win8 */, "got %lu.\n", value);
3622
3623 size = 0xdeadbeef;
3625 ok(ret, "got %lu\n", GetLastError());
3626 ok(size == sizeof(DWORD), "got %lu.\n", size);
3627 ok(value == 1048576, "got %lu.\n", value);
3628
3629 size = 0xdeadbeef;
3631 ok(!ret, "got %d\n", ret);
3633
3634 size = 0xdeadbeef;
3636 ok(ret, "got %lu\n", GetLastError());
3637 ok(size == sizeof(DWORD), "got %lu.\n", size);
3638 ok(value == 15 || broken( value == WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE ) /* Win8 */, "got %lu.\n", value);
3639
3640 size = sizeof(value);
3642 ok(!ret, "got %d\n", ret);
3644
3645 size = sizeof(value);
3647 ok(!ret, "got %d\n", ret);
3649
3650 value = 20000;
3652 ok(!ret, "got %d\n", ret);
3654
3656 ok(ret, "got %lu\n", GetLastError());
3657
3658 if (!broken_buffer_sizes)
3659 {
3660 /* Fails because we have a too small send buffer size set, but is different on Win8. */
3661 ret = WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, 0);
3662 ok(!ret, "got %d\n", ret);
3664 }
3665
3666 value = 16;
3668 ok(ret, "got %lu\n", GetLastError());
3669
3670 ret = WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, 0);
3671 ok(ret, "got %lu\n", GetLastError());
3672
3673 value = 15;
3675 ok(ret, "got %lu\n", GetLastError());
3676
3678 ok(ret, "got %lu\n", GetLastError());
3679
3680 status = 0xdeadbeef;
3681 size = sizeof(status);
3683 &size, NULL);
3684 ok(ret, "got %lu\n", GetLastError());
3685 ok(status == HTTP_STATUS_SWITCH_PROTOCOLS, "got %lu\n", status);
3686
3687 socket = pWinHttpWebSocketCompleteUpgrade(request, 0);
3688 ok(socket != NULL, "got %lu\n", GetLastError());
3689
3690 size = sizeof(value);
3692 ok(!ret, "got %d\n", ret);
3694
3695 value = 65535;
3697 ok(!ret, "got %d\n", ret);
3699
3701 ok(!ret, "got %d\n", ret);
3703
3704 value = 20000;
3706 ok(!ret, "got %d\n", ret);
3708
3709 value = 20000;
3711 ok(!ret, "got %d\n", ret);
3713
3714 SetLastError(0xdeadbeef);
3715 value = 20000;
3717 ok(ret, "got %lu\n", GetLastError());
3718 ok(!GetLastError(), "got %lu\n", GetLastError());
3719
3720 size = sizeof(value);
3722 ok(!ret, "got %d\n", ret);
3724
3725 size = 0;
3727 ok(!ret, "got %d\n", ret);
3729
3730 value = 10000;
3732 ok(!ret, "got %d\n", ret);
3734
3735 value = 10000;
3737 ok(!ret, "got %d\n", ret);
3739
3740 buf[0] = 0;
3741 count = 0;
3742 type = 0xdeadbeef;
3743 error = pWinHttpWebSocketReceive(socket, buf, sizeof(buf), &count, &type);
3744 ok(!error, "got %lu\n", error);
3745 ok(buf[0] == 'R', "got %c\n", buf[0]);
3746 ok(count, "got zero count\n");
3748
3749 error = pWinHttpWebSocketSend(socket, WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE, NULL, 1);
3750 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3751
3752 large_buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(buf) * 2);
3753 memcpy(large_buf, "hello", sizeof("hello"));
3754 memcpy(large_buf + sizeof(buf), "world", sizeof("world"));
3755 error = pWinHttpWebSocketSend(socket, WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE, large_buf, sizeof(buf) * 2);
3756 ok(!error, "got %lu\n", error);
3757 HeapFree(GetProcessHeap(), 0, large_buf);
3758
3759 error = pWinHttpWebSocketReceive(socket, NULL, 0, NULL, NULL);
3760 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3761
3762 error = pWinHttpWebSocketReceive(socket, buf, 0, NULL, NULL);
3763 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3764
3765 error = pWinHttpWebSocketReceive(socket, NULL, 1, NULL, NULL);
3766 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3767
3768 buf[0] = 0;
3769 count = 0;
3770 type = 0xdeadbeef;
3771 error = pWinHttpWebSocketReceive(socket, buf, sizeof(buf), &count, &type);
3772 ok(!error, "got %lu\n", error);
3773 ok(buf[0] == 'h', "got %c\n", buf[0]);
3774 ok(count == sizeof(buf), "got %lu\n", count);
3776
3777 buf[0] = 0;
3778 count = 0;
3779 type = 0xdeadbeef;
3780 error = pWinHttpWebSocketReceive(socket, buf, sizeof(buf), &count, &type);
3781 ok(!error, "got %lu\n", error);
3782 ok(buf[0] == 'w', "got %c\n", buf[0]);
3783 ok(count == sizeof(buf), "got %lu\n", count);
3785
3786 error = pWinHttpWebSocketShutdown(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, NULL, 1);
3787 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3788
3789 error = pWinHttpWebSocketShutdown(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, buf, sizeof(buf));
3790 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3791
3792 error = pWinHttpWebSocketShutdown(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, (void *)"success",
3793 sizeof("success"));
3794 ok(!error, "got %lu\n", error);
3795
3796 error = pWinHttpWebSocketClose(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, NULL, 1);
3797 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3798
3799 error = pWinHttpWebSocketClose(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, buf, sizeof(buf));
3800 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3801
3802 error = pWinHttpWebSocketClose(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, (void *)"success2",
3803 sizeof("success2"));
3804 ok(!error, "got %lu\n", error);
3805
3806 error = pWinHttpWebSocketQueryCloseStatus(socket, NULL, NULL, 0, NULL);
3807 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3808
3809 error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, NULL, 0, NULL);
3810 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3811
3812 error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, buf, 0, NULL);
3813 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3814
3815 error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, buf, sizeof(buf), NULL);
3816 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3817
3818 error = pWinHttpWebSocketQueryCloseStatus(socket, NULL, NULL, 0, &len);
3819 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3820
3821 len = 0xdeadbeef;
3822 error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, NULL, 0, &len);
3823 ok(!error, "got %lu\n", error);
3824 ok(!len, "got %lu\n", len);
3825
3826 error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, NULL, 1, &len);
3827 ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
3828
3829 close_status = 0xdead;
3830 len = 0xdeadbeef;
3831 memset(buf, 0, sizeof(buf));
3832 error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, buf, sizeof(buf), &len);
3833 ok(!error, "got %lu\n", error);
3834 ok(close_status == 1000, "got %d\n", close_status);
3835 ok(!len, "got %lu\n", len);
3836
3839 WinHttpCloseHandle(connection);
3841}
3842
3843static void test_not_modified(int port)
3844{
3845 BOOL ret;
3846 HINTERNET session, request, connection;
3848 SYSTEMTIME st;
3849 WCHAR today[(sizeof(L"If-Modified-Since: ") + WINHTTP_TIME_FORMAT_BUFSIZE)/sizeof(WCHAR) + 3], buffer[32];
3850
3851 memcpy(today, L"If-Modified-Since: ", sizeof(L"If-Modified-Since: "));
3852 GetSystemTime(&st);
3853 WinHttpTimeFromSystemTime(&st, &today[ARRAY_SIZE(L"If-Modified-Since: ") - 1]);
3854
3857 ok(session != NULL, "WinHttpOpen failed: %lu\n", GetLastError());
3858
3859 connection = WinHttpConnect(session, L"localhost", port, 0);
3860 ok(connection != NULL, "WinHttpConnect failed: %lu\n", GetLastError());
3861
3862 request = WinHttpOpenRequest(connection, NULL, L"/not_modified", NULL, WINHTTP_NO_REFERER,
3864 ok(request != NULL, "WinHttpOpenrequest failed: %lu\n", GetLastError());
3865
3866 ret = WinHttpSendRequest(request, today, 0, NULL, 0, 0, 0);
3867 ok(ret, "WinHttpSendRequest failed: %lu\n", GetLastError());
3868
3870 ok(ret, "WinHttpReceiveResponse failed: %lu\n", GetLastError());
3871
3872 index = 0;
3873 len = sizeof(buffer);
3875 L"If-Modified-Since", buffer, &len, &index);
3876 ok(ret, "failed to get header %lu\n", GetLastError());
3877
3878 status = 0xdeadbeef;
3879 size = sizeof(status);
3881 NULL, &status, &size, NULL);
3882 ok(ret, "WinHttpQueryHeaders failed: %lu\n", GetLastError());
3883 ok(status == HTTP_STATUS_NOT_MODIFIED, "got %lu\n", status);
3884
3885 size = 0xdeadbeef;
3887 ok(ret, "WinHttpQueryDataAvailable failed: %lu\n", GetLastError());
3888 ok(!size, "got %lu\n", size);
3889
3891 WinHttpCloseHandle(connection);
3893 start = GetTickCount() - start;
3894 ok(start <= 2000, "Expected less than 2 seconds for the test, got %lu ms\n", start);
3895}
3896
3897static void test_bad_header( int port )
3898{
3899 static const WCHAR expected_headers[] =
3900 {
3901 L"HTTP/1.1 200 OK\r\n"
3902 L"Server: winetest\r\n"
3903 L"SpaceAfterHdr: bad\r\n"
3904 L"OkHdr: ok\r\n"
3905 L"\r\n"
3906 };
3907
3908 HINTERNET ses, con, req;
3909 WCHAR buffer[512];
3910 DWORD index, len;
3911 unsigned int i;
3912 BOOL ret;
3913
3914 static const WCHAR bad_headers[] =
3915 L"Content-Type: text/html\n\r"
3916 L"Test1: Value1\n"
3917 L"Test2: Value2\n\n\n"
3918 L"Test3: Value3\r\r\r"
3919 L"Test4: Value4\r\n\r\n"
3920 L"Cookie: 111";
3921
3922 static const struct
3923 {
3924 const WCHAR *header;
3925 const WCHAR *value;
3926 }
3927 header_tests[] =
3928 {
3929 {L"Content-Type", L"text/html"},
3930 {L"Test1", L"Value1"},
3931 {L"Test2", L"Value2"},
3932 {L"Test3", L"Value3"},
3933 {L"Test4", L"Value4"},
3934 {L"Cookie", L"111"},
3935 };
3936
3937 ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
3938 ok( ses != NULL, "failed to open session %lu\n", GetLastError() );
3939
3940 con = WinHttpConnect( ses, L"localhost", port, 0 );
3941 ok( con != NULL, "failed to open a connection %lu\n", GetLastError() );
3942
3943 req = WinHttpOpenRequest( con, L"POST", L"/bad_headers", NULL, NULL, NULL, 0 );
3944 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
3945
3946 ret = WinHttpAddRequestHeaders( req, bad_headers, ~0u, WINHTTP_ADDREQ_FLAG_ADD );
3947 ok( ret, "failed to add header %lu\n", GetLastError() );
3948
3949 for (i = 0; i < ARRAY_SIZE(header_tests); ++i)
3950 {
3951 index = 0;
3952 buffer[0] = 0;
3953 len = sizeof(buffer);
3955 header_tests[i].header, buffer, &len, &index );
3956 ok( ret, "header %s: failed to query headers %lu\n", debugstr_w(header_tests[i].header), GetLastError() );
3957 ok( !wcscmp( buffer, header_tests[i].value ), "header %s: got %s\n",
3958 debugstr_w(header_tests[i].header), debugstr_w(buffer) );
3959 ok( index == 1, "header %s: index = %lu\n", debugstr_w(header_tests[i].header), index );
3960 }
3961
3962 ret = WinHttpSendRequest( req, L"Test5: Value5\rTest6: Value6", ~0u, NULL, 0, 0, 0 );
3963 ok( ret, "failed to send request %lu\n", GetLastError() );
3964
3966 ok( ret, "failed to receive response %lu\n", GetLastError() );
3967
3968 len = sizeof(buffer);
3970 ok( ret, "got error %lu.\n", GetLastError() );
3971
3972 len = sizeof(buffer);
3974 ok( ret, "got error %lu.\n", GetLastError() );
3975 ok( !wcscmp( buffer, expected_headers ), "got %s.\n", debugstr_w(buffer) );
3976
3977 len = sizeof(buffer);
3979 ok( ret, "got error %lu.\n", GetLastError() );
3980 ok( !wcscmp( buffer, L"bad" ), "got %s.\n", debugstr_w(buffer) );
3981
3982 WinHttpCloseHandle( req );
3983 WinHttpCloseHandle( con );
3984 WinHttpCloseHandle( ses );
3985}
3986
3988{
3989 HINTERNET ses, con, req;
3990 DWORD total_len = 0;
3991 BOOL ret;
3992
3993 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
3994 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
3995
3996 con = WinHttpConnect(ses, L"localhost", port, 0);
3997 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
3998
3999 req = WinHttpOpenRequest(con, NULL, L"big", NULL, NULL, NULL, 0);
4000 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
4001
4002 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
4003 ok(ret, "failed to send request %lu\n", GetLastError());
4004
4005 trace("waiting for response\n");
4007 ok(ret == TRUE, "expected success\n");
4008
4009 trace("finished waiting for response\n");
4010
4011 for (;;)
4012 {
4013 DWORD len = 0xdeadbeef;
4015 ok( ret, "WinHttpQueryDataAvailable failed with error %lu\n", GetLastError() );
4016 if (ret) ok( len != 0xdeadbeef, "WinHttpQueryDataAvailable return wrong length\n" );
4017 if (len)
4018 {
4019 DWORD bytes_read;
4020 char *buf = HeapAlloc( GetProcessHeap(), 0, len + 1 );
4021
4022 ret = WinHttpReadData( req, buf, len, &bytes_read );
4023 ok(ret, "WinHttpReadData failed: %lu\n", GetLastError());
4024 ok( len == bytes_read, "only got %lu of %lu available\n", bytes_read, len );
4025
4026 HeapFree( GetProcessHeap(), 0, buf );
4027 if (!bytes_read) break;
4028 total_len += bytes_read;
4029 trace("read bytes %lu, total_len: %lu\n", bytes_read, total_len);
4030 }
4031 if (!len) break;
4032 }
4033 ok(total_len == BIG_BUFFER_LEN, "got wrong length: %lu\n", total_len);
4034
4035 WinHttpCloseHandle(req);
4036 WinHttpCloseHandle(con);
4037 WinHttpCloseHandle(ses);
4038}
4039
4040static void test_cookies( int port )
4041{
4042 HINTERNET ses, con, req;
4043 DWORD status, size;
4044 BOOL ret;
4045
4046 ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
4047 ok( ses != NULL, "failed to open session %lu\n", GetLastError() );
4048
4049 con = WinHttpConnect( ses, L"localhost", port, 0 );
4050 ok( con != NULL, "failed to open a connection %lu\n", GetLastError() );
4051
4052 req = WinHttpOpenRequest( con, NULL, L"/cookie", NULL, NULL, NULL, 0 );
4053 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
4054
4055 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4056 ok( ret, "failed to send request %lu\n", GetLastError() );
4057
4059 ok( ret, "failed to receive response %lu\n", GetLastError() );
4060
4061 status = 0xdeadbeef;
4062 size = sizeof(status);
4064 ok( ret, "failed to query status code %lu\n", GetLastError() );
4065 ok( status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status );
4066
4067 WinHttpCloseHandle( req );
4068
4069 req = WinHttpOpenRequest( con, NULL, L"/cookie2", NULL, NULL, NULL, 0 );
4070 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
4071
4072 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4073 ok( ret, "failed to send request %lu\n", GetLastError() );
4074
4076 ok( ret, "failed to receive response %lu\n", GetLastError() );
4077
4078 status = 0xdeadbeef;
4079 size = sizeof(status);
4081 ok( ret, "failed to query status code %lu\n", GetLastError() );
4082 ok( status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status );
4083
4084 WinHttpCloseHandle( req );
4085 WinHttpCloseHandle( con );
4086
4087 con = WinHttpConnect( ses, L"localhost", port, 0 );
4088 ok( con != NULL, "failed to open a connection %lu\n", GetLastError() );
4089
4090 req = WinHttpOpenRequest( con, NULL, L"/cookie2", NULL, NULL, NULL, 0 );
4091 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
4092
4093 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4094 ok( ret, "failed to send request %lu\n", GetLastError() );
4095
4097 ok( ret, "failed to receive response %lu\n", GetLastError() );
4098
4099 status = 0xdeadbeef;
4100 size = sizeof(status);
4102 ok( ret, "failed to query status code %lu\n", GetLastError() );
4103 ok( status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status );
4104
4105 WinHttpCloseHandle( req );
4106
4107 req = WinHttpOpenRequest( con, NULL, L"/cookie3", NULL, NULL, NULL, 0 );
4108 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
4109 ret = WinHttpSendRequest( req, L"Cookie: name=value2\r\n", ~0u, NULL, 0, 0, 0 );
4110 ok( ret, "failed to send request %lu\n", GetLastError() );
4111
4113 ok( ret, "failed to receive response %lu\n", GetLastError() );
4114
4115 status = 0xdeadbeef;
4116 size = sizeof(status);
4118 ok( ret, "failed to query status code %lu\n", GetLastError() );
4119 ok( status == HTTP_STATUS_OK || broken(status == HTTP_STATUS_BAD_REQUEST), "request failed unexpectedly %lu\n", status );
4120
4121 WinHttpCloseHandle( req );
4122 WinHttpCloseHandle( con );
4123 WinHttpCloseHandle( ses );
4124
4125 ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
4126 ok( ses != NULL, "failed to open session %lu\n", GetLastError() );
4127
4128 con = WinHttpConnect( ses, L"localhost", port, 0 );
4129 ok( con != NULL, "failed to open a connection %lu\n", GetLastError() );
4130
4131 req = WinHttpOpenRequest( con, NULL, L"/cookie2", NULL, NULL, NULL, 0 );
4132 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
4133
4134 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4135 ok( ret, "failed to send request %lu\n", GetLastError() );
4136
4138 ok( ret, "failed to receive response %lu\n", GetLastError() );
4139
4140 status = 0xdeadbeef;
4141 size = sizeof(status);
4143 ok( ret, "failed to query status code %lu\n", GetLastError() );
4144 ok( status == HTTP_STATUS_BAD_REQUEST, "request failed unexpectedly %lu\n", status );
4145
4146 WinHttpCloseHandle( req );
4147 WinHttpCloseHandle( con );
4148 WinHttpCloseHandle( ses );
4149
4150 ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
4151 ok( ses != NULL, "failed to open session %lu\n", GetLastError() );
4152
4153 con = WinHttpConnect( ses, L"localhost", port, 0 );
4154 ok( con != NULL, "failed to open a connection %lu\n", GetLastError() );
4155
4156 req = WinHttpOpenRequest( con, NULL, L"/cookie4", NULL, NULL, NULL, 0 );
4157 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
4158
4159 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4160 ok( ret, "failed to send request %lu\n", GetLastError() );
4161
4163 ok( ret, "failed to receive response %lu\n", GetLastError() );
4164
4165 status = 0xdeadbeef;
4166 size = sizeof(status);
4168 ok( ret, "failed to query status code %lu\n", GetLastError() );
4169 ok( status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status );
4170 WinHttpCloseHandle( req );
4171
4172 req = WinHttpOpenRequest( con, NULL, L"/cookie5", NULL, NULL, NULL, 0 );
4173 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
4174
4175 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4176 ok( ret, "failed to send request %lu\n", GetLastError() );
4177
4179 ok( ret, "failed to receive response %lu\n", GetLastError() );
4180
4181 status = 0xdeadbeef;
4182 size = sizeof(status);
4184 ok( ret, "failed to query status code %lu\n", GetLastError() );
4186 "request failed unexpectedly %lu\n", status );
4187
4188 WinHttpCloseHandle( req );
4189 WinHttpCloseHandle( con );
4190 WinHttpCloseHandle( ses );
4191}
4192
4193static void do_request( HINTERNET con, const WCHAR *obj, DWORD flags )
4194{
4195 HINTERNET req;
4196 DWORD status, size;
4197 BOOL ret;
4198
4199 req = WinHttpOpenRequest( con, NULL, obj, NULL, NULL, NULL, flags );
4200 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
4201
4202 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4203 ok( ret, "failed to send request %lu\n", GetLastError() );
4204
4206 ok( ret, "failed to receive response %lu\n", GetLastError() );
4207
4208 status = 0xdeadbeef;
4209 size = sizeof(status);
4211 ok( ret, "failed to query status code %lu\n", GetLastError() );
4213 "request %s with flags %#lx failed %lu\n", wine_dbgstr_w(obj), flags, status );
4214 WinHttpCloseHandle( req );
4215}
4216
4218{
4219 static const WCHAR objW[] =
4220 {'/','e','s','c','a','p','e','\r','\n',0x1f,0x7f,'<',' ','%','o','n','e','?',0x1f,0x7f,' ','!','"','#',
4221 '$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^','_','`',
4222 '{','|','}','~','\r','\n',0};
4223 static const WCHAR obj2W[] =
4224 {'/','e','s','c','a','p','e','\r','\n',0x1f,0x7f,'<',' ','%','t','w','o','?',0x1f,0x7f,' ','!','"','#',
4225 '$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^','_','`',
4226 '{','|','}','~','\r','\n',0};
4227 static const WCHAR obj3W[] =
4228 {'/','e','s','c','a','p','e','\r','\n',0x1f,0x7f,'<',' ','%','t','h','r','e','e','?',0x1f,0x7f,' ','!',
4229 '"','#','$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^',
4230 '_','`','{','|','}','~','\r','\n',0};
4231 static const WCHAR obj4W[] =
4232 {'/','e','s','c','a','p','e','\r','\n',0x1f,0x7f,'<',' ','%','f','o','u','r','?',0x1f,0x7f,' ','!','"',
4233 '#','$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^','_',
4234 '`','{','|','}','~','\r','\n',0};
4235 static const WCHAR obj5W[] =
4236 {'/','e','s','c','a','p','e','&','t','e','x','t','=','o','n','e',0x80,0x7f,0x7e,0};
4237 static const WCHAR obj6W[] =
4238 {'/','e','s','c','a','p','e','&','t','e','x','t','=','t','w','o',0x80,0x7f,0x7e,0};
4239 static const WCHAR obj7W[] =
4240 {'/','e','s','c','a','p','e','&','t','e','x','t','=',0x541b,0x306e,0x540d,0x306f,0};
4241 HINTERNET ses, con;
4242
4243 ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
4244 ok( ses != NULL, "failed to open session %lu\n", GetLastError() );
4245
4246 con = WinHttpConnect( ses, L"localhost", port, 0 );
4247 ok( con != NULL, "failed to open a connection %lu\n", GetLastError() );
4248
4249 do_request( con, objW, 0 );
4253 do_request( con, obj5W, 0 );
4256
4257 WinHttpCloseHandle( con );
4258 WinHttpCloseHandle( ses );
4259}
4260
4261static void test_connection_info( int port )
4262{
4263 HINTERNET ses, con, req;
4264 WINHTTP_CONNECTION_INFO info;
4265 DWORD size, error;
4266 BOOL ret;
4267
4268 ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
4269 ok( ses != NULL, "failed to open session %lu\n", GetLastError() );
4270
4271 con = WinHttpConnect( ses, L"localhost", port, 0 );
4272 ok( con != NULL, "failed to open a connection %lu\n", GetLastError() );
4273
4274 req = WinHttpOpenRequest( con, NULL, L"/basic", NULL, NULL, NULL, 0 );
4275 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
4276
4277 size = sizeof(info);
4278 SetLastError( 0xdeadbeef );
4280 error = GetLastError();
4282 {
4283 win_skip( "WINHTTP_OPTION_CONNECTION_INFO not supported\n" );
4284 return;
4285 }
4286 ok( !ret, "unexpected success\n" );
4288
4289 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4290 ok( ret, "failed to send request %lu\n", GetLastError() );
4291
4292 size = 0;
4293 SetLastError( 0xdeadbeef );
4295 error = GetLastError();
4296 ok( !ret, "unexpected success\n" );
4297 ok( error == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", error );
4298
4299 size = sizeof(info);
4300 memset( &info, 0, sizeof(info) );
4302 ok( ret, "failed to retrieve connection info %lu\n", GetLastError() );
4303 ok( info.cbSize == sizeof(info) || info.cbSize == sizeof(info) - sizeof(info.cbSize) /* Win7 */, "wrong size %lu\n", info.cbSize );
4304
4306 ok( ret, "failed to receive response %lu\n", GetLastError() );
4307
4308 size = sizeof(info);
4309 memset( &info, 0, sizeof(info) );
4311 ok( ret, "failed to retrieve connection info %lu\n", GetLastError() );
4312 ok( info.cbSize == sizeof(info) || info.cbSize == sizeof(info) - sizeof(info.cbSize) /* Win7 */, "wrong size %lu\n", info.cbSize );
4313
4314 WinHttpCloseHandle( req );
4315 WinHttpCloseHandle( con );
4316 WinHttpCloseHandle( ses );
4317}
4318
4319static void test_passport_auth( int port )
4320{
4321 static const WCHAR headersW[] =
4322 L"HTTP/1.1 401 Found\r\nContent-Length: 0\r\nLocation: /\r\nWWW-Authenticate: Passport1.4\r\n\r\n";
4323 HINTERNET ses, con, req;
4325 WCHAR buf[128];
4326 BOOL ret;
4327
4328 ses = WinHttpOpen( L"winetest", 0, NULL, NULL, 0 );
4329 ok( ses != NULL, "got %lu\n", GetLastError() );
4330
4333 ok( ret, "got %lu\n", GetLastError() );
4334
4335 con = WinHttpConnect( ses, L"localhost", port, 0 );
4336 ok( con != NULL, "got %lu\n", GetLastError() );
4337
4338 req = WinHttpOpenRequest( con, NULL, L"/passport", NULL, NULL, NULL, 0 );
4339 ok( req != NULL, "got %lu\n", GetLastError() );
4340
4341 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4342 ok( ret, "got %lu\n", GetLastError() );
4343
4345 err = GetLastError();
4346 ok( ret || broken(!ret && err == ERROR_WINHTTP_LOGIN_FAILURE) /* winxp */
4347 || broken(!ret && err == ERROR_WINHTTP_INVALID_SERVER_RESPONSE ), "got %lu\n", err );
4348 if (!ret)
4349 {
4350 win_skip("no support for Passport redirects\n");
4351 goto cleanup;
4352 }
4353
4354 status = 0xdeadbeef;
4355 size = sizeof(status);
4357 ok( ret, "got %lu\n", GetLastError() );
4358 ok( status == HTTP_STATUS_DENIED, "got %lu\n", status );
4359
4360 buf[0] = 0;
4361 size = sizeof(buf);
4363 ok( ret, "got %lu\n", GetLastError() );
4364 ok( !lstrcmpW(L"Found", buf) || broken(!lstrcmpW(L"Unauthorized", buf)) /* < win7 */, "got %s\n",
4365 wine_dbgstr_w(buf) );
4366
4367 buf[0] = 0;
4368 size = sizeof(buf);
4370 ok( ret || broken(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER) /* < win7 */, "got %lu\n", GetLastError() );
4371 if (ret)
4372 {
4373 ok( size == lstrlenW(headersW) * sizeof(WCHAR), "got %lu\n", size );
4374 ok( !lstrcmpW(headersW, buf), "got %s\n", wine_dbgstr_w(buf) );
4375 }
4376
4377cleanup:
4378 WinHttpCloseHandle( req );
4379 WinHttpCloseHandle( con );
4380 WinHttpCloseHandle( ses );
4381}
4382
4383static void test_credentials(void)
4384{
4385 static WCHAR userW[] = {'u','s','e','r',0};
4386 static WCHAR passW[] = {'p','a','s','s',0};
4387 static WCHAR proxy_userW[] = {'p','r','o','x','y','u','s','e','r',0};
4388 static WCHAR proxy_passW[] = {'p','r','o','x','y','p','a','s','s',0};
4389 HINTERNET ses, con, req;
4390 DWORD size, error;
4391 WCHAR buffer[32];
4392 BOOL ret;
4393
4394 ses = WinHttpOpen(L"winetest", 0, proxy_userW, proxy_passW, 0);
4395 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
4396
4397 con = WinHttpConnect(ses, L"localhost", 0, 0);
4398 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
4399
4400 req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
4401 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
4402
4405 ok(ret, "failed to query proxy username %lu\n", GetLastError());
4406 ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
4407 ok(!size, "expected 0, got %lu\n", size);
4408
4409 size = 4;
4410 SetLastError(0xdeadbeef);
4412 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4413 ok(size == 2, "Unexpected size %lu\n", size);
4414
4417 ok(ret, "failed to query proxy password %lu\n", GetLastError());
4418 ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
4419 ok(!size, "expected 0, got %lu\n", size);
4420
4421 size = 4;
4422 SetLastError(0xdeadbeef);
4424 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4425 ok(size == 2, "Unexpected size %lu\n", size);
4426
4427 ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_USERNAME, proxy_userW, lstrlenW(proxy_userW));
4428 ok(ret, "failed to set username %lu\n", GetLastError());
4429
4432 ok(ret, "failed to query proxy username %lu\n", GetLastError());
4433 ok(!wcscmp(buffer, proxy_userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
4434 ok(size == lstrlenW(proxy_userW) * sizeof(WCHAR), "unexpected result %lu\n", size);
4435
4436 /* Exact buffer size match. */
4437 size = (lstrlenW(proxy_userW) + 1) * sizeof(WCHAR);
4438 buffer[0] = 0;
4440 ok(ret, "failed to query proxy username %lu\n", GetLastError());
4441 ok(!wcscmp(buffer, proxy_userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
4442 ok(size == lstrlenW(proxy_userW) * sizeof(WCHAR), "unexpected result %lu\n", size);
4443
4444 buffer[0] = 0x1;
4445 SetLastError(0xdeadbeef);
4447 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4448 ok(*buffer == 0x1, "unexpected result %s\n", wine_dbgstr_w(buffer));
4449 ok(size == (lstrlenW(proxy_userW) + 1) * sizeof(WCHAR), "unexpected result %lu\n", size);
4450
4451 size = 0;
4452 SetLastError(0xdeadbeef);
4454 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4455 ok(size == (lstrlenW(proxy_userW) + 1) * sizeof(WCHAR), "Unexpected size %lu\n", size);
4456
4459 ok(ret, "failed to query username %lu\n", GetLastError());
4460 ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
4461 ok(!size, "expected 0, got %lu\n", size);
4462
4463 size = 4;
4464 SetLastError(0xdeadbeef);
4466 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4467 ok(size == 2, "Unexpected size %lu\n", size);
4468
4471 ok(ret, "failed to query password %lu\n", GetLastError());
4472 ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
4473 ok(!size, "expected 0, got %lu\n", size);
4474
4475 size = 4;
4476 SetLastError(0xdeadbeef);
4478 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4479 ok(size == 2, "Unexpected size %lu\n", size);
4480
4481 ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_PASSWORD, proxy_passW, lstrlenW(proxy_passW));
4482 ok(ret, "failed to set proxy password %lu\n", GetLastError());
4483
4486 ok(ret, "failed to query proxy password %lu\n", GetLastError());
4487 ok(!wcscmp(buffer, proxy_passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
4488 ok(size == lstrlenW(proxy_passW) * sizeof(WCHAR), "unexpected result %lu\n", size);
4489
4490 /* Exact buffer size match. */
4491 size = (lstrlenW(proxy_passW) + 1) * sizeof(WCHAR);
4492 buffer[0] = 0;
4494 ok(ret, "failed to query proxy password %lu\n", GetLastError());
4495 ok(!wcscmp(buffer, proxy_passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
4496 ok(size == lstrlenW(proxy_passW) * sizeof(WCHAR), "unexpected result %lu\n", size);
4497
4498 buffer[0] = 0x1;
4499 SetLastError(0xdeadbeef);
4501 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4502 ok(*buffer == 0x1, "unexpected result %s\n", wine_dbgstr_w(buffer));
4503 ok(size == (lstrlenW(proxy_passW) + 1) * sizeof(WCHAR), "unexpected result %lu\n", size);
4504
4505 size = 0;
4506 SetLastError(0xdeadbeef);
4508 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4509 ok(size == (lstrlenW(proxy_passW) + 1) * sizeof(WCHAR), "Unexpected size %lu\n", size);
4510
4512 ok(ret, "failed to set username %lu\n", GetLastError());
4513
4516 ok(ret, "failed to query username %lu\n", GetLastError());
4517 ok(!wcscmp(buffer, userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
4518 ok(size == lstrlenW(userW) * sizeof(WCHAR), "unexpected result %lu\n", size);
4519
4520 /* Exact buffer size match. */
4521 size = (lstrlenW(userW) + 1) * sizeof(WCHAR);
4522 buffer[0] = 0;
4524 ok(ret, "failed to query username %lu\n", GetLastError());
4525 ok(!wcscmp(buffer, userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
4526 ok(size == lstrlenW(userW) * sizeof(WCHAR), "unexpected result %lu\n", size);
4527
4528 buffer[0] = 0x1;
4529 SetLastError(0xdeadbeef);
4531 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4532 ok(*buffer == 0x1, "unexpected result %s\n", wine_dbgstr_w(buffer));
4533 ok(size == (lstrlenW(userW) + 1) * sizeof(WCHAR), "unexpected result %lu\n", size);
4534
4535 size = 0;
4536 SetLastError(0xdeadbeef);
4538 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4539 ok(size == (lstrlenW(userW) + 1) * sizeof(WCHAR), "Unexpected size %lu\n", size);
4540
4542 ok(ret, "failed to set password %lu\n", GetLastError());
4543
4546 ok(ret, "failed to query password %lu\n", GetLastError());
4547 ok(!wcscmp(buffer, passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
4548 ok(size == lstrlenW(passW) * sizeof(WCHAR), "unexpected result %lu\n", size);
4549
4550 /* Exact buffer size match. */
4551 buffer[0] = 0;
4552 size = (lstrlenW(passW) + 1) * sizeof(WCHAR);
4554 ok(ret, "failed to query password %lu\n", GetLastError());
4555 ok(!wcscmp(buffer, passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
4556 ok(size == lstrlenW(passW) * sizeof(WCHAR), "unexpected result %lu\n", size);
4557
4558 buffer[0] = 0x1;
4559 SetLastError(0xdeadbeef);
4561 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4562 ok(*buffer == 0x1, "unexpected result %s\n", wine_dbgstr_w(buffer));
4563 ok(size == (lstrlenW(passW) + 1) * sizeof(WCHAR), "unexpected result %lu\n", size);
4564
4565 size = 0;
4566 SetLastError(0xdeadbeef);
4568 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected error %lu\n", GetLastError());
4569 ok(size == (lstrlenW(passW) + 1) * sizeof(WCHAR), "Unexpected size %lu\n", size);
4570
4571 WinHttpCloseHandle(req);
4572
4573 req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
4574 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
4575
4576 SetLastError(0xdeadbeef);
4578 error = GetLastError();
4579 ok(!ret, "expected failure\n");
4580 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
4581
4582 SetLastError(0xdeadbeef);
4584 error = GetLastError();
4585 ok(!ret, "expected failure\n");
4586 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
4587
4589 ok(ret, "failed to set credentials %lu\n", GetLastError());
4590
4593 ok(ret, "failed to query username %lu\n", GetLastError());
4594 todo_wine {
4595 ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
4596 ok(!size, "expected 0, got %lu\n", size);
4597 }
4598
4601 ok(ret, "failed to query password %lu\n", GetLastError());
4602 todo_wine {
4603 ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
4604 ok(!size, "expected 0, got %lu\n", size);
4605 }
4606
4607 WinHttpCloseHandle(req);
4608 WinHttpCloseHandle(con);
4609 WinHttpCloseHandle(ses);
4610}
4611
4613{
4614 static const WCHAR data_start[] = {'<','!','D','O','C','T','Y','P','E',' ','h','t','m','l',' ','P','U','B','L','I','C'};
4615 HRESULT hr;
4616 IWinHttpRequest *req;
4617 BSTR method, url, username, password, response = NULL, status_text = NULL, headers = NULL;
4618 BSTR date, today, connection, value = NULL;
4619 VARIANT async, empty, timeout, body, body2, proxy_server, bypass_list, data, cp, flags;
4620 VARIANT_BOOL succeeded;
4621 LONG status;
4623 SYSTEMTIME st;
4624 IStream *stream, *stream2;
4626 char buf[128];
4627 WCHAR bufW[128];
4628 DWORD count;
4629
4630 GetSystemTime( &st );
4631 WinHttpTimeFromSystemTime( &st, todayW );
4632
4633 CoInitialize( NULL );
4634 hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
4635 ok( hr == S_OK, "got %#lx\n", hr );
4636
4637 V_VT( &empty ) = VT_ERROR;
4638 V_ERROR( &empty ) = 0xdeadbeef;
4639
4640 V_VT( &async ) = VT_BOOL;
4641 V_BOOL( &async ) = VARIANT_FALSE;
4642
4643 method = SysAllocString( L"POST" );
4644 url = SysAllocString( L"http://test.winehq.org/tests/post.php" );
4645 hr = IWinHttpRequest_Open( req, method, url, async );
4646 ok( hr == S_OK, "got %#lx\n", hr );
4648 SysFreeString( url );
4649
4650 V_VT( &data ) = VT_BSTR;
4651 V_BSTR( &data ) = SysAllocString( L"testdata\x80" );
4652 hr = IWinHttpRequest_Send( req, data );
4654 SysFreeString( V_BSTR( &data ) );
4655 if (hr != S_OK) goto done;
4656
4657 hr = IWinHttpRequest_Open( req, NULL, NULL, empty );
4658 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4659
4660 method = SysAllocString( L"GET" );
4661 hr = IWinHttpRequest_Open( req, method, NULL, empty );
4662 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4663
4664 hr = IWinHttpRequest_Open( req, method, NULL, async );
4665 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4666
4667 url = SysAllocString( L"http://test.winehq.org" );
4668 hr = IWinHttpRequest_Open( req, NULL, url, empty );
4669 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4670
4671 hr = IWinHttpRequest_Abort( req );
4672 ok( hr == S_OK, "got %#lx\n", hr );
4673
4674 hr = IWinHttpRequest_Open( req, method, url, empty );
4675 ok( hr == S_OK, "got %#lx\n", hr );
4676
4677 hr = IWinHttpRequest_Abort( req );
4678 ok( hr == S_OK, "got %#lx\n", hr );
4679
4680 IWinHttpRequest_Release( req );
4681
4682 hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
4683 ok( hr == S_OK, "got %#lx\n", hr );
4684
4685 SysFreeString( url );
4686 url = SysAllocString( L"test.winehq.org" );
4687 hr = IWinHttpRequest_Open( req, method, url, async );
4689
4691 method = SysAllocString( L"INVALID" );
4692 hr = IWinHttpRequest_Open( req, method, url, async );
4694
4695 V_VT( &flags ) = VT_ERROR;
4696 V_ERROR( &flags ) = 0xdeadbeef;
4697 hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, &flags );
4698 ok( hr == S_OK, "got %#lx\n", hr );
4699 ok( V_VT( &flags ) == VT_I4, "got %#x\n", V_VT( &flags ) );
4700 ok( V_I4( &flags ) == 0, "got %lx\n", V_I4( &flags ) );
4701
4702 V_VT( &flags ) = VT_I4;
4704 hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, flags );
4705 ok( hr == S_OK, "got %#lx\n", hr );
4706
4707 V_VT( &flags ) = VT_ERROR;
4708 V_ERROR( &flags ) = 0xdeadbeef;
4709 hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, &flags );
4710 ok( hr == S_OK, "got %#lx\n", hr );
4711 ok( V_I4( &flags ) == SECURITY_FLAG_IGNORE_UNKNOWN_CA, "got %lx\n", V_I4( &flags ) );
4712
4714 method = SysAllocString( L"GET" );
4715 SysFreeString( url );
4716 url = SysAllocString( L"http://test.winehq.org" );
4717 V_VT( &async ) = VT_ERROR;
4718 V_ERROR( &async ) = DISP_E_PARAMNOTFOUND;
4719 hr = IWinHttpRequest_Open( req, method, url, async );
4720 ok( hr == S_OK, "got %#lx\n", hr );
4721
4722 V_VT( &cp ) = VT_ERROR;
4723 V_ERROR( &cp ) = 0xdeadbeef;
4724 hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
4725 ok( hr == S_OK, "got %#lx\n", hr );
4726 ok( V_VT( &cp ) == VT_I4, "got %#x\n", V_VT( &cp ) );
4727 ok( V_I4( &cp ) == CP_UTF8, "got %ld\n", V_I4( &cp ) );
4728
4729 V_VT( &cp ) = VT_UI4;
4730 V_UI4( &cp ) = CP_ACP;
4731 hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
4732 ok( hr == S_OK, "got %#lx\n", hr );
4733
4734 V_VT( &cp ) = VT_ERROR;
4735 V_ERROR( &cp ) = 0xdeadbeef;
4736 hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
4737 ok( hr == S_OK, "got %#lx\n", hr );
4738 ok( V_VT( &cp ) == VT_I4, "got %#x\n", V_VT( &cp ) );
4739 ok( V_I4( &cp ) == CP_ACP, "got %ld\n", V_I4( &cp ) );
4740
4741 value = SysAllocString( L"utf-8" );
4742 V_VT( &cp ) = VT_BSTR;
4743 V_BSTR( &cp ) = value;
4744 hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
4745 ok( hr == S_OK, "got %#lx\n", hr );
4747
4748 V_VT( &cp ) = VT_ERROR;
4749 V_ERROR( &cp ) = 0xdeadbeef;
4750 hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
4751 ok( hr == S_OK, "got %#lx\n", hr );
4752 ok( V_VT( &cp ) == VT_I4, "got %#x\n", V_VT( &cp ) );
4753 ok( V_I4( &cp ) == CP_UTF8, "got %ld\n", V_I4( &cp ) );
4754
4755 V_VT( &flags ) = VT_ERROR;
4756 V_ERROR( &flags ) = 0xdeadbeef;
4757 hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, &flags );
4758 ok( hr == S_OK, "got %#lx\n", hr );
4759 ok( V_I4( &flags ) == SECURITY_FLAG_IGNORE_UNKNOWN_CA, "got %lx\n", V_I4( &flags ) );
4760
4761 V_VT( &flags ) = VT_I4;
4762 V_I4( &flags ) = 0x321;
4763 hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, flags );
4764 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4765
4766 V_VT( &flags ) = VT_UI4;
4767 V_UI4( &flags ) = 0x123;
4768 hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, flags );
4769 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4770
4771 V_VT( &flags ) = VT_UI4;
4773 hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, flags);
4774 ok( hr == S_OK, "got %#lx\n", hr );
4775
4776 V_VT( &flags ) = VT_ERROR;
4777 V_ERROR( &flags ) = 0xdeadbeef;
4778 hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, &flags );
4779 ok( hr == S_OK, "got %#lx\n", hr );
4780 ok( V_I4( &flags ) == SECURITY_FLAG_IGNORE_CERT_DATE_INVALID, "got %lx\n", V_I4( &flags ) );
4781
4782 V_VT( &flags ) = VT_I4;
4784 hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, flags );
4785 ok( hr == S_OK, "got %#lx\n", hr );
4786
4787 V_VT( &flags ) = VT_ERROR;
4788 V_ERROR( &flags ) = 0xdeadbeef;
4789 hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, &flags );
4790 ok( hr == S_OK, "got %#lx\n", hr );
4792
4793 hr = IWinHttpRequest_Abort( req );
4794 ok( hr == S_OK, "got %#lx\n", hr );
4795
4796 hr = IWinHttpRequest_Send( req, empty );
4798
4799 hr = IWinHttpRequest_Abort( req );
4800 ok( hr == S_OK, "got %#lx\n", hr );
4801
4802 IWinHttpRequest_Release( req );
4803
4804 hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
4805 ok( hr == S_OK, "got %#lx\n", hr );
4806
4807 hr = IWinHttpRequest_get_ResponseText( req, NULL );
4808 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4809
4810 hr = IWinHttpRequest_get_ResponseText( req, &response );
4812
4813 hr = IWinHttpRequest_get_Status( req, NULL );
4814 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4815
4816 hr = IWinHttpRequest_get_Status( req, &status );
4818
4819 hr = IWinHttpRequest_get_StatusText( req, NULL );
4820 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4821
4822 hr = IWinHttpRequest_get_StatusText( req, &status_text );
4824
4825 hr = IWinHttpRequest_get_ResponseBody( req, NULL );
4826 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4827
4828 hr = IWinHttpRequest_SetTimeouts( req, 10000, 10000, 10000, 10000 );
4829 ok( hr == S_OK, "got %#lx\n", hr );
4830
4831 hr = IWinHttpRequest_SetCredentials( req, NULL, NULL, 0xdeadbeef );
4833
4836 VariantInit( &bypass_list );
4837 V_VT( &bypass_list ) = VT_ERROR;
4838 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
4839 ok( hr == S_OK, "got %#lx\n", hr );
4840
4841 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
4842 ok( hr == S_OK, "got %#lx\n", hr );
4843
4844 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
4845 ok( hr == S_OK, "got %#lx\n", hr );
4846
4847 hr = IWinHttpRequest_GetAllResponseHeaders( req, NULL );
4848 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4849
4850 hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
4852
4853 hr = IWinHttpRequest_GetResponseHeader( req, NULL, NULL );
4855
4856 connection = SysAllocString( L"Connection" );
4857 hr = IWinHttpRequest_GetResponseHeader( req, connection, NULL );
4859
4860 hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
4862
4863 hr = IWinHttpRequest_SetRequestHeader( req, NULL, NULL );
4864 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4865
4866 date = SysAllocString( L"Date" );
4867 hr = IWinHttpRequest_SetRequestHeader( req, date, NULL );
4869
4870 today = SysAllocString( todayW );
4871 hr = IWinHttpRequest_SetRequestHeader( req, date, today );
4873
4874 hr = IWinHttpRequest_SetAutoLogonPolicy( req, 0xdeadbeef );
4875 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4876
4877 hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
4878 ok( hr == S_OK, "got %#lx\n", hr );
4879
4881 method = SysAllocString( L"GET" );
4882 SysFreeString( url );
4883 url = SysAllocString( L"http://test.winehq.org" );
4884 hr = IWinHttpRequest_Open( req, method, url, async );
4885 ok( hr == S_OK, "got %#lx\n", hr );
4886
4887 hr = IWinHttpRequest_get_ResponseText( req, NULL );
4888 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4889
4890 hr = IWinHttpRequest_get_ResponseText( req, &response );
4892
4893 hr = IWinHttpRequest_get_Status( req, &status );
4895
4896 hr = IWinHttpRequest_get_StatusText( req, &status_text );
4898
4899 hr = IWinHttpRequest_get_ResponseBody( req, NULL );
4900 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4901
4902 hr = IWinHttpRequest_SetTimeouts( req, 10000, 10000, 10000, 10000 );
4903 ok( hr == S_OK, "got %#lx\n", hr );
4904
4905 hr = IWinHttpRequest_SetCredentials( req, NULL, NULL, 0xdeadbeef );
4906 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4907
4908 username = SysAllocString( L"username" );
4909 hr = IWinHttpRequest_SetCredentials( req, username, NULL, 0xdeadbeef );
4910 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4911
4912 password = SysAllocString( L"password" );
4913 hr = IWinHttpRequest_SetCredentials( req, NULL, password, 0xdeadbeef );
4914 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4915
4916 hr = IWinHttpRequest_SetCredentials( req, username, password, 0xdeadbeef );
4917 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4918
4919 hr = IWinHttpRequest_SetCredentials( req, NULL, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
4920 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4921
4922 hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
4923 ok( hr == S_OK, "got %#lx\n", hr );
4924
4925 V_VT( &flags ) = VT_I4;
4927 hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, flags );
4928 ok( hr == S_OK, "got %#lx\n", hr );
4929
4931 V_BSTR( &proxy_server ) = SysAllocString( L"proxyserver" );
4932 V_VT( &bypass_list ) = VT_BSTR;
4933 V_BSTR( &bypass_list ) = SysAllocString( L"bypasslist" );
4934 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
4935 ok( hr == S_OK, "got %#lx\n", hr );
4936
4937 hr = IWinHttpRequest_SetProxy( req, 0xdeadbeef, proxy_server, bypass_list );
4938 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4939
4940 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
4941 ok( hr == S_OK, "got %#lx\n", hr );
4942
4943 hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
4945
4946 hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
4948
4949 hr = IWinHttpRequest_SetRequestHeader( req, date, today );
4950 ok( hr == S_OK, "got %#lx\n", hr );
4951
4952 hr = IWinHttpRequest_SetRequestHeader( req, date, NULL );
4953 ok( hr == S_OK, "got %#lx\n", hr );
4954
4955 hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
4956 ok( hr == S_OK, "got %#lx\n", hr );
4957
4958 hr = IWinHttpRequest_Send( req, empty );
4959 ok( hr == S_OK, "got %#lx\n", hr );
4960
4961 hr = IWinHttpRequest_Send( req, empty );
4962 ok( hr == S_OK, "got %#lx\n", hr );
4963
4964 V_VT( &flags ) = VT_ERROR;
4965 V_ERROR( &flags ) = 0xdeadbeef;
4966 hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_SslErrorIgnoreFlags, &flags );
4967 ok( hr == S_OK, "got %#lx\n", hr );
4969
4970 hr = IWinHttpRequest_get_ResponseText( req, NULL );
4971 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4972
4973 hr = IWinHttpRequest_get_ResponseText( req, &response );
4974 ok( hr == S_OK, "got %#lx\n", hr );
4975 ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", wine_dbgstr_wn(response, 32) );
4976 SysFreeString( response );
4977
4978 hr = IWinHttpRequest_get_Status( req, NULL );
4979 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4980
4981 status = 0;
4982 hr = IWinHttpRequest_get_Status( req, &status );
4983 ok( hr == S_OK, "got %#lx\n", hr );
4984 trace("Status = %lu\n", status);
4985
4986 hr = IWinHttpRequest_get_StatusText( req, NULL );
4987 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4988
4989 hr = IWinHttpRequest_get_StatusText( req, &status_text );
4990 ok( hr == S_OK, "got %#lx\n", hr );
4991 trace("StatusText=%s\n", wine_dbgstr_w(status_text));
4992 SysFreeString( status_text );
4993
4994 hr = IWinHttpRequest_get_ResponseBody( req, NULL );
4995 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
4996
4997 hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
4998 ok( hr == S_OK, "got %#lx\n", hr );
4999
5000 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
5001 ok( hr == S_OK, "got %#lx\n", hr );
5002
5003 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
5004 ok( hr == S_OK, "got %#lx\n", hr );
5005
5006 hr = IWinHttpRequest_GetAllResponseHeaders( req, NULL );
5007 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
5008
5009 hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
5010 ok( hr == S_OK, "got %#lx\n", hr );
5012
5013 hr = IWinHttpRequest_GetResponseHeader( req, NULL, NULL );
5014 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
5015
5016 hr = IWinHttpRequest_GetResponseHeader( req, connection, NULL );
5017 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
5018
5019 hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
5020 ok( hr == S_OK, "got %#lx\n", hr );
5022
5023 hr = IWinHttpRequest_SetRequestHeader( req, date, today );
5025
5026 hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
5027 ok( hr == S_OK, "got %#lx\n", hr );
5028
5029 VariantInit( &timeout );
5030 V_VT( &timeout ) = VT_I4;
5031 V_I4( &timeout ) = 10;
5032 hr = IWinHttpRequest_WaitForResponse( req, timeout, &succeeded );
5033 ok( hr == S_OK, "got %#lx\n", hr );
5034
5035 hr = IWinHttpRequest_get_Status( req, &status );
5036 ok( hr == S_OK, "got %#lx\n", hr );
5037
5038 hr = IWinHttpRequest_get_StatusText( req, &status_text );
5039 ok( hr == S_OK, "got %#lx\n", hr );
5040 SysFreeString( status_text );
5041
5042 hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
5043 ok( hr == S_OK, "got %#lx\n", hr );
5044
5045 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
5046 ok( hr == S_OK, "got %#lx\n", hr );
5047
5048 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
5049 ok( hr == S_OK, "got %#lx\n", hr );
5050
5051 hr = IWinHttpRequest_Send( req, empty );
5052 ok( hr == S_OK, "got %#lx\n", hr );
5053
5054 hr = IWinHttpRequest_get_ResponseText( req, NULL );
5055 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
5056
5057 hr = IWinHttpRequest_get_ResponseText( req, &response );
5058 ok( hr == S_OK, "got %#lx\n", hr );
5059 SysFreeString( response );
5060
5061 hr = IWinHttpRequest_get_ResponseBody( req, NULL );
5062 ok( hr == E_INVALIDARG, "got %#lx\n", hr );
5063
5064 VariantInit( &body );
5065 V_VT( &body ) = VT_ERROR;
5066 hr = IWinHttpRequest_get_ResponseBody( req, &body );
5067 ok( hr == S_OK, "got %#lx\n", hr );
5068 ok( V_VT( &body ) == (VT_ARRAY|VT_UI1), "got %#x\n", V_VT( &body ) );
5069
5070 hr = VariantClear( &body );
5071 ok( hr == S_OK, "got %#lx\n", hr );
5072
5073 VariantInit( &body );
5074 V_VT( &body ) = VT_ERROR;
5075 hr = IWinHttpRequest_get_ResponseStream( req, &body );
5076 ok( hr == S_OK, "got %#lx\n", hr );
5077 ok( V_VT( &body ) == VT_UNKNOWN, "got %#x\n", V_VT( &body ) );
5078
5079 hr = IUnknown_QueryInterface( V_UNKNOWN( &body ), &IID_IStream, (void **)&stream );
5080 ok( hr == S_OK, "got %#lx\n", hr );
5081 ok( V_UNKNOWN( &body ) == (IUnknown *)stream, "got different interface pointer\n" );
5082
5083 buf[0] = 0;
5084 count = 0xdeadbeef;
5085 hr = IStream_Read( stream, buf, 128, &count );
5086 ok( hr == S_OK, "got %#lx\n", hr );
5087 ok( count != 0xdeadbeef, "count not set\n" );
5088 ok( buf[0], "no data\n" );
5089
5090 VariantInit( &body2 );
5091 V_VT( &body2 ) = VT_ERROR;
5092 hr = IWinHttpRequest_get_ResponseStream( req, &body2 );
5093 ok( hr == S_OK, "got %#lx\n", hr );
5094 ok( V_VT( &body2 ) == VT_UNKNOWN, "got %#x\n", V_VT( &body2 ) );
5095 ok( V_UNKNOWN( &body ) != V_UNKNOWN( &body2 ), "got same interface pointer\n" );
5096
5097 hr = IUnknown_QueryInterface( V_UNKNOWN( &body2 ), &IID_IStream, (void **)&stream2 );
5098 ok( hr == S_OK, "got %#lx\n", hr );
5099 ok( V_UNKNOWN( &body2 ) == (IUnknown *)stream2, "got different interface pointer\n" );
5100 IStream_Release( stream2 );
5101
5102 hr = VariantClear( &body );
5103 ok( hr == S_OK, "got %#lx\n", hr );
5104
5105 hr = VariantClear( &body2 );
5106 ok( hr == S_OK, "got %#lx\n", hr );
5107
5108 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
5109 ok( hr == S_OK, "got %#lx\n", hr );
5110
5111 hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
5112 ok( hr == S_OK, "got %#lx\n", hr );
5113
5114 hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
5115 ok( hr == S_OK, "got %#lx\n", hr );
5117
5118 hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
5119 ok( hr == S_OK, "got %#lx\n", hr );
5121
5122 hr = IWinHttpRequest_SetRequestHeader( req, date, today );
5124
5125 hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
5126 ok( hr == S_OK, "got %#lx\n", hr );
5127
5128 hr = IWinHttpRequest_Send( req, empty );
5129 ok( hr == S_OK, "got %#lx\n", hr );
5130
5131 hr = IWinHttpRequest_Abort( req );
5132 ok( hr == S_OK, "got %#lx\n", hr );
5133
5134 hr = IWinHttpRequest_Abort( req );
5135 ok( hr == S_OK, "got %#lx\n", hr );
5136
5137 IWinHttpRequest_Release( req );
5138
5139 pos.QuadPart = 0;
5140 hr = IStream_Seek( stream, pos, STREAM_SEEK_SET, NULL );
5141 ok( hr == S_OK, "got %#lx\n", hr );
5142
5143 buf[0] = 0;
5144 count = 0xdeadbeef;
5145 hr = IStream_Read( stream, buf, 128, &count );
5146 ok( hr == S_OK, "got %#lx\n", hr );
5147 ok( count != 0xdeadbeef, "count not set\n" );
5148 ok( buf[0], "no data\n" );
5149 IStream_Release( stream );
5150
5151 hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
5152 ok( hr == S_OK, "got %#lx\n", hr );
5153
5154 V_VT( &async ) = VT_I4;
5155 V_I4( &async ) = 1;
5156 hr = IWinHttpRequest_Open( req, method, url, async );
5157 ok( hr == S_OK, "got %#lx\n", hr );
5158
5159 hr = IWinHttpRequest_Send( req, empty );
5160 ok( hr == S_OK, "got %#lx\n", hr );
5161
5162 hr = IWinHttpRequest_WaitForResponse( req, timeout, &succeeded );
5163 ok( hr == S_OK, "got %#lx\n", hr );
5164
5165 IWinHttpRequest_Release( req );
5166
5168 SysFreeString( url );
5171 SysFreeString( connection );
5173 SysFreeString( today );
5175 VariantClear( &bypass_list );
5176
5177 hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
5178 ok( hr == S_OK, "got %#lx\n", hr );
5179
5180 url = SysAllocString( L"https://test.winehq.org:443" );
5181 method = SysAllocString( L"POST" );
5182 V_VT( &async ) = VT_BOOL;
5183 V_BOOL( &async ) = VARIANT_FALSE;
5184 hr = IWinHttpRequest_Open( req, method, url, async );
5185 ok( hr == S_OK, "got %#lx\n", hr );
5187 SysFreeString( url );
5188
5189 hr = IWinHttpRequest_Send( req, empty );
5190 ok( hr == S_OK ||
5192 hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_SECURE_CHANNEL_ERROR ) /* win7 */, "got %#lx\n", hr );
5193 if (hr != S_OK) goto done;
5194
5195 hr = IWinHttpRequest_get_ResponseText( req, &response );
5196 ok( hr == S_OK, "got %#lx\n", hr );
5197#ifdef __REACTOS__
5198 ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n",
5199 wine_dbgstr_wn(response, min(SysStringLen(response), 32)) );
5200#else
5201 ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", wine_dbgstr_wn(response, 32) );
5202#endif
5203 SysFreeString( response );
5204
5205 IWinHttpRequest_Release( req );
5206
5207 hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
5208 ok( hr == S_OK, "got %#lx\n", hr );
5209
5210 sprintf( buf, "http://localhost:%d/auth", port );
5211 MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, ARRAY_SIZE( bufW ));
5212 url = SysAllocString( bufW );
5213 method = SysAllocString( L"POST" );
5214 V_VT( &async ) = VT_BOOL;
5215 V_BOOL( &async ) = VARIANT_FALSE;
5216 hr = IWinHttpRequest_Open( req, method, url, async );
5217 ok( hr == S_OK, "got %#lx\n", hr );
5219 SysFreeString( url );
5220
5221 hr = IWinHttpRequest_get_Status( req, &status );
5223
5224 V_VT( &data ) = VT_BSTR;
5225 V_BSTR( &data ) = SysAllocString( L"testdata\x80" );
5226 hr = IWinHttpRequest_Send( req, data );
5227 ok( hr == S_OK, "got %#lx\n", hr );
5228 SysFreeString( V_BSTR( &data ) );
5229
5230 hr = IWinHttpRequest_get_ResponseText( req, &response );
5231 ok( hr == S_OK, "got %#lx\n", hr );
5232 ok( !memcmp( response, L"Unauthorized", sizeof(L"Unauthorized") ), "got %s\n", wine_dbgstr_w(response) );
5233 SysFreeString( response );
5234
5235 status = 0xdeadbeef;
5236 hr = IWinHttpRequest_get_Status( req, &status );
5237 ok( hr == S_OK, "got %#lx\n", hr );
5238 ok( status == HTTP_STATUS_DENIED, "got %lu\n", status );
5239
5240done:
5241 IWinHttpRequest_Release( req );
5243}
5244
5245static void request_get_property(IWinHttpRequest *request, int property, VARIANT *ret)
5246{
5247 DISPPARAMS params;
5248 VARIANT arg;
5249 HRESULT hr;
5250
5251 memset(&params, 0, sizeof(params));
5252 params.cNamedArgs = 0;
5253 params.rgdispidNamedArgs = NULL;
5254 params.cArgs = 1;
5255 params.rgvarg = &arg;
5256 VariantInit(&arg);
5257 V_VT(&arg) = VT_I4;
5258 V_I4(&arg) = property;
5260 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
5262 ok(hr == S_OK, "error %#lx\n", hr);
5263}
5264
5266{
5267 WCHAR openW[] = {'O','p','e','n',0};
5268 WCHAR optionW[] = {'O','p','t','i','o','n',0};
5269 OLECHAR *open = openW, *option = optionW;
5270 BSTR utf8;
5271 CLSID clsid;
5272 IWinHttpRequest *request;
5274 DISPID id;
5275 DISPPARAMS params;
5276 VARIANT arg[3], ret;
5277 UINT err;
5278 BOOL bret;
5279 HRESULT hr;
5280
5282
5283 hr = CLSIDFromProgID(L"WinHttp.WinHttpRequest.5.1", &clsid);
5284 ok(hr == S_OK, "CLSIDFromProgID error %#lx\n", hr);
5285 bret = IsEqualIID(&clsid, &CLSID_WinHttpRequest);
5286 ok(bret || broken(!bret) /* win2003 */, "not expected %s\n", wine_dbgstr_guid(&clsid));
5287
5288 hr = CoCreateInstance(&CLSID_WinHttpRequest, 0, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&request);
5289 ok(hr == S_OK, "error %#lx\n", hr);
5290
5291 hr = IWinHttpRequest_QueryInterface(request, &IID_IDispatch, (void **)&dispatch);
5292 ok(hr == S_OK, "error %#lx\n", hr);
5293 IDispatch_Release(dispatch);
5294
5295 hr = IWinHttpRequest_GetIDsOfNames(request, &IID_NULL, &open, 1, 0x0409, &id);
5296 ok(hr == S_OK, "error %#lx\n", hr);
5297 ok(id == DISPID_HTTPREQUEST_OPEN, "expected DISPID_HTTPREQUEST_OPEN, got %lu\n", id);
5298
5299 hr = IWinHttpRequest_GetIDsOfNames(request, &IID_NULL, &option, 1, 0x0409, &id);
5300 ok(hr == S_OK, "error %#lx\n", hr);
5301 ok(id == DISPID_HTTPREQUEST_OPTION, "expected DISPID_HTTPREQUEST_OPTION, got %lu\n", id);
5302
5303 request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
5304 ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %#x\n", V_VT(&ret));
5305 ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %ld\n", V_I4(&ret));
5306
5307 memset(&params, 0, sizeof(params));
5308 params.cArgs = 2;
5309 params.cNamedArgs = 0;
5310 params.rgvarg = arg;
5311 V_VT(&arg[0]) = VT_I4;
5312 V_I4(&arg[0]) = 1252;
5313 V_VT(&arg[1]) = VT_R8;
5314 V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
5315 VariantInit(&ret);
5316 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
5318 ok(hr == S_OK, "error %#lx\n", hr);
5319
5320 request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
5321 ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %#x\n", V_VT(&ret));
5322 ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %ld\n", V_I4(&ret));
5323
5324 memset(&params, 0, sizeof(params));
5325 params.cArgs = 2;
5326 params.cNamedArgs = 0;
5327 params.rgvarg = arg;
5328 V_VT(&arg[0]) = VT_I4;
5329 V_I4(&arg[0]) = 1252;
5330 V_VT(&arg[1]) = VT_R8;
5331 V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
5332 VariantInit(&ret);
5333 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
5335 ok(hr == S_OK, "error %#lx\n", hr);
5336
5337 request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
5338 ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %#x\n", V_VT(&ret));
5339 ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %ld\n", V_I4(&ret));
5340
5341 memset(&params, 0, sizeof(params));
5342 params.cArgs = 2;
5343 params.cNamedArgs = 0;
5344 params.rgvarg = arg;
5345 V_VT(&arg[0]) = VT_I4;
5346 V_I4(&arg[0]) = 1252;
5347 V_VT(&arg[1]) = VT_R8;
5348 V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
5349 VariantInit(&ret);
5350 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
5352 ok(hr == S_OK, "error %#lx\n", hr);
5353
5354 request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
5355 ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %#x\n", V_VT(&ret));
5356 ok(V_I4(&ret) == 1252, "expected 1252, got %ld\n", V_I4(&ret));
5357
5358 memset(&params, 0, sizeof(params));
5359 params.cArgs = 2;
5360 params.cNamedArgs = 0;
5361 params.rgvarg = arg;
5362 V_VT(&arg[0]) = VT_BSTR;
5363 utf8 = SysAllocString(L"UTF-8");
5364 V_BSTR(&arg[0]) = utf8;
5365 V_VT(&arg[1]) = VT_R8;
5366 V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
5367 hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, &err);
5368 ok(hr == S_OK, "error %#lx\n", hr);
5369
5370 request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
5371 ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %#x\n", V_VT(&ret));
5372 ok(V_I4(&ret) == 1252, "expected 1252, got %ld\n", V_I4(&ret));
5373
5374 VariantInit(&ret);
5375 hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, &params, &ret, NULL, &err);
5376 ok(hr == S_OK, "error %#lx\n", hr);
5377
5378 request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
5379 ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %#x\n", V_VT(&ret));
5380 ok(V_I4(&ret) == 1252, "expected 1252, got %ld\n", V_I4(&ret));
5381
5382 VariantInit(&ret);
5383 hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
5384 ok(hr == S_OK, "error %#lx\n", hr);
5385
5386 request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
5387 ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %#x\n", V_VT(&ret));
5388 ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %ld\n", V_I4(&ret));
5389
5391 ok(hr == S_OK, "error %#lx\n", hr);
5392
5393 hr = IWinHttpRequest_Invoke(request, 255, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, NULL, NULL, NULL);
5394 ok(hr == DISP_E_MEMBERNOTFOUND, "error %#lx\n", hr);
5395
5396 VariantInit(&ret);
5397 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_IUnknown, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
5398 ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#lx\n", hr);
5399
5400 VariantInit(&ret);
5401 if (0) /* crashes */
5402 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, &ret, NULL, &err);
5403
5404 params.cArgs = 1;
5405 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
5406 ok(hr == DISP_E_TYPEMISMATCH, "error %#lx\n", hr);
5407
5408 VariantInit(&arg[2]);
5409 params.cArgs = 3;
5410 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
5411 todo_wine
5412 ok(hr == S_OK, "error %#lx\n", hr);
5413
5414 VariantInit(&arg[0]);
5415 VariantInit(&arg[1]);
5416 VariantInit(&arg[2]);
5417
5418 params.cArgs = 1;
5419 V_VT(&arg[0]) = VT_I4;
5420 V_I4(&arg[0]) = WinHttpRequestOption_URLCodePage;
5422 ok(hr == S_OK, "error %#lx\n", hr);
5423
5424 V_VT(&ret) = 0xdead;
5425 V_I4(&ret) = 0xbeef;
5427 ok(hr == S_OK, "error %#lx\n", hr);
5428 ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %#x\n", V_VT(&ret));
5429 ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %ld\n", V_I4(&ret));
5430
5431 V_VT(&ret) = 0xdead;
5432 V_I4(&ret) = 0xbeef;
5433 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD, &params, &ret, NULL, NULL);
5434 ok(hr == S_OK, "error %#lx\n", hr);
5435 ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %#x\n", V_VT(&ret));
5436 ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %ld\n", V_I4(&ret));
5437
5439 ok(hr == S_OK, "error %#lx\n", hr);
5440
5441 V_VT(&ret) = 0xdead;
5442 V_I4(&ret) = 0xbeef;
5443 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0, &params, &ret, NULL, NULL);
5444 ok(hr == S_OK, "error %#lx\n", hr);
5445 ok(V_VT(&ret) == VT_EMPTY, "expected VT_EMPTY, got %#x\n", V_VT(&ret));
5446 ok(V_I4(&ret) == 0xbeef || V_I4(&ret) == 0 /* Win8 */, "expected 0xdead, got %ld\n", V_I4(&ret));
5447
5448 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0, &params, NULL, NULL, NULL);
5449 ok(hr == S_OK, "error %#lx\n", hr);
5450
5452 ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#lx\n", hr);
5453
5454 params.cArgs = 2;
5456 todo_wine
5457 ok(hr == S_OK, "error %#lx\n", hr);
5458
5459 params.cArgs = 0;
5461 ok(hr == DISP_E_PARAMNOTFOUND, "error %#lx\n", hr);
5462
5464
5465 params.cArgs = 1;
5466 V_VT(&arg[0]) = VT_I4;
5467 V_I4(&arg[0]) = AutoLogonPolicy_Never;
5468 VariantInit(&ret);
5469 hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_SETAUTOLOGONPOLICY, &IID_NULL, 0,
5471 ok(hr == S_OK, "error %#lx\n", hr);
5472
5473 IWinHttpRequest_Release(request);
5474
5476}
5477
5479{
5480 BOOL ret;
5481 WCHAR *url;
5482 DWORD error;
5483
5484 SetLastError(0xdeadbeef);
5486 error = GetLastError();
5487 ok( !ret, "expected failure\n" );
5488 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5489
5490 url = NULL;
5491 SetLastError(0xdeadbeef);
5493 error = GetLastError();
5494 ok( !ret, "expected failure\n" );
5495 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5496
5497 SetLastError(0xdeadbeef);
5499 error = GetLastError();
5500 ok( !ret, "expected failure\n" );
5501 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5502
5503 url = (WCHAR *)0xdeadbeef;
5504 SetLastError(0xdeadbeef);
5506 error = GetLastError();
5507 if (!ret)
5508 {
5510 ok( !url || broken(url == (WCHAR *)0xdeadbeef), "got %p\n", url );
5511 }
5512 else
5513 {
5514 trace("%s\n", wine_dbgstr_w(url));
5515 GlobalFree( url );
5516 }
5517
5518 url = (WCHAR *)0xdeadbeef;
5519 SetLastError(0xdeadbeef);
5521 error = GetLastError();
5522 if (!ret)
5523 {
5525 ok( !url || broken(url == (WCHAR *)0xdeadbeef), "got %p\n", url );
5526 }
5527 else
5528 {
5529 ok( error == ERROR_SUCCESS, "got %lu\n", error );
5530 trace("%s\n", wine_dbgstr_w(url));
5531 GlobalFree( url );
5532 }
5533}
5534
5536{
5537 BOOL ret;
5538 DWORD error;
5540
5541 memset( &cfg, 0, sizeof(cfg) );
5542
5543 SetLastError(0xdeadbeef);
5545 error = GetLastError();
5546 ok( !ret, "expected failure\n" );
5547 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5548
5549 SetLastError(0xdeadbeef);
5551 error = GetLastError();
5552 ok( ret, "expected success\n" );
5553 ok( error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* < win7 */, "got %lu\n", error );
5554
5555 trace("IEProxy.AutoDetect=%d\n", cfg.fAutoDetect);
5556 trace("IEProxy.AutoConfigUrl=%s\n", wine_dbgstr_w(cfg.lpszAutoConfigUrl));
5557 trace("IEProxy.Proxy=%s\n", wine_dbgstr_w(cfg.lpszProxy));
5558 trace("IEProxy.ProxyBypass=%s\n", wine_dbgstr_w(cfg.lpszProxyBypass));
5560 GlobalFree( cfg.lpszProxy );
5562}
5563
5565{
5566 WCHAR pac_url[64];
5567 BOOL ret, old_winhttp = FALSE;
5568 DWORD error;
5572
5573 memset( &options, 0, sizeof(options) );
5574
5575 SetLastError(0xdeadbeef);
5577 error = GetLastError();
5578 ok( !ret, "expected failure\n" );
5579 ok( error == ERROR_INVALID_HANDLE, "got %lu\n", error );
5580
5581 session = WinHttpOpen( L"winetest", 0, NULL, NULL, 0 );
5582 ok( session != NULL, "failed to open session %lu\n", GetLastError() );
5583
5584 SetLastError(0xdeadbeef);
5586 error = GetLastError();
5587 ok( !ret, "expected failure\n" );
5588 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5589
5590 SetLastError(0xdeadbeef);
5592 error = GetLastError();
5593 ok( !ret, "expected failure\n" );
5594 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5595
5596 SetLastError(0xdeadbeef);
5597 ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", NULL, NULL );
5598 error = GetLastError();
5599 ok( !ret, "expected failure\n" );
5600 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5601
5602 SetLastError(0xdeadbeef);
5603 ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
5604 error = GetLastError();
5605 ok( !ret, "expected failure\n" );
5606 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5607
5609 options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DNS_A;
5610
5611 SetLastError(0xdeadbeef);
5612 ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, NULL );
5613 error = GetLastError();
5614 ok( !ret, "expected failure\n" );
5615 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5616
5618 options.dwAutoDetectFlags = 0;
5619
5620 SetLastError(0xdeadbeef);
5621 ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
5622 error = GetLastError();
5623 ok( !ret, "expected failure\n" );
5624 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5625
5627 options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DNS_A;
5628
5629 SetLastError(0xdeadbeef);
5630 ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
5631 error = GetLastError();
5632 ok( !ret, "expected failure\n" );
5633 ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
5634
5636 options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DNS_A;
5637
5638 memset( &info, 0, sizeof(info) );
5639 SetLastError(0xdeadbeef);
5640 ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
5641 error = GetLastError();
5642 if (ret)
5643 {
5644 ok( error == ERROR_SUCCESS, "got %lu\n", error );
5645 trace("Proxy.AccessType=%lu\n", info.dwAccessType);
5646 trace("Proxy.Proxy=%s\n", wine_dbgstr_w(info.lpszProxy));
5647 trace("Proxy.ProxyBypass=%s\n", wine_dbgstr_w(info.lpszProxyBypass));
5648 GlobalFree( info.lpszProxy );
5649 GlobalFree( info.lpszProxyBypass );
5650
5651 ret = WinHttpGetProxyForUrl( session, L"http:", &options, &info );
5652 ok( !ret, "expected failure\n" );
5653 }
5654
5656 options.dwAutoDetectFlags = 0;
5657 options.lpszAutoConfigUrl = L"http://wpad/wpad.dat";
5658
5659 memset( &info, 0, sizeof(info) );
5660 ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
5661 if (ret)
5662 {
5663 trace("Proxy.AccessType=%lu\n", info.dwAccessType);
5664 trace("Proxy.Proxy=%s\n", wine_dbgstr_w(info.lpszProxy));
5665 trace("Proxy.ProxyBypass=%s\n", wine_dbgstr_w(info.lpszProxyBypass));
5666 GlobalFree( info.lpszProxy );
5667 GlobalFree( info.lpszProxyBypass );
5668 }
5669
5672 options.lpszAutoConfigUrl = L"http://wpad/wpad.dat";
5673
5674 SetLastError(0xdeadbeef);
5675 memset( &info, 0, sizeof(info) );
5676 ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
5677 error = GetLastError();
5678 ok( error != ERROR_INVALID_PARAMETER, "got ERROR_INVALID_PARAMETER\n" );
5679 if (ret)
5680 {
5681 GlobalFree( info.lpszProxy );
5682 GlobalFree( info.lpszProxyBypass );
5683 }
5684
5687
5688 ret = WinHttpGetProxyForUrl( session, L"http:", &options, &info );
5689 ok( !ret, "expected failure\n" );
5690
5691 swprintf(pac_url, ARRAY_SIZE(pac_url), L"http://localhost:%d/proxy.pac?ver=1", port);
5693 options.dwAutoDetectFlags = 0;
5694 options.lpszAutoConfigUrl = pac_url;
5695
5696 ret = WinHttpGetProxyForUrl( session, L"HTTP://WINEHQ.ORG/Test.html", &options, &info);
5697 if (!ret)
5698 {
5699 old_winhttp = TRUE;
5700 options.dwFlags &= ~WINHTTP_AUTOPROXY_NO_CACHE_SVC;
5701 ret = WinHttpGetProxyForUrl( session, L"HTTP://WINEHQ.ORG/Test.html", &options, &info);
5702 }
5703 ok(ret, "expected success\n" );
5704 ok(info.dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY,
5705 "info.dwAccessType = %lu\n", info.dwAccessType);
5706 ok(!wcscmp(info.lpszProxy, L"http___WINEHQ.ORG_Test.html_WINEHQ.ORG:8080") ||
5707 broken(old_winhttp && !wcscmp(info.lpszProxy, L"HTTP___WINEHQ.ORG_Test.html_WINEHQ.ORG:8080")),
5708 "info.Proxy = %s\n", wine_dbgstr_w(info.lpszProxy));
5709 ok(!info.lpszProxyBypass, "info.ProxyBypass = %s\n",
5710 wine_dbgstr_w(info.lpszProxyBypass));
5711 GlobalFree( info.lpszProxy );
5712
5714
5715 ret = WinHttpGetProxyForUrl( session, L"HTTP://WINEHQ.ORG/Test.html", &options, &info);
5716 ok(ret, "expected success\n" );
5717 ok(info.dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY,
5718 "info.dwAccessType = %lu\n", info.dwAccessType);
5719 ok(!wcscmp(info.lpszProxy, L"http___winehq.org_Test.html_winehq.org:8080") ||
5720 broken(old_winhttp && !wcscmp(info.lpszProxy, L"HTTP___winehq.org_Test.html_winehq.org:8080")),
5721 "info.Proxy = %s\n", wine_dbgstr_w(info.lpszProxy));
5722 ok(!info.lpszProxyBypass, "info.ProxyBypass = %s\n",
5723 wine_dbgstr_w(info.lpszProxyBypass));
5724 GlobalFree( info.lpszProxy );
5725
5726 if (!old_winhttp)
5727 {
5729
5730 ret = WinHttpGetProxyForUrl( session, L"HTTP://WINEHQ.ORG/Test.html", &options, &info);
5731 ok(ret, "expected success\n" );
5732 ok(info.dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY,
5733 "info.dwAccessType = %lu\n", info.dwAccessType);
5734 ok(!wcscmp(info.lpszProxy, L"http___WINEHQ.ORG_Test.html_WINEHQ.ORG:8080"),
5735 "info.Proxy = %s\n", wine_dbgstr_w(info.lpszProxy));
5736 ok(!info.lpszProxyBypass, "info.ProxyBypass = %s\n",
5737 wine_dbgstr_w(info.lpszProxyBypass));
5738 GlobalFree( info.lpszProxy );
5739 }
5740
5742}
5743
5744static void test_chunked_read(void)
5745{
5746 WCHAR header[32];
5747 DWORD len, err;
5748 HINTERNET ses, con = NULL, req = NULL;
5749 BOOL ret;
5750
5751 trace( "starting chunked read test\n" );
5752
5753 ses = WinHttpOpen( L"winetest", 0, NULL, NULL, 0 );
5754 ok( ses != NULL, "WinHttpOpen failed with error %lu\n", GetLastError() );
5755 if (!ses) goto done;
5756
5757 con = WinHttpConnect( ses, L"test.winehq.org", 0, 0 );
5758 ok( con != NULL, "WinHttpConnect failed with error %lu\n", GetLastError() );
5759 if (!con) goto done;
5760
5761 req = WinHttpOpenRequest( con, NULL, L"/tests/chunked", NULL, NULL, NULL, 0 );
5762 ok( req != NULL, "WinHttpOpenRequest failed with error %lu\n", GetLastError() );
5763 if (!req) goto done;
5764
5765 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
5766 err = GetLastError();
5768 {
5769 skip("connection failed, skipping\n");
5770 goto done;
5771 }
5772 ok( ret, "WinHttpSendRequest failed with error %lu\n", GetLastError() );
5773 if (!ret) goto done;
5774
5776 ok( ret, "WinHttpReceiveResponse failed with error %lu\n", GetLastError() );
5777 if (!ret) goto done;
5778
5779 header[0] = 0;
5780 len = sizeof(header);
5782 ok( ret, "failed to get TRANSFER_ENCODING header with error %lu\n", GetLastError() );
5783 ok( !lstrcmpW( header, L"chunked" ), "wrong transfer encoding %s\n", wine_dbgstr_w(header) );
5784 trace( "transfer encoding: %s\n", wine_dbgstr_w(header) );
5785
5786 header[0] = 0;
5787 len = sizeof(header);
5788 SetLastError( 0xdeadbeef );
5790 ok( !ret, "unexpected CONTENT_LENGTH header %s\n", wine_dbgstr_w(header) );
5791 ok( GetLastError() == ERROR_WINHTTP_HEADER_NOT_FOUND, "wrong error %lu\n", GetLastError() );
5792
5793 trace( "entering query loop\n" );
5794 for (;;)
5795 {
5796 len = 0xdeadbeef;
5798 ok( ret, "WinHttpQueryDataAvailable failed with error %lu\n", GetLastError() );
5799 if (ret) ok( len != 0xdeadbeef, "WinHttpQueryDataAvailable return wrong length\n" );
5800 trace( "got %lu available\n", len );
5801 if (len)
5802 {
5803 DWORD bytes_read;
5804 char *buf = HeapAlloc( GetProcessHeap(), 0, len + 1 );
5805
5806 ret = WinHttpReadData( req, buf, len, &bytes_read );
5807 ok(ret, "WinHttpReadData failed: %lu\n", GetLastError());
5808
5809 buf[bytes_read] = 0;
5810 trace( "WinHttpReadData -> %d %lu\n", ret, bytes_read );
5811 ok( len == bytes_read, "only got %lu of %lu available\n", bytes_read, len );
5812 ok( buf[bytes_read - 1] == '\n', "received partial line '%s'\n", buf );
5813
5814 HeapFree( GetProcessHeap(), 0, buf );
5815 if (!bytes_read) break;
5816 }
5817 if (!len) break;
5818 }
5819 trace( "done\n" );
5820
5821done:
5822 if (req) WinHttpCloseHandle( req );
5823 if (con) WinHttpCloseHandle( con );
5824 if (ses) WinHttpCloseHandle( ses );
5825}
5826
5828{
5829 HINTERNET session, request, connection;
5830 DWORD max_redirects, err, size;
5831 WCHAR url[128];
5832 BOOL ret;
5833
5836 ok(session != NULL, "WinHttpOpen failed to open session.\n");
5837
5838 connection = WinHttpConnect (session, L"test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, 0);
5839 ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %lu\n", GetLastError());
5840
5841 /* Test with 2 redirects (page will try to redirect 3 times) */
5842 request = WinHttpOpenRequest(connection, L"GET", L"tests/redirecttest.php?max=3", NULL, WINHTTP_NO_REFERER,
5845 {
5846 skip("Network unreachable, skipping.\n");
5847 goto done;
5848 }
5849 ok(request != NULL, "WinHttpOpenRequest failed to open a request, error: %lu\n", GetLastError());
5850 if (!request) goto done;
5851
5852 max_redirects = 2;
5853 ret = WinHttpSetOption(request, WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS, &max_redirects, sizeof(max_redirects));
5854 ok(ret, "WinHttpSetOption failed: %lu\n", GetLastError());
5855
5857 err = GetLastError();
5859 {
5860 skip("connection failed, skipping\n");
5861 goto done;
5862 }
5863 ok(ret == TRUE, "WinHttpSendRequest failed: %lu\n", GetLastError());
5864
5865 url[0] = 0;
5866 size = sizeof(url);
5868 ok(ret, "got %lu\n", GetLastError());
5869 ok(!wcscmp(url, L"http://test.winehq.org/tests/redirecttest.php?max=3"), "got %s\n", wine_dbgstr_w(url));
5870
5871 SetLastError(0xdeadbeef);
5873 ok(!ret, "WinHttpReceiveResponse succeeded, expected failure\n");
5874 ok(GetLastError() == ERROR_WINHTTP_REDIRECT_FAILED, "Expected ERROR_WINHTTP_REDIRECT_FAILED, got %lu\n", GetLastError());
5875
5876 url[0] = 0;
5877 size = sizeof(url);
5879 ok(ret, "got %lu\n", GetLastError());
5880 ok(!wcscmp(url, L"http://test.winehq.org/tests/redirecttest.php?id=2&max=3") ||
5881 broken(!wcscmp(url, L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3")) /* < Win10 1809 */,
5882 "got %s\n", wine_dbgstr_w(url));
5883
5884 done:
5886 ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n", ret);
5887 ret = WinHttpCloseHandle(connection);
5888 ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret);
5890 ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n", ret);
5891}
5892
5893static const BYTE pfxdata[] =
5894{
5895 0x30, 0x82, 0x0b, 0x1d, 0x02, 0x01, 0x03, 0x30, 0x82, 0x0a, 0xe3, 0x06,
5896 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82,
5897 0x0a, 0xd4, 0x04, 0x82, 0x0a, 0xd0, 0x30, 0x82, 0x0a, 0xcc, 0x30, 0x82,
5898 0x05, 0x07, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07,
5899 0x06, 0xa0, 0x82, 0x04, 0xf8, 0x30, 0x82, 0x04, 0xf4, 0x02, 0x01, 0x00,
5900 0x30, 0x82, 0x04, 0xed, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
5901 0x01, 0x07, 0x01, 0x30, 0x1c, 0x06, 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7,
5902 0x0d, 0x01, 0x0c, 0x01, 0x06, 0x30, 0x0e, 0x04, 0x08, 0xac, 0x3e, 0x35,
5903 0xa8, 0xed, 0x0d, 0x50, 0x07, 0x02, 0x02, 0x08, 0x00, 0x80, 0x82, 0x04,
5904 0xc0, 0x5a, 0x62, 0x55, 0x25, 0xf6, 0x2c, 0xf1, 0x78, 0x6c, 0x63, 0x96,
5905 0x8a, 0xea, 0x04, 0x64, 0xb3, 0x99, 0x3b, 0x80, 0x50, 0x05, 0x37, 0x55,
5906 0xa3, 0x5e, 0x9f, 0x35, 0xc3, 0x3c, 0xdc, 0xf6, 0xc4, 0xc1, 0x39, 0xa2,
5907 0xd7, 0x50, 0xad, 0xf9, 0x29, 0x3c, 0x51, 0xea, 0x15, 0x20, 0x25, 0xd3,
5908 0x4d, 0x69, 0xdf, 0x10, 0xd8, 0x9d, 0x60, 0x78, 0x8a, 0x70, 0x44, 0x7f,
5909 0x01, 0x4f, 0x4a, 0xfa, 0xab, 0xfd, 0x46, 0x48, 0x96, 0x2b, 0x69, 0xfc,
5910 0x11, 0xf8, 0x3f, 0xd3, 0x79, 0x09, 0x75, 0x81, 0x47, 0xdf, 0xce, 0xfe,
5911 0x07, 0x2f, 0x0a, 0xd8, 0xac, 0x87, 0x14, 0x1f, 0x7b, 0x95, 0x70, 0xee,
5912 0x7e, 0x52, 0x90, 0x11, 0xd6, 0x69, 0xf4, 0xd5, 0x38, 0x85, 0xc9, 0xc1,
5913 0x07, 0x01, 0xe8, 0xbb, 0xfb, 0xe2, 0x08, 0xa8, 0xfa, 0xbf, 0xf0, 0x92,
5914 0x63, 0x1d, 0xbb, 0x2b, 0x45, 0x6f, 0xce, 0x97, 0x01, 0xd7, 0x95, 0xf0,
5915 0x9c, 0x9a, 0x6b, 0x73, 0x01, 0xbf, 0xf9, 0x3d, 0xc8, 0x2b, 0x86, 0x7a,
5916 0xd5, 0x65, 0x84, 0xd7, 0xff, 0xb2, 0xf9, 0x20, 0x52, 0x35, 0xc5, 0x60,
5917 0x33, 0x70, 0x1d, 0x2f, 0x26, 0x09, 0x1c, 0x22, 0x17, 0xd8, 0x08, 0x4e,
5918 0x69, 0x20, 0xe2, 0x71, 0xe4, 0x07, 0xb1, 0x48, 0x5f, 0x20, 0x08, 0x7a,
5919 0xbf, 0x65, 0x53, 0x23, 0x07, 0xf9, 0x6c, 0xde, 0x3e, 0x29, 0xbf, 0x6b,
5920 0xef, 0xbb, 0x6a, 0x5f, 0x79, 0xa1, 0x72, 0xa1, 0x10, 0x24, 0x80, 0xb4,
5921 0x44, 0xb8, 0xc9, 0xfc, 0xa3, 0x36, 0x7e, 0x23, 0x37, 0x58, 0xc6, 0x1e,
5922 0xe8, 0x42, 0x4d, 0xb5, 0xf5, 0x58, 0x93, 0x21, 0x38, 0xa2, 0xc4, 0xa9,
5923 0x01, 0x96, 0xf9, 0x61, 0xac, 0x55, 0xb3, 0x3d, 0xe4, 0x54, 0x8b, 0x6c,
5924 0xc3, 0x83, 0xff, 0x50, 0x87, 0x94, 0xe8, 0x35, 0x3c, 0x26, 0x0d, 0x20,
5925 0x8a, 0x25, 0x0e, 0xb6, 0x67, 0x78, 0x29, 0xc7, 0xbf, 0x76, 0x8e, 0x62,
5926 0x62, 0xc4, 0x50, 0xd6, 0xc5, 0x3c, 0xb4, 0x7a, 0x35, 0xbe, 0x53, 0x52,
5927 0xc4, 0xe4, 0x10, 0xb3, 0xe0, 0x73, 0xb0, 0xd1, 0xc1, 0x5a, 0x4f, 0x4e,
5928 0x64, 0x0d, 0x92, 0x51, 0x2d, 0x4d, 0xec, 0xb0, 0xc6, 0x40, 0x1b, 0x03,
5929 0x89, 0x7f, 0xc2, 0x2c, 0xe3, 0x2c, 0xbd, 0x8c, 0x9c, 0xd9, 0xe0, 0x08,
5930 0x59, 0xd3, 0xaf, 0x48, 0x56, 0x89, 0x60, 0x85, 0x76, 0xe0, 0xd8, 0x7c,
5931 0xcf, 0x02, 0x8f, 0xfd, 0xb2, 0x8f, 0x2b, 0x61, 0xcf, 0x28, 0x56, 0x8b,
5932 0x6b, 0x03, 0x2b, 0x2f, 0x83, 0x31, 0xa0, 0x1c, 0xd1, 0x6c, 0x87, 0x49,
5933 0xc4, 0x77, 0x55, 0x1f, 0x61, 0x45, 0x58, 0x88, 0x9f, 0x01, 0xc3, 0x63,
5934 0x62, 0x30, 0x35, 0xdf, 0x61, 0x74, 0x55, 0x63, 0x3f, 0xae, 0x41, 0xc1,
5935 0xb8, 0xf0, 0x9f, 0xab, 0x25, 0xad, 0x41, 0x5c, 0x1f, 0x00, 0x0d, 0xef,
5936 0xf0, 0xcf, 0xaf, 0x41, 0x23, 0xca, 0x8c, 0x38, 0xea, 0x5a, 0xe4, 0x8b,
5937 0xb4, 0x89, 0xd0, 0x76, 0x7f, 0x2b, 0x77, 0x8f, 0xe4, 0x44, 0xd5, 0x37,
5938 0xac, 0xc2, 0x09, 0x7e, 0x7e, 0x7e, 0x02, 0x5c, 0x27, 0x01, 0xcb, 0x4d,
5939 0xea, 0xb3, 0x97, 0x36, 0x35, 0xd2, 0x05, 0x3c, 0x4e, 0xb8, 0x04, 0x5c,
5940 0xb8, 0x95, 0x3f, 0xc6, 0xbf, 0xd4, 0x20, 0x01, 0xfb, 0xed, 0x37, 0x5a,
5941 0xad, 0x4c, 0x61, 0x93, 0xfe, 0x95, 0x7c, 0x34, 0x11, 0x15, 0x9d, 0x00,
5942 0x0b, 0x99, 0x69, 0xcb, 0x7e, 0xb9, 0x53, 0x46, 0x57, 0x39, 0x3f, 0x59,
5943 0x4b, 0x30, 0x8d, 0xfb, 0x84, 0x66, 0x2d, 0x06, 0xc9, 0x88, 0xa6, 0x18,
5944 0xd7, 0x36, 0xc6, 0xf6, 0xf7, 0x47, 0x85, 0x38, 0xc8, 0x3d, 0x37, 0xea,
5945 0x57, 0x4c, 0xb0, 0x7c, 0x95, 0x29, 0x84, 0xab, 0xbb, 0x19, 0x86, 0xc2,
5946 0xc5, 0x99, 0x01, 0x38, 0x6b, 0xf1, 0xd3, 0x1d, 0xa8, 0x02, 0xf9, 0x6f,
5947 0xaa, 0xf1, 0x57, 0xd0, 0x88, 0x68, 0x62, 0x5f, 0x9f, 0x7a, 0x63, 0xba,
5948 0x3a, 0xc9, 0x95, 0x11, 0x3c, 0xf9, 0xa1, 0xc1, 0x35, 0xfe, 0xd5, 0x12,
5949 0x49, 0x88, 0x0d, 0x5c, 0xe2, 0xd1, 0x15, 0x18, 0xfb, 0xd5, 0x7f, 0x19,
5950 0x3f, 0xaf, 0xa0, 0xcb, 0x31, 0x20, 0x9e, 0x03, 0x93, 0xa4, 0x66, 0xbd,
5951 0x83, 0xe8, 0x60, 0x34, 0x55, 0x0d, 0x97, 0x10, 0x23, 0x24, 0x7a, 0x45,
5952 0x36, 0xb4, 0xc4, 0xee, 0x60, 0x6f, 0xd8, 0x46, 0xc5, 0xac, 0x2b, 0xa9,
5953 0x18, 0x74, 0x83, 0x1e, 0xdf, 0x7c, 0x1a, 0x5a, 0xe8, 0x5f, 0x8b, 0x4f,
5954 0x9f, 0x40, 0x3e, 0x5e, 0xfb, 0xd3, 0x68, 0xac, 0x34, 0x62, 0x30, 0x23,
5955 0xb6, 0xbc, 0xdf, 0xbc, 0xc7, 0x25, 0xd2, 0x1b, 0x57, 0x33, 0xfb, 0x78,
5956 0x22, 0x21, 0x1e, 0x3a, 0xf6, 0x44, 0x18, 0x7e, 0x12, 0x36, 0x47, 0x58,
5957 0xd0, 0x59, 0x26, 0x98, 0x98, 0x95, 0xf4, 0xd1, 0xaa, 0x45, 0xaa, 0xe7,
5958 0xd1, 0xe6, 0x2d, 0x78, 0xf0, 0x8b, 0x1c, 0xfd, 0xf8, 0x50, 0x60, 0xa2,
5959 0x1e, 0x7f, 0xe3, 0x31, 0x77, 0x31, 0x58, 0x99, 0x0f, 0xda, 0x0e, 0xa3,
5960 0xc6, 0x7a, 0x30, 0x45, 0x55, 0x11, 0x91, 0x77, 0x41, 0x79, 0xd3, 0x56,
5961 0xb2, 0x07, 0x00, 0x61, 0xab, 0xec, 0x27, 0xc7, 0x9f, 0xfa, 0x89, 0x08,
5962 0xc2, 0x87, 0xcf, 0xe9, 0xdc, 0x9e, 0x29, 0x22, 0xfb, 0x23, 0x7f, 0x9d,
5963 0x89, 0xd5, 0x6e, 0x75, 0x20, 0xd8, 0x00, 0x5b, 0xc4, 0x94, 0xbb, 0xc5,
5964 0xb2, 0xba, 0x77, 0x2b, 0xf6, 0x3c, 0x88, 0xb0, 0x4c, 0x38, 0x46, 0x55,
5965 0xee, 0x8b, 0x03, 0x15, 0xbc, 0x0a, 0x1d, 0x47, 0x87, 0x44, 0xaf, 0xb1,
5966 0x2a, 0xa7, 0x4d, 0x08, 0xdf, 0x3b, 0x2d, 0x70, 0xa1, 0x67, 0x31, 0x76,
5967 0x6e, 0x6f, 0x40, 0x3b, 0x3b, 0xe8, 0xf9, 0xdf, 0x90, 0xa4, 0xce, 0x7f,
5968 0xb8, 0x2d, 0x69, 0xcb, 0x1c, 0x1e, 0x94, 0xcd, 0xb1, 0xd8, 0x43, 0x22,
5969 0xb8, 0x4f, 0x98, 0x92, 0x74, 0xb3, 0xde, 0xeb, 0x7a, 0xcb, 0xfa, 0xd0,
5970 0x36, 0xe4, 0x5d, 0xfa, 0xd3, 0xce, 0xf9, 0xba, 0x3e, 0x0f, 0x6c, 0xc3,
5971 0x5b, 0xb3, 0x81, 0x84, 0x6e, 0x5d, 0xc1, 0x21, 0x89, 0xec, 0x67, 0x9a,
5972 0xfd, 0x55, 0x20, 0xb0, 0x71, 0x53, 0xae, 0xf8, 0xa4, 0x8d, 0xd5, 0xe5,
5973 0x2d, 0x3a, 0xce, 0x89, 0x55, 0x8c, 0x4f, 0x3b, 0x37, 0x95, 0x4e, 0x15,
5974 0xbe, 0xe7, 0xd1, 0x7a, 0x36, 0x82, 0x45, 0x69, 0x7c, 0x27, 0x4f, 0xb9,
5975 0x4b, 0x7d, 0xcd, 0x59, 0xc8, 0xf4, 0x8b, 0x0f, 0x4f, 0x75, 0x23, 0xd3,
5976 0xd0, 0xc7, 0x10, 0x79, 0xc0, 0xf1, 0xac, 0x14, 0xf7, 0x0d, 0xc8, 0x5e,
5977 0xfc, 0xff, 0x1a, 0x2b, 0x10, 0x88, 0x7e, 0x7e, 0x2f, 0xfa, 0x7b, 0x9f,
5978 0x47, 0x23, 0x34, 0xfc, 0xf5, 0xde, 0xd9, 0xa3, 0x05, 0x99, 0x2a, 0x96,
5979 0x83, 0x3d, 0xa4, 0x7f, 0x6a, 0x66, 0x9b, 0xe7, 0xf1, 0x00, 0x4e, 0x9a,
5980 0xfc, 0x68, 0xd2, 0x74, 0x17, 0xba, 0xc9, 0xc8, 0x20, 0x39, 0xa1, 0xa8,
5981 0x85, 0xc6, 0x10, 0x2b, 0xab, 0x97, 0x34, 0x2d, 0x49, 0x68, 0x57, 0xb0,
5982 0x43, 0xee, 0x25, 0xbb, 0x35, 0x1b, 0x03, 0x99, 0xa3, 0x21, 0x68, 0x66,
5983 0x86, 0x3f, 0xc6, 0xfc, 0x49, 0xf0, 0xba, 0x5f, 0x00, 0xc6, 0xe3, 0x1c,
5984 0xb2, 0x9f, 0x16, 0x7f, 0xc7, 0x40, 0x4a, 0x9a, 0x39, 0xc1, 0x95, 0x69,
5985 0xa2, 0x87, 0xba, 0x58, 0xc6, 0xf2, 0xd6, 0x66, 0xa6, 0x4c, 0x6d, 0x29,
5986 0x9c, 0xa8, 0x6e, 0xa9, 0xd2, 0xe4, 0x54, 0x17, 0x89, 0xe2, 0x43, 0xf0,
5987 0xe1, 0x8b, 0x57, 0x84, 0x6c, 0x87, 0x63, 0x17, 0xbb, 0xf6, 0x33, 0x1b,
5988 0xe4, 0x34, 0x6a, 0x80, 0x70, 0x7b, 0x1b, 0xfd, 0xf8, 0x79, 0x28, 0xc8,
5989 0x3c, 0x8e, 0xa4, 0xd5, 0xb8, 0x96, 0x54, 0xd4, 0xec, 0x72, 0xe5, 0x40,
5990 0x8f, 0x56, 0xde, 0x82, 0x15, 0x72, 0x4d, 0xd8, 0x0c, 0x07, 0xea, 0xe6,
5991 0x44, 0xcd, 0x94, 0x73, 0x5c, 0x04, 0xe8, 0x8e, 0xb7, 0xc7, 0xc9, 0x29,
5992 0xdc, 0x04, 0xef, 0x7c, 0x31, 0x9b, 0x50, 0xbc, 0xea, 0x71, 0x1f, 0x28,
5993 0x22, 0xb6, 0x04, 0x53, 0x2e, 0x71, 0xc4, 0xf6, 0xbb, 0x88, 0x51, 0xee,
5994 0x3e, 0x76, 0x65, 0xb4, 0x4b, 0x1b, 0xa3, 0xec, 0x7b, 0xa7, 0x9d, 0x31,
5995 0x5d, 0xb8, 0x9f, 0xab, 0x6b, 0x54, 0x7d, 0xbd, 0xc1, 0x2c, 0x55, 0xb0,
5996 0x23, 0x8c, 0x06, 0x60, 0x01, 0x4f, 0x60, 0x85, 0x56, 0x7f, 0xfb, 0x99,
5997 0x0c, 0xdc, 0x8c, 0x09, 0x37, 0x46, 0x5b, 0x97, 0x5d, 0xe8, 0x31, 0x00,
5998 0x1b, 0x30, 0x9b, 0x02, 0x92, 0x29, 0xb5, 0x20, 0xce, 0x4b, 0x90, 0xfb,
5999 0x91, 0x07, 0x5a, 0xd3, 0xf5, 0xa0, 0xe6, 0x8f, 0xf8, 0x73, 0xc5, 0x4b,
6000 0xbb, 0xad, 0x2a, 0xeb, 0xa8, 0xb7, 0x68, 0x34, 0x36, 0x47, 0xd5, 0x4b,
6001 0x61, 0x89, 0x53, 0xe6, 0xb6, 0xb1, 0x07, 0xe4, 0x08, 0x2e, 0xed, 0x50,
6002 0xd4, 0x1e, 0xed, 0x7f, 0xbf, 0x35, 0x68, 0x04, 0x45, 0x72, 0x86, 0x71,
6003 0x15, 0x55, 0xdf, 0xe6, 0x30, 0xc0, 0x8b, 0x8a, 0xb0, 0x6c, 0xd0, 0x35,
6004 0x57, 0x8f, 0x04, 0x37, 0xbc, 0xe1, 0xb8, 0xbf, 0x27, 0x37, 0x3d, 0xd0,
6005 0xc8, 0x46, 0x67, 0x42, 0x51, 0x30, 0x82, 0x05, 0xbd, 0x06, 0x09, 0x2a,
6006 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, 0x05, 0xae,
6007 0x04, 0x82, 0x05, 0xaa, 0x30, 0x82, 0x05, 0xa6, 0x30, 0x82, 0x05, 0xa2,
6008 0x06, 0x0b, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x0a, 0x01,
6009 0x02, 0xa0, 0x82, 0x04, 0xee, 0x30, 0x82, 0x04, 0xea, 0x30, 0x1c, 0x06,
6010 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x01, 0x03, 0x30,
6011 0x0e, 0x04, 0x08, 0x9f, 0xa4, 0x72, 0x2b, 0x6b, 0x0e, 0xcb, 0x9f, 0x02,
6012 0x02, 0x08, 0x00, 0x04, 0x82, 0x04, 0xc8, 0xe5, 0x35, 0xb9, 0x72, 0x28,
6013 0x20, 0x28, 0xad, 0xe3, 0x01, 0xd7, 0x0b, 0xe0, 0x4e, 0x36, 0xc3, 0x73,
6014 0x06, 0xd5, 0xf6, 0x75, 0x1a, 0x78, 0xb2, 0xd8, 0xf6, 0x5a, 0x85, 0x8e,
6015 0x50, 0xa3, 0x05, 0x49, 0x02, 0x2d, 0xf8, 0xa3, 0x2f, 0xe6, 0x02, 0x7a,
6016 0xd5, 0x0b, 0x1d, 0xf1, 0xd1, 0xe4, 0x16, 0xaa, 0x70, 0x2e, 0x34, 0xdb,
6017 0x56, 0xd9, 0x33, 0x94, 0x11, 0xaa, 0x60, 0xd4, 0xfa, 0x5b, 0xd1, 0xb3,
6018 0x2e, 0x86, 0x6a, 0x5a, 0x69, 0xdf, 0x11, 0x91, 0xb0, 0xca, 0x82, 0xff,
6019 0x63, 0xad, 0x6a, 0x0b, 0x90, 0xa6, 0xc7, 0x9b, 0xef, 0x9a, 0xf8, 0x96,
6020 0xec, 0xe4, 0xc4, 0xdf, 0x55, 0x4c, 0x12, 0x07, 0xab, 0x7c, 0x5c, 0x68,
6021 0x47, 0xf2, 0x92, 0xfb, 0x94, 0xab, 0xc3, 0x64, 0xd3, 0xfe, 0xb2, 0x16,
6022 0xb4, 0x78, 0x80, 0x52, 0xe9, 0x32, 0x39, 0x3b, 0x8d, 0x12, 0x91, 0x36,
6023 0xfd, 0xa1, 0x97, 0xc2, 0x0a, 0x4a, 0xf1, 0xb3, 0x8a, 0xe4, 0x01, 0xed,
6024 0x0a, 0xda, 0x2e, 0xa0, 0x38, 0xa9, 0x47, 0x3d, 0x3a, 0x64, 0x87, 0x06,
6025 0xc3, 0x83, 0x60, 0xaf, 0x84, 0xdb, 0x87, 0xff, 0x70, 0x61, 0x43, 0x7d,
6026 0x2d, 0x61, 0x9a, 0xf7, 0x0d, 0xca, 0x0c, 0x0f, 0xbe, 0x43, 0x5b, 0x99,
6027 0xe1, 0x90, 0x64, 0x1f, 0xa7, 0x1b, 0xa6, 0xa6, 0x5c, 0x13, 0x70, 0xa3,
6028 0xdb, 0xd7, 0xf0, 0xe8, 0x7a, 0xb0, 0xd1, 0x9b, 0x52, 0xa6, 0x4f, 0xd6,
6029 0xff, 0x54, 0x4d, 0xa6, 0x15, 0x05, 0x5c, 0xe9, 0x04, 0x6a, 0xc3, 0x49,
6030 0x12, 0x2f, 0x24, 0x03, 0xc3, 0x80, 0x06, 0xa6, 0x07, 0x8b, 0x96, 0xe7,
6031 0x39, 0x31, 0x6d, 0xd3, 0x1b, 0xa5, 0x45, 0x58, 0x04, 0xe7, 0x87, 0xdf,
6032 0x26, 0xfb, 0x1b, 0x9f, 0x92, 0x93, 0x32, 0x12, 0x9a, 0xc9, 0xe6, 0xcb,
6033 0x88, 0x14, 0x9f, 0x23, 0x0b, 0x52, 0xa2, 0xb8, 0x32, 0x6c, 0xa9, 0x33,
6034 0xa1, 0x17, 0xe8, 0x4a, 0xd4, 0x5c, 0x7d, 0xb3, 0xa3, 0x64, 0x86, 0x03,
6035 0x7c, 0x7c, 0x3f, 0x99, 0xdc, 0x21, 0x9f, 0x93, 0xc6, 0xb9, 0x1d, 0xe0,
6036 0x21, 0x79, 0x78, 0x35, 0xdc, 0x1e, 0x27, 0x3c, 0x73, 0x7f, 0x0f, 0xd6,
6037 0x4f, 0xde, 0xe9, 0xb4, 0xb7, 0xe3, 0xf5, 0x72, 0xce, 0x42, 0xf3, 0x91,
6038 0x5b, 0x84, 0xba, 0xbb, 0xae, 0xf0, 0x87, 0x0f, 0x50, 0xa4, 0x5e, 0x80,
6039 0x23, 0x57, 0x2b, 0xa0, 0xa3, 0xc3, 0x8a, 0x2f, 0xa8, 0x7a, 0x1a, 0x65,
6040 0x8f, 0x62, 0xf8, 0x3e, 0xe2, 0xcd, 0xbc, 0x63, 0x56, 0x8e, 0x77, 0xf3,
6041 0xf9, 0x69, 0x10, 0x57, 0xa8, 0xaf, 0x67, 0x2a, 0x9f, 0x7f, 0x7e, 0xeb,
6042 0x1d, 0x99, 0xa6, 0x67, 0xcd, 0x9e, 0x42, 0x2e, 0x5e, 0x4e, 0x61, 0x24,
6043 0xfa, 0xca, 0x2a, 0xeb, 0x62, 0x1f, 0xa3, 0x14, 0x0a, 0x06, 0x4b, 0x77,
6044 0x78, 0x77, 0x9b, 0xf1, 0x03, 0xcc, 0xb5, 0xfe, 0xfb, 0x7a, 0x77, 0xa6,
6045 0x82, 0x9f, 0xe5, 0xde, 0x9d, 0x0d, 0x4d, 0x37, 0xc6, 0x12, 0x73, 0x6d,
6046 0xea, 0xbb, 0x48, 0xf0, 0xd2, 0x81, 0xcc, 0x1a, 0x47, 0xfa, 0xa4, 0xd2,
6047 0xb2, 0x27, 0xa0, 0xfc, 0x30, 0x04, 0xdb, 0x05, 0xd3, 0x0b, 0xbc, 0x4d,
6048 0x7a, 0x99, 0xef, 0x7f, 0x26, 0x01, 0xd4, 0x07, 0x0b, 0x1e, 0x99, 0x06,
6049 0x3c, 0xde, 0x3d, 0x1c, 0x21, 0x82, 0x68, 0x46, 0x35, 0x38, 0x61, 0xea,
6050 0xd4, 0xc2, 0x65, 0x09, 0x39, 0x87, 0xb4, 0xd3, 0x5d, 0x3c, 0xa3, 0x79,
6051 0xe4, 0x01, 0x4e, 0xbf, 0x18, 0xba, 0x57, 0x3f, 0xdd, 0xea, 0x0a, 0x6b,
6052 0x99, 0xfb, 0x93, 0xfa, 0xab, 0xee, 0x08, 0xdf, 0x38, 0x23, 0xae, 0x8d,
6053 0xa8, 0x03, 0x13, 0xfe, 0x83, 0x88, 0xb0, 0xc2, 0xf9, 0x90, 0xa5, 0x1c,
6054 0x01, 0x6f, 0x71, 0x91, 0x42, 0x35, 0x81, 0x74, 0x71, 0x6c, 0xba, 0x86,
6055 0x48, 0xfe, 0x96, 0xd2, 0x88, 0x12, 0x36, 0x4e, 0xa6, 0x2f, 0xd1, 0xdb,
6056 0xfa, 0xbf, 0xdb, 0x84, 0x01, 0xfc, 0x7d, 0x7a, 0xac, 0x20, 0xae, 0xf5,
6057 0x95, 0xc9, 0xdc, 0x10, 0x5f, 0x4c, 0xae, 0x85, 0x01, 0x8b, 0xfe, 0x77,
6058 0x13, 0x01, 0xae, 0x39, 0x59, 0x7e, 0xbc, 0xfd, 0xc9, 0x42, 0xe4, 0x13,
6059 0x07, 0x3f, 0xa9, 0x74, 0xd9, 0xd5, 0xfc, 0xb9, 0x78, 0xbe, 0x97, 0xf5,
6060 0xe7, 0x36, 0x7f, 0xfa, 0x23, 0x30, 0xeb, 0xab, 0x92, 0xd3, 0xdc, 0x3f,
6061 0x7f, 0xc0, 0x77, 0x93, 0xf9, 0x88, 0xe3, 0x4e, 0x13, 0x53, 0x6d, 0x71,
6062 0x87, 0xe9, 0x24, 0x2b, 0xae, 0x26, 0xbf, 0x62, 0x51, 0x04, 0x42, 0xe1,
6063 0x13, 0x9d, 0xd8, 0x9f, 0x59, 0x87, 0x3f, 0xfc, 0x94, 0xff, 0xcf, 0x88,
6064 0x88, 0xe6, 0xeb, 0x6e, 0xc1, 0x96, 0x04, 0x27, 0xc8, 0xda, 0xfa, 0xe8,
6065 0x2e, 0xbb, 0x2c, 0x6e, 0xf4, 0xb4, 0x00, 0x7d, 0x8d, 0x3b, 0xef, 0x8b,
6066 0x18, 0xa9, 0x5f, 0x32, 0xa9, 0xf2, 0x3a, 0x7e, 0x65, 0x2d, 0x6e, 0x8d,
6067 0x75, 0x77, 0xf6, 0xa6, 0xd8, 0xf9, 0x6b, 0x51, 0xe6, 0x66, 0x52, 0x59,
6068 0x39, 0x97, 0x22, 0xda, 0xb2, 0xd6, 0x82, 0x5a, 0x6e, 0x61, 0x60, 0x16,
6069 0x48, 0x7b, 0xf1, 0xc3, 0x4d, 0x7f, 0x50, 0xfa, 0x4d, 0x58, 0x27, 0x30,
6070 0xc8, 0x96, 0xe0, 0x41, 0x4f, 0x6b, 0xeb, 0x88, 0xa2, 0x7a, 0xef, 0x8a,
6071 0x88, 0xc8, 0x50, 0x4b, 0x55, 0x66, 0xee, 0xbf, 0xc4, 0x01, 0x82, 0x4c,
6072 0xec, 0xde, 0x37, 0x64, 0xd6, 0x1e, 0xcf, 0x3e, 0x2e, 0xfe, 0x84, 0x68,
6073 0xbf, 0xa3, 0x68, 0x77, 0xa9, 0x03, 0xe4, 0xf8, 0xd7, 0xb2, 0x6e, 0xa3,
6074 0xc4, 0xc3, 0x36, 0x53, 0xf3, 0xdd, 0x7e, 0x4c, 0xf0, 0xe9, 0xb2, 0x44,
6075 0xe6, 0x60, 0x3d, 0x00, 0x9a, 0x08, 0xc3, 0x21, 0x17, 0x49, 0xda, 0x49,
6076 0xfb, 0x4c, 0x8b, 0xe9, 0x10, 0x66, 0xfe, 0xb7, 0xe0, 0xf9, 0xdd, 0xbf,
6077 0x41, 0xfe, 0x04, 0x9b, 0x7f, 0xe8, 0xd6, 0x2e, 0x4d, 0x0f, 0x7b, 0x10,
6078 0x73, 0x4c, 0xa1, 0x3e, 0x43, 0xb7, 0xcf, 0x94, 0x97, 0x7e, 0x24, 0xbb,
6079 0x87, 0xbf, 0x22, 0xb8, 0x3e, 0xeb, 0x9a, 0x3f, 0xe3, 0x86, 0xee, 0x21,
6080 0xbc, 0xf5, 0x44, 0xeb, 0x60, 0x2e, 0xe7, 0x8f, 0x89, 0xa4, 0x91, 0x61,
6081 0x28, 0x90, 0x85, 0x68, 0xe0, 0xa9, 0x62, 0x93, 0x86, 0x5a, 0x15, 0xbe,
6082 0xb2, 0x76, 0x83, 0xf2, 0x0f, 0x00, 0xc7, 0xb6, 0x57, 0xe9, 0x1f, 0x92,
6083 0x49, 0xfe, 0x50, 0x85, 0xbf, 0x39, 0x3d, 0xe4, 0x8b, 0x72, 0x2d, 0x49,
6084 0xbe, 0x05, 0x0a, 0x34, 0x56, 0x80, 0xc6, 0x1f, 0x46, 0x59, 0xc9, 0xfe,
6085 0x40, 0xfb, 0x78, 0x6d, 0x7a, 0xe5, 0x30, 0xe9, 0x81, 0x55, 0x75, 0x05,
6086 0x63, 0xd2, 0x22, 0xee, 0x2e, 0x6e, 0xb9, 0x18, 0xe5, 0x8a, 0x5a, 0x66,
6087 0xbd, 0x74, 0x30, 0xe3, 0x8b, 0x76, 0x22, 0x18, 0x1e, 0xef, 0x69, 0xe8,
6088 0x9d, 0x07, 0xa7, 0x9a, 0x87, 0x6c, 0x04, 0x4b, 0x74, 0x2b, 0xbe, 0x37,
6089 0x2f, 0x29, 0x9b, 0x60, 0x9d, 0x8b, 0x57, 0x55, 0x34, 0xca, 0x41, 0x25,
6090 0xae, 0x56, 0x92, 0x34, 0x1b, 0x9e, 0xbd, 0xfe, 0x74, 0xbd, 0x4e, 0x29,
6091 0xf0, 0x5e, 0x27, 0x94, 0xb0, 0x9e, 0x23, 0x9f, 0x4a, 0x0f, 0xa1, 0xdf,
6092 0xe7, 0xc4, 0xdb, 0xbe, 0x0f, 0x1a, 0x0b, 0x6c, 0xb0, 0xe1, 0x06, 0x7c,
6093 0x5a, 0x5b, 0x81, 0x1c, 0xb6, 0x12, 0xec, 0x6f, 0x3b, 0xbb, 0x84, 0x36,
6094 0xd5, 0x28, 0x16, 0xea, 0x51, 0xa8, 0x99, 0x24, 0x8f, 0xe7, 0xf8, 0xe9,
6095 0xce, 0xa1, 0x65, 0x96, 0x6f, 0x4e, 0x2f, 0xb7, 0x6f, 0x65, 0x39, 0xad,
6096 0xfd, 0x2e, 0xa0, 0x37, 0x32, 0x2f, 0xf3, 0x95, 0xa1, 0x3a, 0xa1, 0x9d,
6097 0x2c, 0x9e, 0xa1, 0x4b, 0x7e, 0xc9, 0x7e, 0x86, 0xaa, 0x16, 0x00, 0x82,
6098 0x1d, 0x36, 0xbf, 0x98, 0x0a, 0x82, 0x5b, 0xcc, 0xc4, 0x6a, 0xad, 0xa0,
6099 0x1f, 0x47, 0x98, 0xde, 0x8d, 0x68, 0x38, 0x3f, 0x33, 0xe2, 0x08, 0x3b,
6100 0x2a, 0x65, 0xd9, 0x2f, 0x53, 0x68, 0xb8, 0x78, 0xd0, 0x1d, 0xbb, 0x2a,
6101 0x73, 0x19, 0xba, 0x58, 0xea, 0xf1, 0x0a, 0xaa, 0xa6, 0xbe, 0x27, 0xd6,
6102 0x00, 0x6b, 0x4e, 0x43, 0x8e, 0x5b, 0x19, 0xc1, 0x37, 0x0f, 0xfb, 0x81,
6103 0x72, 0x10, 0xb6, 0x20, 0x32, 0xcd, 0xa2, 0x7c, 0x90, 0xd4, 0xf5, 0xcf,
6104 0x1c, 0xcb, 0x14, 0x24, 0x7a, 0x4d, 0xf5, 0xd5, 0xd9, 0xce, 0x6a, 0x64,
6105 0xc9, 0xd3, 0xa7, 0x36, 0x6f, 0x1d, 0xf1, 0xe9, 0x71, 0x6c, 0x3d, 0x02,
6106 0xa4, 0x62, 0xb1, 0x82, 0x5c, 0x13, 0x4b, 0x6b, 0x68, 0xe2, 0x31, 0xef,
6107 0xe4, 0x46, 0xfd, 0xe5, 0xa8, 0x29, 0xe9, 0x1e, 0xad, 0xff, 0x33, 0xdb,
6108 0x0b, 0xc0, 0x92, 0xb1, 0xef, 0xeb, 0xb3, 0x6f, 0x96, 0x7b, 0xdf, 0xcd,
6109 0x07, 0x19, 0x86, 0x60, 0x98, 0xcf, 0x95, 0xfe, 0x98, 0xdd, 0x29, 0xa6,
6110 0x35, 0x7b, 0x46, 0x13, 0x03, 0xa8, 0xd9, 0x7c, 0xb3, 0xdf, 0x9f, 0x14,
6111 0xb7, 0x34, 0x5a, 0xc4, 0x12, 0x81, 0xc5, 0x98, 0x25, 0x8d, 0x3e, 0xe3,
6112 0xd8, 0x2d, 0xe4, 0x54, 0xab, 0xb0, 0x13, 0xfd, 0xd1, 0x3f, 0x3b, 0xbf,
6113 0xa9, 0x45, 0x28, 0x8a, 0x2f, 0x9c, 0x1e, 0x2d, 0xe5, 0xab, 0x13, 0x95,
6114 0x97, 0xc3, 0x34, 0x37, 0x8d, 0x93, 0x66, 0x31, 0x81, 0xa0, 0x30, 0x23,
6115 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x15, 0x31,
6116 0x16, 0x04, 0x14, 0xa5, 0x23, 0x9b, 0x7e, 0xe6, 0x45, 0x71, 0xbf, 0x48,
6117 0xc6, 0x27, 0x3c, 0x96, 0x87, 0x63, 0xbd, 0x1f, 0xde, 0x72, 0x12, 0x30,
6118 0x79, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x11, 0x01,
6119 0x31, 0x6c, 0x1e, 0x6a, 0x00, 0x4d, 0x00, 0x69, 0x00, 0x63, 0x00, 0x72,
6120 0x00, 0x6f, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x66, 0x00, 0x74, 0x00, 0x20,
6121 0x00, 0x45, 0x00, 0x6e, 0x00, 0x68, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x63,
6122 0x00, 0x65, 0x00, 0x64, 0x00, 0x20, 0x00, 0x52, 0x00, 0x53, 0x00, 0x41,
6123 0x00, 0x20, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x20, 0x00, 0x41,
6124 0x00, 0x45, 0x00, 0x53, 0x00, 0x20, 0x00, 0x43, 0x00, 0x72, 0x00, 0x79,
6125 0x00, 0x70, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61,
6126 0x00, 0x70, 0x00, 0x68, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20, 0x00, 0x50,
6127 0x00, 0x72, 0x00, 0x6f, 0x00, 0x76, 0x00, 0x69, 0x00, 0x64, 0x00, 0x65,
6128 0x00, 0x72, 0x30, 0x31, 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
6129 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x93, 0xa8, 0xb2, 0x7e, 0xb7,
6130 0xab, 0xf1, 0x1c, 0x3c, 0x36, 0x58, 0xdc, 0x67, 0x6d, 0x42, 0xa6, 0xfc,
6131 0x53, 0x01, 0xe6, 0x04, 0x08, 0x77, 0x57, 0x22, 0xa1, 0x7d, 0xb9, 0xa2,
6132 0x69, 0x02, 0x02, 0x08, 0x00
6133};
6134
6136{
6137 HINTERNET ses, req, con;
6138 BOOL ret;
6139 CRYPT_DATA_BLOB pfx;
6140 HCERTSTORE store;
6141 const CERT_CONTEXT *cert;
6142
6143 ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
6144 ok( ses != NULL, "failed to open session %lu\n", GetLastError() );
6145
6146 con = WinHttpConnect( ses, L"test.winehq.org", 443, 0 );
6147 ok( con != NULL, "failed to open a connection %lu\n", GetLastError() );
6148
6149 req = WinHttpOpenRequest( con, NULL, L"/tests/clientcert/", NULL, NULL, NULL, WINHTTP_FLAG_SECURE );
6150 ok( req != NULL, "failed to open a request %lu\n", GetLastError() );
6151
6152 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
6153 ok( ret || broken(!ret && GetLastError() == ERROR_WINHTTP_SECURE_FAILURE) /* win7 */,
6154 "failed to send request %lu\n", GetLastError() );
6155 if (!ret) goto done;
6156
6157 SetLastError( 0xdeadbeef );
6159 ok( !ret, "unexpected success\n" );
6161
6162 pfx.pbData = (BYTE *)pfxdata;
6163 pfx.cbData = sizeof(pfxdata);
6165 ok( store != NULL, "got %lu\n", GetLastError() );
6166
6168 ok( cert != NULL, "got %lu\n", GetLastError() );
6169
6171 ok( ret, "failed to set client cert %lu\n", GetLastError() );
6172
6173 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
6174 ok( ret, "failed to send request %lu\n", GetLastError() );
6175
6176 SetLastError( 0xdeadbeef );
6178 todo_wine {
6179 ok( !ret, "unexpected success\n" );
6181 "got %lu\n", GetLastError() );
6182 }
6183
6185 CertCloseStore( store, 0 );
6186done:
6187 WinHttpCloseHandle( req );
6188 WinHttpCloseHandle( con );
6189 WinHttpCloseHandle( ses );
6190}
6191
6193{
6194 HINTERNET ses, con, req;
6195 DWORD status, size;
6196 char buffer[256];
6197 BOOL ret;
6198
6199 ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
6200 ok(ses != NULL, "failed to open session %lu\n", GetLastError());
6201
6202 con = WinHttpConnect(ses, L"localhost", port, 0);
6203 ok(con != NULL, "failed to open a connection %lu\n", GetLastError());
6204
6205 req = WinHttpOpenRequest(con, L"GET", L"/cached", NULL, NULL, NULL, 0);
6206 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
6207 ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
6208 ok(ret, "failed to send request %lu\n", GetLastError());
6210 ok(ret, "failed to receive response %lu\n", GetLastError());
6211 size = sizeof(status);
6213 ok(ret, "failed to query status code %lu\n", GetLastError());
6214 ok(status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status);
6215 ret = WinHttpReadData(req, buffer, sizeof buffer, &size);
6216 ok(ret, "failed to read data %lu\n", GetLastError());
6217 ok(!size, "got size %lu.\n", size);
6218 WinHttpCloseHandle(req);
6219
6220 req = WinHttpOpenRequest(con, L"GET", L"/cached", NULL, NULL, NULL, 0);
6221 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
6222 ret = WinHttpSendRequest(req, L"Connection: close", ~0u, NULL, 0, 0, 0);
6223 ok(ret, "failed to send request %lu\n", GetLastError());
6225 ok(ret, "failed to receive response %lu\n", GetLastError());
6226 size = sizeof(status);
6228 ok(ret, "failed to query status code %lu\n", GetLastError());
6229 ok(status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status);
6230 ret = WinHttpReadData(req, buffer, sizeof buffer, &size);
6231 ok(ret, "failed to read data %lu\n", GetLastError());
6232 ok(!size, "got size %lu.\n", size);
6233 WinHttpCloseHandle(req);
6234
6235 req = WinHttpOpenRequest(con, L"GET", L"/notcached", NULL, NULL, NULL, 0);
6236 ok(req != NULL, "failed to open a request %lu\n", GetLastError());
6237 ret = WinHttpSendRequest(req, L"Connection: close", ~0u, NULL, 0, 0, 0);
6238 ok(ret, "failed to send request %lu\n", GetLastError());
6240 ok(ret, "failed to receive response %lu\n", GetLastError());
6241 size = sizeof(status);
6243 ok(ret, "failed to query status code %lu\n", GetLastError());
6244 ok(status == HTTP_STATUS_OK, "request failed unexpectedly %lu\n", status);
6245 WinHttpCloseHandle(req);
6246
6247 WinHttpCloseHandle(con);
6248 WinHttpCloseHandle(ses);
6249}
6250
6251START_TEST (winhttp)
6252{
6253 struct server_info si;
6254 HANDLE thread;
6255 DWORD ret;
6256 HMODULE mod = GetModuleHandleA("winhttp.dll");
6257
6258 pWinHttpWebSocketClose = (void *)GetProcAddress(mod, "WinHttpWebSocketClose");
6259 pWinHttpWebSocketCompleteUpgrade = (void *)GetProcAddress(mod, "WinHttpWebSocketCompleteUpgrade");
6260 pWinHttpWebSocketQueryCloseStatus = (void *)GetProcAddress(mod, "WinHttpWebSocketQueryCloseStatus");
6261 pWinHttpWebSocketSend = (void *)GetProcAddress(mod, "WinHttpWebSocketSend");
6262 pWinHttpWebSocketShutdown = (void *)GetProcAddress(mod, "WinHttpWebSocketShutdown");
6263 pWinHttpWebSocketReceive = (void *)GetProcAddress(mod, "WinHttpWebSocketReceive");
6264
6277 test_timeouts();
6285
6286 si.event = CreateEventW(NULL, 0, 0, NULL);
6287 si.port = 7532;
6289 ok(thread != NULL, "failed to create thread %lu\n", GetLastError());
6290
6291 ret = WaitForSingleObject(si.event, 10000);
6292 ok(ret == WAIT_OBJECT_0, "failed to start winhttp test server %lu\n", GetLastError());
6293 if (ret != WAIT_OBJECT_0)
6294 {
6296 return;
6297 }
6298
6301 test_basic_request(si.port, NULL, L"/basic");
6302 test_basic_request(si.port, L"PUT", L"/test");
6304 test_no_headers(si.port);
6305 test_no_content(si.port);
6306 test_head_request(si.port);
6307 test_not_modified(si.port);
6311 test_bad_header(si.port);
6312#ifdef __REACTOS__
6314 {
6315 skip("Skipping tests due to hang. See ROSTESTS-350\n");
6316 }
6317 else
6318 {
6319 test_multiple_reads(si.port);
6320 test_cookies(si.port);
6322 test_passport_auth(si.port);
6323 test_websocket(si.port);
6324 test_redirect(si.port);
6327
6328 /* send the basic request again to shutdown the server thread */
6329 test_basic_request(si.port, NULL, L"/quit");
6330 }
6331#else
6332 test_multiple_reads(si.port);
6333 test_cookies(si.port);
6335 test_passport_auth(si.port);
6336 test_websocket(si.port);
6337 test_redirect(si.port);
6340
6341 /* send the basic request again to shutdown the server thread */
6342 test_basic_request(si.port, NULL, L"/quit");
6343#endif
6344
6347}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
ULONG WSAAPI inet_addr(IN CONST CHAR FAR *cp)
Definition: addrconv.c:71
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
WINBASEAPI _Check_return_ _Out_ AppPolicyProcessTerminationMethod * policy
Definition: appmodel.h:73
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
#define index(s, c)
Definition: various.h:29
#define ARRAY_SIZE(A)
Definition: main.h:20
void dispatch(HANDLE hStopEvent)
Definition: dispatch.c:70
struct protocol * protocols
Definition: dispatch.c:56
static HANDLE thread
Definition: service.c:33
const GUID IID_IUnknown
#define RegCloseKey(hKey)
Definition: registry.h:49
r l[0]
Definition: byte_order.h:168
#define sha1
Definition: compat-1.3.h:2261
static const WCHAR proxy_server[]
Definition: connections.c:40
HCERTSTORE WINAPI PFXImportCertStore(CRYPT_DATA_BLOB *pPFX, LPCWSTR szPassword, DWORD dwFlags)
Definition: decode.c:6400
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT hr
Definition: delayimp.cpp:573
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
Definition: crypt.c:753
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1675
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
Definition: crypt.c:929
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:661
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
Definition: crypt.c:1836
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, CLSID *clsid)
Definition: combase.c:1437
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
static const WCHAR empty[1]
Definition: string.c:47
BOOL WINAPI CryptBinaryToStringA(const BYTE *pbBinary, DWORD cbBinary, DWORD dwFlags, LPSTR pszString, DWORD *pcchString)
Definition: base64.c:253
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
Definition: cert.c:1765
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
WCHAR OLECHAR
Definition: compat.h:2292
OLECHAR * BSTR
Definition: compat.h:2293
#define GetCurrentProcess()
Definition: compat.h:759
#define IsWow64Process
Definition: compat.h:760
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define CALLBACK
Definition: compat.h:35
short VARIANT_BOOL
Definition: compat.h:2290
#define MultiByteToWideChar
Definition: compat.h:110
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
@ VT_BSTR
Definition: compat.h:2303
@ VT_UNKNOWN
Definition: compat.h:2308
@ VT_ERROR
Definition: compat.h:2305
@ VT_ARRAY
Definition: compat.h:2341
@ VT_R8
Definition: compat.h:2300
@ VT_I4
Definition: compat.h:2298
@ VT_BOOL
Definition: compat.h:2306
@ VT_UI4
Definition: compat.h:2313
@ VT_EMPTY
Definition: compat.h:2295
@ VT_UI1
Definition: compat.h:2311
#define lstrlenW
Definition: compat.h:750
static const WCHAR version[]
Definition: asmname.c:66
static void cleanup(void)
Definition: main.c:1335
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
#define open
Definition: io.h:44
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3415
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
USHORT port
Definition: uri.c:228
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, const WCHAR *verb, const WCHAR *object, const WCHAR *version, const WCHAR *referrer, const WCHAR **types, DWORD flags)
Definition: session.c:1277
BOOL WINAPI WinHttpGetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *info)
Definition: session.c:1731
BOOL WINAPI WinHttpQueryOption(HINTERNET handle, DWORD option, void *buffer, DWORD *buflen)
Definition: session.c:1420
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:304
BOOL WINAPI WinHttpGetIEProxyConfigForCurrentUser(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *config)
Definition: session.c:1851
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, const WCHAR *server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:594
BOOL WINAPI WinHttpSetOption(HINTERNET handle, DWORD option, void *buffer, DWORD buflen)
Definition: session.c:1479
BOOL WINAPI WinHttpGetProxyForUrl(HINTERNET hsession, LPCWSTR url, WINHTTP_AUTOPROXY_OPTIONS *options, WINHTTP_PROXY_INFO *info)
Definition: session.c:2165
BOOL WINAPI WinHttpTimeFromSystemTime(const SYSTEMTIME *time, LPWSTR string)
Definition: session.c:2534
BOOL WINAPI WinHttpSetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *info)
Definition: session.c:2221
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1358
BOOL WINAPI WinHttpSetTimeouts(HINTERNET handle, int resolve, int connect, int send, int receive)
Definition: session.c:2460
BOOL WINAPI WinHttpDetectAutoProxyConfigUrl(DWORD flags, WCHAR **url)
Definition: session.c:1675
BOOL WINAPI WinHttpTimeToSystemTime(LPCWSTR string, SYSTEMTIME *time)
Definition: session.c:2561
WINHTTP_STATUS_CALLBACK WINAPI WinHttpSetStatusCallback(HINTERNET handle, WINHTTP_STATUS_CALLBACK callback, DWORD flags, DWORD_PTR reserved)
Definition: session.c:2435
#define swprintf
Definition: precomp.h:40
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
method
Definition: dragdrop.c:54
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLuint index
Definition: glext.h:6031
GLenum const GLfloat * params
Definition: glext.h:5645
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
const GLint * first
Definition: glext.h:5794
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
static const WCHAR optionW[]
Definition: htmlelem.c:36
#define DISPID_HTTPREQUEST_SETAUTOLOGONPOLICY
Definition: httprequestid.h:40
#define DISPID_HTTPREQUEST_OPEN
Definition: httprequestid.h:23
#define DISPID_HTTPREQUEST_OPTION
Definition: httprequestid.h:28
#define S_OK
Definition: intsafe.h:52
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
#define wine_dbgstr_w
Definition: kernel32.h:34
#define GUID_NULL
Definition: ks.h:106
POINT cp
Definition: magnifier.c:59
#define win_skip
Definition: minitest.h:67
int winetest_interactive
#define todo_wine
Definition: minitest.h:80
__u16 date
Definition: mkdosfs.c:8
__u16 time
Definition: mkdosfs.c:8
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define htons(x)
Definition: module.h:215
#define sprintf
Definition: sprintf.c:45
static const WCHAR url[]
Definition: encode.c:1384
static BYTE cert[]
Definition: msg.c:1374
BOOL expected
Definition: store.c:2000
static SYSTEM_INFO si
Definition: virtual.c:39
static BSTR content_type
static VARIANTARG static DISPID
Definition: ordinal.c:49
INTERNETFEATURELIST feature
Definition: misc.c:1719
static const CHAR post_data[]
Definition: protocol.c:217
static BOOL test_redirect
Definition: protocol.c:149
static WCHAR password[]
Definition: url.c:33
static WCHAR username[]
Definition: url.c:32
#define min(a, b)
Definition: monoChain.cc:55
int disable
Definition: msacm.c:1365
const CLSID * clsid
Definition: msctf.cpp:50
#define closesocket
Definition: ncftp.h:477
unsigned int UINT
Definition: ndis.h:50
#define KEY_READ
Definition: nt_native.h:1026
#define KEY_WRITE
Definition: nt_native.h:1034
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define V_ERROR(A)
Definition: oleauto.h:241
#define V_BOOL(A)
Definition: oleauto.h:224
#define V_UNKNOWN(A)
Definition: oleauto.h:281
#define DISPATCH_PROPERTYPUT
Definition: oleauto.h:1008
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_I4(A)
Definition: oleauto.h:247
#define V_UI4(A)
Definition: oleauto.h:270
#define V_R8(A)
Definition: oleauto.h:262
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
const GUID IID_IDispatch
static BOOL check_buffer(parse_buffer *buf, ULONG size)
Definition: parsing.c:1119
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
static BOOL wow64
Definition: psapi_main.c:44
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define IID_NULL
Definition: guiddef.h:98
#define err(...)
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, const WCHAR *name, void *buffer, DWORD *buflen, DWORD *index)
Definition: request.c:814
BOOL WINAPI WinHttpAddRequestHeaders(HINTERNET hrequest, const WCHAR *headers, DWORD len, DWORD flags)
Definition: request.c:521
BOOL WINAPI WinHttpQueryDataAvailable(HINTERNET hrequest, LPDWORD available)
Definition: request.c:3156
BOOL WINAPI WinHttpWriteData(HINTERNET hrequest, const void *buffer, DWORD to_write, DWORD *written)
Definition: request.c:3371
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, void *buffer, DWORD to_read, DWORD *read)
Definition: request.c:3252
BOOL WINAPI WinHttpSetCredentials(HINTERNET hrequest, DWORD target, DWORD scheme, const WCHAR *username, const WCHAR *password, void *params)
Definition: request.c:2493
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, const WCHAR *headers, DWORD headers_len, void *optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2397
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:3068
BOOL WINAPI WinHttpQueryAuthSchemes(HINTERNET hrequest, LPDWORD supported, LPDWORD first, LPDWORD target)
Definition: request.c:925
#define wine_dbgstr_wn
Definition: testlist.c:2
#define CP_UTF8
Definition: nls.h:20
strcat
Definition: string.h:92
strcpy
Definition: string.h:131
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:206
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition: md5.c:100
#define memset(x, y, z)
Definition: compat.h:39
vector< Header * > headers
Definition: sdkparse.cpp:39
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
LPWSTR lpszProxyBypass
Definition: winhttp.h:578
LPWSTR lpszProxy
Definition: winhttp.h:577
BYTE * pbData
Definition: wincrypt.h:112
Definition: http.c:7252
Definition: _hash_fun.h:40
Definition: copy.c:22
Definition: getopt.h:109
Definition: tftpd.h:86
Definition: ps.c:97
Definition: parse.h:23
Definition: tools.h:99
Definition: dhcpd.h:248
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define MAKEWORD(a, b)
Definition: typedefs.h:248
Definition: pdh_main.c:96
static void reverse(int *pidx, int cch)
Definition: bidi.c:1153
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define PROV_RSA_FULL
Definition: wincrypt.h:2243
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2273
#define CALG_SHA1
Definition: wincrypt.h:2060
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:55
#define CRYPT_USER_KEYSET
Definition: wincrypt.h:4320
#define CRYPT_STRING_BASE64
Definition: wincrypt.h:3132
#define X509_ASN_ENCODING
Definition: wincrypt.h:2501
#define PKCS12_NO_PERSIST_KEY
Definition: wincrypt.h:4327
ULONG_PTR HCRYPTHASH
Definition: wincrypt.h:59
#define CERT_FIND_ANY
Definition: wincrypt.h:3010
#define HP_HASHVAL
Definition: wincrypt.h:2387
#define CRYPT_EXPORTABLE
Definition: wincrypt.h:2410
void * arg
Definition: msvc.h:10
#define WINAPI
Definition: msvc.h:6
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define DISP_E_PARAMNOTFOUND
Definition: winerror.h:3616
#define ERROR_INVALID_OPERATION
Definition: winerror.h:1689
#define DISP_E_UNKNOWNINTERFACE
Definition: winerror.h:3614
#define WSAEINVAL
Definition: winerror.h:2845
#define DISP_E_MEMBERNOTFOUND
Definition: winerror.h:3615
#define SEC_E_ILLEGAL_MESSAGE
Definition: winerror.h:4341
#define SEC_E_CERT_EXPIRED
Definition: winerror.h:4343
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:3617
#define ERROR_NO_TOKEN
Definition: winerror.h:911
static void test_WinHttpSendRequest(void)
Definition: winhttp.c:371
static const WCHAR WinHttpSettings[]
Definition: winhttp.c:1325
static const char auth_unseen[]
Definition: winhttp.c:2309
static void test_WinHttpDetectAutoProxyConfigUrl(void)
Definition: winhttp.c:5478
static const BYTE pfxdata[]
Definition: winhttp.c:5893
static void test_bad_header(int port)
Definition: winhttp.c:3897
static USHORT
Definition: winhttp.c:38
static const char badreplyheadermsg[]
Definition: winhttp.c:2294
static void test_IWinHttpRequest(int port)
Definition: winhttp.c:4612
static DWORD CALLBACK server_thread(LPVOID param)
Definition: winhttp.c:2362
static const char okmsg[]
Definition: winhttp.c:2199
static void test_multiple_reads(int port)
Definition: winhttp.c:3987
static void test_websocket(int port)
Definition: winhttp.c:3380
static void test_no_content(int port)
Definition: winhttp.c:3168
static void test_no_headers(int port)
Definition: winhttp.c:3133
static void set_proxy(REGSAM access, BYTE *buf, DWORD len, DWORD type)
Definition: winhttp.c:1353
static void test_credentials(void)
Definition: winhttp.c:4383
static void test_cookies(int port)
Definition: winhttp.c:4040
static void CALLBACK cert_error(HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID buf, DWORD len)
Definition: winhttp.c:1041
static void do_request(HINTERNET con, const WCHAR *obj, DWORD flags)
Definition: winhttp.c:4193
static void test_chunked_request(int port)
Definition: winhttp.c:2725
static void test_set_default_proxy_config(void)
Definition: winhttp.c:1377
static void test_WinHttpOpenRequest(void)
Definition: winhttp.c:277
static const char noauthmsg[]
Definition: winhttp.c:2234
static void test_resolve_timeout(void)
Definition: winhttp.c:2123
static const char hello_world[]
Definition: winhttp.c:2308
#define X(x)
static void test_secure_connection(void)
Definition: winhttp.c:1061
static const char notokmsg[]
Definition: winhttp.c:2210
static DWORD_PTR
Definition: winhttp.c:39
static const char proxy_pac[]
Definition: winhttp.c:2301
static void test_connect_error(void)
Definition: winhttp.c:485
static const char page1[]
Definition: winhttp.c:2193
static void test_WinHttpGetIEProxyConfigForCurrentUser(void)
Definition: winhttp.c:5535
static void test_WinHttpAddHeaders(void)
Definition: winhttp.c:584
static void test_WinHttpGetProxyForUrl(int port)
Definition: winhttp.c:5564
static void test_basic_authentication(int port)
Definition: winhttp.c:2763
static void test_basic_request(int port, const WCHAR *verb, const WCHAR *path)
Definition: winhttp.c:2628
static void test_request_parameter_defaults(void)
Definition: winhttp.c:1242
static const char cookiemsg2[]
Definition: winhttp.c:2220
static const char headmsg[]
Definition: winhttp.c:2251
static void test_multi_authentication(int port)
Definition: winhttp.c:3035
static void test_IWinHttpRequest_Invoke(void)
Definition: winhttp.c:5265
static void test_empty_headers_param(void)
Definition: winhttp.c:341
static USHORT void DWORD *static void DWORD WINHTTP_WEB_SOCKET_BUFFER_TYPE *static WINHTTP_WEB_SOCKET_BUFFER_TYPE
Definition: winhttp.c:42
static void create_websocket_accept(const char *key, char *buf, unsigned int buflen)
Definition: winhttp.c:2319
static const char unauthorized[]
Definition: winhttp.c:2307
static const char nocontentmsg[]
Definition: winhttp.c:2225
static void test_WinHttpTimeToSystemTime(void)
Definition: winhttp.c:548
static void test_client_cert_authentication(void)
Definition: winhttp.c:6135
static void test_max_http_automatic_redirects(void)
Definition: winhttp.c:5827
static void test_head_request(int port)
Definition: winhttp.c:3250
static const char passportauth[]
Definition: winhttp.c:2275
static int server_receive_request(int c, char *buffer, size_t buffer_size)
Definition: winhttp.c:2344
static void test_not_modified(int port)
Definition: winhttp.c:3843
static const char largeauth[]
Definition: winhttp.c:2266
static const WCHAR Connections[]
Definition: winhttp.c:1318
static DWORD get_default_proxy_reg_value(BYTE *buf, DWORD len, DWORD *type)
Definition: winhttp.c:1328
static const char cookiemsg[]
Definition: winhttp.c:2214
static void test_WinHttpQueryOption(void)
Definition: winhttp.c:67
static void test_connection_info(int port)
Definition: winhttp.c:4261
static void test_request_path_escapes(int port)
Definition: winhttp.c:4217
#define BIG_BUFFER_LEN
Definition: winhttp.c:2317
static const char redirectmsg[]
Definition: winhttp.c:2288
static void test_passport_auth(int port)
Definition: winhttp.c:4319
static void DWORD
Definition: winhttp.c:38
static void test_chunked_read(void)
Definition: winhttp.c:5744
static void set_default_proxy_reg_value(BYTE *buf, DWORD len, DWORD type)
Definition: winhttp.c:1364
static void test_connection_cache(int port)
Definition: winhttp.c:6192
static void test_WinHttpTimeFromSystemTime(void)
Definition: winhttp.c:520
static void test_large_data_authentication(int port)
Definition: winhttp.c:3086
static const char okauthmsg[]
Definition: winhttp.c:2243
static const char switchprotocols[]
Definition: winhttp.c:2282
static BOOL proxy_active(void)
Definition: winhttp.c:45
static const char okmsg_length0[]
Definition: winhttp.c:2204
static const char notmodified[]
Definition: winhttp.c:2230
static void request_get_property(IWinHttpRequest *request, int property, VARIANT *ret)
Definition: winhttp.c:5245
static const char multiauth[]
Definition: winhttp.c:2256
static void test_timeouts(void)
Definition: winhttp.c:1465
#define HTTP_STATUS_OK
Definition: winhttp.h:301
#define WINHTTP_OPTION_WEB_SOCKET_RECEIVE_BUFFER_SIZE
Definition: winhttp.h:164
#define WINHTTP_OPTION_PROXY_PASSWORD
Definition: winhttp.h:185
#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED
Definition: winhttp.h:505
#define WINHTTP_OPTION_USERNAME
Definition: winhttp.h:182
#define WINHTTP_QUERY_CONTENT_LENGTH
Definition: winhttp.h:365
#define WINHTTP_AUTOPROXY_NO_CACHE_SVC
Definition: winhttp.h:615
#define WINHTTP_AUTO_DETECT_TYPE_DHCP
Definition: winhttp.h:601
#define WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH
Definition: winhttp.h:135
#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE
Definition: winhttp.h:511
#define ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN
Definition: winhttp.h:255
#define WINHTTP_OPTION_CONTEXT_VALUE
Definition: winhttp.h:121
#define WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS
Definition: winhttp.h:141
#define WINHTTP_FLAG_ESCAPE_DISABLE_QUERY
Definition: winhttp.h:64
#define ERROR_WINHTTP_NAME_NOT_RESOLVED
Definition: winhttp.h:239
#define SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE
Definition: winhttp.h:346
#define WINHTTP_OPTION_SEND_TIMEOUT
Definition: winhttp.h:106
#define WINHTTP_QUERY_CONNECTION
Definition: winhttp.h:383
@ WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS
Definition: winhttp.h:797
#define WINHTTP_QUERY_VERSION
Definition: winhttp.h:378
#define WINHTTP_OPTION_CONNECTION_INFO
Definition: winhttp.h:145
#define HTTP_STATUS_NO_CONTENT
Definition: winhttp.h:305
#define ERROR_WINHTTP_OPERATION_CANCELLED
Definition: winhttp.h:244
#define WINHTTP_HEADER_NAME_BY_INDEX
Definition: winhttp.h:85
#define WINHTTP_OPTION_SERVER_CERT_CONTEXT
Definition: winhttp.h:130
#define HTTP_STATUS_BAD_REQUEST
Definition: winhttp.h:317
#define WINHTTP_OPTION_SECURITY_FLAGS
Definition: winhttp.h:114
#define WINHTTP_DEFAULT_ACCEPT_TYPES
Definition: winhttp.h:226
#define ERROR_WINHTTP_CANNOT_CONNECT
Definition: winhttp.h:247
LPVOID HINTERNET
Definition: winhttp.h:37
#define WINHTTP_FLAG_BYPASS_PROXY_CACHE
Definition: winhttp.h:65
#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID
Definition: winhttp.h:509
#define WINHTTP_AUTH_SCHEME_BASIC
Definition: winhttp.h:524
#define ERROR_WINHTTP_INVALID_SERVER_RESPONSE
Definition: winhttp.h:260
#define WINHTTP_AUTH_SCHEME_PASSPORT
Definition: winhttp.h:526
#define WINHTTP_OPTION_PROXY_USERNAME
Definition: winhttp.h:184
#define WINHTTP_OPTION_ENABLE_FEATURE
Definition: winhttp.h:131
#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED
Definition: winhttp.h:507
#define WINHTTP_OPTION_PASSWORD
Definition: winhttp.h:183
#define WINHTTP_OPTION_URL
Definition: winhttp.h:116
#define WINHTTP_NO_REQUEST_DATA
Definition: winhttp.h:230
#define WINHTTP_NO_ADDITIONAL_HEADERS
Definition: winhttp.h:229
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:103
#define WINHTTP_QUERY_UPGRADE
Definition: winhttp.h:424
#define WINHTTP_OPTION_DISABLE_FEATURE
Definition: winhttp.h:125
#define WINHTTP_OPTION_CLIENT_CERT_CONTEXT
Definition: winhttp.h:122
#define WINHTTP_ADDREQ_FLAG_ADD_IF_NEW
Definition: winhttp.h:91
#define WINHTTP_ENABLE_SSL_REVOCATION
Definition: winhttp.h:218
#define WINHTTP_DISABLE_KEEP_ALIVE
Definition: winhttp.h:217
#define WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA
Definition: winhttp.h:508
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
Definition: winhttp.h:94
#define WINHTTP_AUTOPROXY_AUTO_DETECT
Definition: winhttp.h:604
#define WINHTTP_QUERY_STATUS_CODE
Definition: winhttp.h:379
#define WINHTTP_QUERY_FLAG_REQUEST_HEADERS
Definition: winhttp.h:437
#define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
Definition: winhttp.h:69
#define WINHTTP_ENABLE_PASSPORT_AUTH
Definition: winhttp.h:210
#define WINHTTP_ACCESS_TYPE_NAMED_PROXY
Definition: winhttp.h:71
#define HTTP_STATUS_SWITCH_PROTOCOLS
Definition: winhttp.h:300
#define ERROR_WINHTTP_SECURE_FAILURE
Definition: winhttp.h:271
#define WINHTTP_NO_PROXY_NAME
Definition: winhttp.h:74
#define WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP
Definition: winhttp.h:204
#define WINHTTP_AUTH_SCHEME_NEGOTIATE
Definition: winhttp.h:528
#define WINHTTP_AUTH_TARGET_SERVER
Definition: winhttp.h:530
#define WINHTTP_NO_HEADER_INDEX
Definition: winhttp.h:87
#define WINHTTP_QUERY_ORIG_URI
Definition: winhttp.h:394
#define ERROR_WINHTTP_INCORRECT_HANDLE_STATE
Definition: winhttp.h:246
#define ERROR_WINHTTP_INVALID_OPTION
Definition: winhttp.h:240
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:92
#define WINHTTP_OPTION_CONNECT_RETRIES
Definition: winhttp.h:105
#define WINHTTP_AUTH_SCHEME_DIGEST
Definition: winhttp.h:527
#define WINHTTP_QUERY_FLAG_NUMBER
Definition: winhttp.h:439
#define SECURITY_FLAG_IGNORE_CERT_DATE_INVALID
Definition: winhttp.h:344
#define ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND
Definition: winhttp.h:256
#define WINHTTP_AUTO_DETECT_TYPE_DNS_A
Definition: winhttp.h:602
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:104
#define WINHTTP_QUERY_MAX
Definition: winhttp.h:435
@ WINHTTP_WEB_SOCKET_UTF8_MESSAGE_BUFFER_TYPE
Definition: winhttp.h:790
@ WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE
Definition: winhttp.h:789
@ WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE
Definition: winhttp.h:788
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:107
#define WINHTTP_QUERY_CUSTOM
Definition: winhttp.h:436
#define ERROR_WINHTTP_AUTODETECTION_FAILED
Definition: winhttp.h:276
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:245
#define SECURITY_FLAG_SECURE
Definition: winhttp.h:347
#define ERROR_WINHTTP_UNRECOGNIZED_SCHEME
Definition: winhttp.h:238
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:70
#define WINHTTP_AUTOPROXY_HOST_KEEPCASE
Definition: winhttp.h:606
#define ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED
Definition: winhttp.h:252
#define WINHTTP_QUERY_STATUS_TEXT
Definition: winhttp.h:380
#define ERROR_WINHTTP_CONNECTION_ERROR
Definition: winhttp.h:248
#define WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT
Definition: winhttp.h:506
#define WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT
Definition: winhttp.h:115
#define WINHTTP_FLAG_ESCAPE_PERCENT
Definition: winhttp.h:61
enum _WINHTTP_WEB_SOCKET_BUFFER_TYPE WINHTTP_WEB_SOCKET_BUFFER_TYPE
#define WINHTTP_NO_CLIENT_CERT_CONTEXT
Definition: winhttp.h:77
#define WINHTTP_AUTOPROXY_HOST_LOWERCASE
Definition: winhttp.h:607
#define WINHTTP_FLAG_ESCAPE_DISABLE
Definition: winhttp.h:63
#define HTTP_STATUS_DENIED
Definition: winhttp.h:318
#define HTTP_STATUS_CONTINUE
Definition: winhttp.h:299
#define ERROR_WINHTTP_LOGIN_FAILURE
Definition: winhttp.h:243
#define WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL
Definition: winhttp.h:162
#define WINHTTP_ADDREQ_FLAG_REPLACE
Definition: winhttp.h:96
#define ERROR_WINHTTP_HEADER_NOT_FOUND
Definition: winhttp.h:259
#define ERROR_WINHTTP_TIMEOUT
Definition: winhttp.h:235
#define WINHTTP_QUERY_TRANSFER_ENCODING
Definition: winhttp.h:423
#define HTTP_STATUS_NOT_MODIFIED
Definition: winhttp.h:313
#define WINHTTP_QUERY_RAW_HEADERS_CRLF
Definition: winhttp.h:382
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:67
#define WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT
Definition: winhttp.h:108
#define WINHTTP_ADDREQ_FLAG_COALESCE
Definition: winhttp.h:95
#define ERROR_WINHTTP_SHUTDOWN
Definition: winhttp.h:242
#define INTERNET_DEFAULT_HTTP_PORT
Definition: winhttp.h:41
#define WINHTTP_QUERY_REQUEST_METHOD
Definition: winhttp.h:405
#define ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND
Definition: winhttp.h:257
#define WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE
Definition: winhttp.h:165
#define WINHTTP_OPTION_REDIRECT_POLICY
Definition: winhttp.h:140
#define WINHTTP_OPTION_SECURITY_KEY_BITNESS
Definition: winhttp.h:117
#define WINHTTP_OPTION_SECURE_PROTOCOLS
Definition: winhttp.h:136
#define WINHTTP_NO_REFERER
Definition: winhttp.h:225
#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID
Definition: winhttp.h:510
#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2
Definition: winhttp.h:518
#define WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET
Definition: winhttp.h:160
#define SECURITY_FLAG_STRENGTH_STRONG
Definition: winhttp.h:350
#define WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS
Definition: winhttp.h:205
#define WINHTTP_NO_PROXY_BYPASS
Definition: winhttp.h:75
#define WINHTTP_AUTH_SCHEME_NTLM
Definition: winhttp.h:525
#define SECURITY_FLAG_IGNORE_UNKNOWN_CA
Definition: winhttp.h:343
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Definition: winhttp.h:93
#define ERROR_WINHTTP_SECURE_CHANNEL_ERROR
Definition: winhttp.h:265
#define WINHTTP_DISABLE_COOKIES
Definition: winhttp.h:214
#define WINHTTP_CALLBACK_STATUS_SECURE_FAILURE
Definition: winhttp.h:458
#define WINHTTP_AUTOPROXY_CONFIG_URL
Definition: winhttp.h:605
#define WINHTTP_QUERY_RAW_HEADERS
Definition: winhttp.h:381
#define SECURITY_FLAG_IGNORE_CERT_CN_INVALID
Definition: winhttp.h:345
#define ERROR_WINHTTP_REDIRECT_FAILED
Definition: winhttp.h:264
#define WINHTTP_TIME_FORMAT_BUFSIZE
Definition: winhttp.h:533
#define WINHTTP_OPTION_WORKER_THREAD_COUNT
Definition: winhttp.h:132
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
ACCESS_MASK REGSAM
Definition: winreg.h:76
#define INVALID_SOCKET
Definition: winsock.h:326
UINT_PTR SOCKET
Definition: winsock.h:41
#define SO_REUSEADDR
Definition: winsock.h:174
#define SOL_SOCKET
Definition: winsock.h:392
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193