ReactOS 0.4.17-dev-1190-g4c812f4
http.c
Go to the documentation of this file.
1/*
2 * Wininet - HTTP tests
3 *
4 * Copyright 2002 Aric Stewart
5 * Copyright 2004 Mike McCormack
6 * Copyright 2005 Hans Leidekker
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23#include <stdarg.h>
24#include <stdio.h>
25#include <stdlib.h>
26#include <limits.h>
27
28#include "windef.h"
29#include "winbase.h"
30#include "wininet.h"
31#include "winineti.h"
32#include "winsock2.h"
33
34#include "wine/test.h"
35
36/* Undocumented security flags */
37#define _SECURITY_FLAG_CERT_REV_FAILED 0x00800000
38#define _SECURITY_FLAG_CERT_INVALID_CA 0x01000000
39#define _SECURITY_FLAG_CERT_INVALID_CN 0x02000000
40#define _SECURITY_FLAG_CERT_INVALID_DATE 0x04000000
41
42#define TEST_URL "http://test.winehq.org/tests/hello.html"
43
46
47/* Adapted from dlls/urlmon/tests/protocol.c */
48
49#define SET_EXPECT2(status, num) \
50 expect[status] = num
51
52#define SET_EXPECT(status) \
53 SET_EXPECT2(status, 1)
54
55#define SET_OPTIONAL2(status, num) \
56 optional[status] = num
57
58#define SET_OPTIONAL(status) \
59 SET_OPTIONAL2(status, 1)
60
61/* SET_WINE_ALLOW's should be used with an appropriate
62 * todo_wine CHECK_NOTIFIED at a later point in the code */
63#define SET_WINE_ALLOW2(status, num) \
64 wine_allow[status] = num
65
66#define SET_WINE_ALLOW(status) \
67 SET_WINE_ALLOW2(status, 1)
68
69#define CHECK_EXPECT(status) \
70 do { \
71 if (!expect[status] && !optional[status] && wine_allow[status]) \
72 { \
73 todo_wine ok(expect[status], "unexpected status %ld (%s)\n", status, \
74 status < MAX_INTERNET_STATUS && status_string[status] ? \
75 status_string[status] : "unknown"); \
76 wine_allow[status]--; \
77 } \
78 else \
79 { \
80 ok(expect[status] || optional[status], "unexpected status %ld (%s)\n", status, \
81 status < MAX_INTERNET_STATUS && status_string[status] ? \
82 status_string[status] : "unknown"); \
83 if (expect[status]) expect[status]--; \
84 else if(optional[status]) optional[status]--; \
85 } \
86 notified[status]++; \
87 }while(0)
88
89/* CLEAR_NOTIFIED used in cases when notification behavior
90 * differs between Windows versions */
91#define CLEAR_NOTIFIED(status) \
92 expect[status] = optional[status] = wine_allow[status] = notified[status] = 0;
93
94#define CHECK_NOTIFIED2(status, num) \
95 do { \
96 ok(notified[status] + optional[status] == (num), \
97 "expected status %d (%s) %d times, received %d times\n", \
98 status, status < MAX_INTERNET_STATUS && status_string[status] ? \
99 status_string[status] : "unknown", (num), notified[status]); \
100 CLEAR_NOTIFIED(status); \
101 }while(0)
102
103#define CHECK_NOTIFIED(status) \
104 CHECK_NOTIFIED2(status, 1)
105
106#define CHECK_NOT_NOTIFIED(status) \
107 CHECK_NOTIFIED2(status, 0)
108
109#define MAX_INTERNET_STATUS (INTERNET_STATUS_COOKIE_HISTORY+1)
113
117
118#define TESTF_REDIRECT 0x01
119#define TESTF_COMPRESSED 0x02
120#define TESTF_CHUNKED 0x04
121
122typedef struct {
123 const char *url;
124 const char *redirected_url;
125 const char *host;
126 const char *path;
127 const char *headers;
129 const char *post_data;
130 const char *content;
132
133static const test_data_t test_data[] = {
134 {
135 "http://test.winehq.org/tests/data.php",
136 "http://test.winehq.org/tests/data.php",
137 "test.winehq.org",
138 "/tests/data.php",
139 "",
141 },
142 {
143 "http://test.winehq.org/tests/redirect",
144 "http://test.winehq.org/tests/hello.html",
145 "test.winehq.org",
146 "/tests/redirect",
147 "",
149 },
150 {
151 "http://test.winehq.org/tests/gzip.php",
152 "http://test.winehq.org/tests/gzip.php",
153 "test.winehq.org",
154 "/tests/gzip.php",
155 "Accept-Encoding: gzip, deflate",
157 },
158 {
159 "http://test.winehq.org/tests/post.php",
160 "http://test.winehq.org/tests/post.php",
161 "test.winehq.org",
162 "/tests/post.php",
163 "Content-Type: application/x-www-form-urlencoded",
164 0,
165 "mode=Test",
166 "mode => Test\n"
167 }
168};
169
171static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackW)(HINTERNET ,INTERNET_STATUS_CALLBACK);
172static BOOL (WINAPI *pInternetGetSecurityInfoByURLA)(LPSTR,PCCERT_CHAIN_CONTEXT*,DWORD*);
173
175{
176 static HMODULE hkernel32 = NULL;
177 static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
178 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
179
180 if (!hkernel32)
181 {
182 hkernel32 = GetModuleHandleA("kernel32.dll");
183 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
184 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
185 }
186 if (pGetThreadUILanguage)
187 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
188 if (pGetUserDefaultUILanguage)
189 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
190
192}
193
194static int strcmp_wa(LPCWSTR strw, const char *stra)
195{
196 WCHAR buf[512];
198 return lstrcmpW(strw, buf);
199}
200
201static BOOL proxy_active(void)
202{
205 DWORD size;
206
207 if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
209 return FALSE;
210
211 size = sizeof(DWORD);
213 proxy_enable = 0;
214
216
217 return proxy_enable != 0;
218}
219
220static void init_events(void)
221{
227}
228
229static void free_events(void)
230{
236}
237
238static void reset_events(void)
239{
245}
246
247#define test_status_code(a,b) _test_status_code(__LINE__,a,b, FALSE)
248#define test_status_code_todo(a,b) _test_status_code(__LINE__,a,b, TRUE)
249static void _test_status_code(unsigned line, HINTERNET req, DWORD excode, BOOL is_todo)
250{
252 char exbuf[12], bufa[10];
253 WCHAR bufw[10];
254 BOOL res;
255
256 code = 0xdeadbeef;
257 size = sizeof(code);
259 ok_(__FILE__,line)(res, "[1] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE|number) failed: %lu\n", GetLastError());
260 todo_wine_if (is_todo)
261 ok_(__FILE__,line)(code == excode, "code = %ld, expected %ld\n", code, excode);
262 ok_(__FILE__,line)(size == sizeof(code), "size = %lu\n", size);
263
264 code = 0xdeadbeef;
265 index = 0;
266 size = sizeof(code);
268 ok_(__FILE__,line)(res, "[2] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE|number index) failed: %lu\n", GetLastError());
269 ok_(__FILE__,line)(!index, "index = %ld, expected 0\n", index);
270 ok_(__FILE__,line)(size == sizeof(code), "size = %lu\n", size);
271
272 sprintf(exbuf, "%lu", excode);
273
274 size = sizeof(bufa);
276 ok_(__FILE__,line)(res, "[3] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE) failed: %lu\n", GetLastError());
277 todo_wine_if (is_todo)
278 ok_(__FILE__,line)(!strcmp(bufa, exbuf), "unexpected status code %s, expected %s\n", bufa, exbuf);
279 ok_(__FILE__,line)(size == strlen(exbuf), "unexpected size %ld for \"%s\"\n", size, exbuf);
280
281 size = 0;
284 "[4] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE) failed: %lu\n", GetLastError());
285 ok_(__FILE__,line)(size == strlen(exbuf)+1, "unexpected size %ld for \"%s\"\n", size, exbuf);
286
287 size = sizeof(bufw);
289 ok_(__FILE__,line)(res, "[5] HttpQueryInfoW(HTTP_QUERY_STATUS_CODE) failed: %lu\n", GetLastError());
290 todo_wine_if (is_todo)
291 ok_(__FILE__,line)(!strcmp_wa(bufw, exbuf), "unexpected status code %s, expected %s\n", bufa, exbuf);
292 ok_(__FILE__,line)(size == strlen(exbuf)*sizeof(WCHAR), "unexpected size %ld for \"%s\"\n", size, exbuf);
293
294 size = 0;
297 "[6] HttpQueryInfoW(HTTP_QUERY_STATUS_CODE) failed: %lu\n", GetLastError());
298 ok_(__FILE__,line)(size == (strlen(exbuf)+1)*sizeof(WCHAR), "unexpected size %ld for \"%s\"\n", size, exbuf);
299
300 if(0) {
301 size = sizeof(bufw);
303 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER, "HttpQueryInfo(HTTP_QUERY_STATUS_CODE) failed: %lu\n", GetLastError());
304 ok(size == sizeof(bufw), "unexpected size %ld\n", size);
305 }
306
307 code = 0xdeadbeef;
308 index = 1;
309 size = sizeof(code);
312 "[7] HttpQueryInfoA failed: %x(%ld)\n", res, GetLastError());
313
314 code = 0xdeadbeef;
315 size = sizeof(code);
318 "[8] HttpQueryInfoA failed: %x(%ld)\n", res, GetLastError());
319}
320
321#define test_request_flags(a,b) _test_request_flags(__LINE__,a,b,FALSE)
322#define test_request_flags_todo(a,b) _test_request_flags(__LINE__,a,b,TRUE)
323static void _test_request_flags(unsigned line, HINTERNET req, DWORD exflags, BOOL is_todo)
324{
326 BOOL res;
327
328 flags = 0xdeadbeef;
329 size = sizeof(flags);
331 ok_(__FILE__,line)(res, "InternetQueryOptionW(INTERNET_OPTION_REQUEST_FLAGS) failed: %lu\n", GetLastError());
332
333 /* FIXME: Remove once we have INTERNET_REQFLAG_CACHE_WRITE_DISABLED implementation */
334 flags &= ~INTERNET_REQFLAG_CACHE_WRITE_DISABLED;
335 todo_wine_if (is_todo)
336 ok_(__FILE__,line)(flags == exflags, "flags = %lx, expected %lx\n", flags, exflags);
337}
338
339#define test_request_url(a,b) _test_request_url(__LINE__,a,b)
340static void _test_request_url(unsigned line, HINTERNET req, const char *expected_url)
341{
343 DWORD size = sizeof(buf);
344 BOOL res;
345
347 ok_(__FILE__,line)(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %lu\n", GetLastError());
348 ok_(__FILE__,line)(size == strlen(expected_url), "size = %lu\n", size);
349 ok_(__FILE__,line)(!strcmp(buf, expected_url), "unexpected URL %s, expected %s\n", buf, expected_url);
350}
351
352#define test_http_version(a) _test_http_version(__LINE__,a)
353static void _test_http_version(unsigned line, HINTERNET req)
354{
355 HTTP_VERSION_INFO v = {0xdeadbeef, 0xdeadbeef};
356 DWORD size;
357 BOOL res;
358
359 size = sizeof(v);
361 ok_(__FILE__,line)(res, "InternetQueryOptionW(INTERNET_OPTION_HTTP_VERSION) failed: %lu\n", GetLastError());
362 ok_(__FILE__,line)(v.dwMajorVersion == 1, "dwMajorVersion = %ld\n", v.dwMajorVersion);
363 ok_(__FILE__,line)(v.dwMinorVersion == 1, "dwMinorVersion = %ld\n", v.dwMinorVersion);
364}
365
367
369 HINTERNET hInternet,
370 DWORD_PTR dwContext,
371 DWORD dwInternetStatus,
372 LPVOID lpvStatusInformation,
373 DWORD dwStatusInformationLength
374)
375{
377 CHECK_EXPECT(dwInternetStatus);
378 switch (dwInternetStatus)
379 {
381 if(winetest_debug > 1)
382 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_RESOLVING_NAME \"%s\" %ld\n",
383 GetCurrentThreadId(), hInternet, dwContext,
384 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
385 *(LPSTR)lpvStatusInformation = '\0';
386 break;
388 if(winetest_debug > 1)
389 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_NAME_RESOLVED \"%s\" %ld\n",
390 GetCurrentThreadId(), hInternet, dwContext,
391 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
392 *(LPSTR)lpvStatusInformation = '\0';
393 break;
395 if(winetest_debug > 1)
396 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %ld\n",
397 GetCurrentThreadId(), hInternet, dwContext,
398 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
399 ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %lu\n",
400 dwStatusInformationLength);
401 *(LPSTR)lpvStatusInformation = '\0';
402 break;
404 if(winetest_debug > 1)
405 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %ld\n",
406 GetCurrentThreadId(), hInternet, dwContext,
407 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
408 ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %lu\n",
409 dwStatusInformationLength);
410 *(LPSTR)lpvStatusInformation = '\0';
411 break;
413 if(winetest_debug > 1)
414 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_SENDING_REQUEST %p %ld\n",
415 GetCurrentThreadId(), hInternet, dwContext,
416 lpvStatusInformation,dwStatusInformationLength);
417 break;
419 ok(dwStatusInformationLength == sizeof(DWORD),
420 "info length should be sizeof(DWORD) instead of %ld\n",
421 dwStatusInformationLength);
422 if(winetest_debug > 1)
423 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_REQUEST_SENT 0x%lx %ld\n",
424 GetCurrentThreadId(), hInternet, dwContext,
425 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
426 break;
428 if(winetest_debug > 1)
429 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_RECEIVING_RESPONSE %p %ld\n",
430 GetCurrentThreadId(), hInternet, dwContext,
431 lpvStatusInformation,dwStatusInformationLength);
432 break;
434 ok(dwStatusInformationLength == sizeof(DWORD),
435 "info length should be sizeof(DWORD) instead of %ld\n",
436 dwStatusInformationLength);
437 if(winetest_debug > 1)
438 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_RESPONSE_RECEIVED 0x%lx %ld\n",
439 GetCurrentThreadId(), hInternet, dwContext,
440 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
441 break;
443 if(winetest_debug > 1)
444 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_CTL_RESPONSE_RECEIVED %p %ld\n",
445 GetCurrentThreadId(), hInternet,dwContext,
446 lpvStatusInformation,dwStatusInformationLength);
447 break;
449 if(winetest_debug > 1)
450 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_PREFETCH %p %ld\n",
451 GetCurrentThreadId(), hInternet, dwContext,
452 lpvStatusInformation,dwStatusInformationLength);
453 break;
455 if(winetest_debug > 1)
456 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_CLOSING_CONNECTION %p %ld\n",
457 GetCurrentThreadId(), hInternet, dwContext,
458 lpvStatusInformation,dwStatusInformationLength);
459 break;
461 if(winetest_debug > 1)
462 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_CONNECTION_CLOSED %p %ld\n",
463 GetCurrentThreadId(), hInternet, dwContext,
464 lpvStatusInformation,dwStatusInformationLength);
465 break;
467 ok(dwStatusInformationLength == sizeof(HINTERNET),
468 "info length should be sizeof(HINTERNET) instead of %ld\n",
469 dwStatusInformationLength);
470 if(winetest_debug > 1)
471 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_HANDLE_CREATED %p %ld\n",
472 GetCurrentThreadId(), hInternet, dwContext,
473 *(HINTERNET *)lpvStatusInformation,dwStatusInformationLength);
476 break;
478 ok(dwStatusInformationLength == sizeof(HINTERNET),
479 "info length should be sizeof(HINTERNET) instead of %ld\n",
480 dwStatusInformationLength);
481 if(winetest_debug > 1)
482 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_HANDLE_CLOSING %p %ld\n",
483 GetCurrentThreadId(), hInternet, dwContext,
484 *(HINTERNET *)lpvStatusInformation, dwStatusInformationLength);
487 break;
489 {
490 INTERNET_ASYNC_RESULT *iar = (INTERNET_ASYNC_RESULT *)lpvStatusInformation;
491 ok(dwStatusInformationLength == sizeof(INTERNET_ASYNC_RESULT),
492 "info length should be sizeof(INTERNET_ASYNC_RESULT) instead of %ld\n",
493 dwStatusInformationLength);
494 ok(iar->dwResult == 1 || iar->dwResult == 0, "iar->dwResult = %Id\n", iar->dwResult);
495 if(winetest_debug > 1)
496 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_REQUEST_COMPLETE {%Id,%ld} %ld\n",
497 GetCurrentThreadId(), hInternet, dwContext,
498 iar->dwResult,iar->dwError,dwStatusInformationLength);
499 req_error = iar->dwError;
502 break;
503 }
505 if(winetest_debug > 1)
506 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_REDIRECT \"%s\" %ld\n",
507 GetCurrentThreadId(), hInternet, dwContext,
508 (LPCSTR)lpvStatusInformation, dwStatusInformationLength);
509 *(LPSTR)lpvStatusInformation = '\0';
512 break;
514 if(winetest_debug > 1)
515 trace("%04lx:Callback %p 0x%Ix INTERNET_STATUS_INTERMEDIATE_RESPONSE %p %ld\n",
516 GetCurrentThreadId(), hInternet, dwContext,
517 lpvStatusInformation, dwStatusInformationLength);
518 break;
519 default:
520 if(winetest_debug > 1)
521 trace("%04lx:Callback %p 0x%Ix %ld %p %ld\n",
522 GetCurrentThreadId(), hInternet, dwContext, dwInternetStatus,
523 lpvStatusInformation, dwStatusInformationLength);
524 }
525}
526
527typedef struct {
532
533#define open_simple_request(a,b,c,d,e) _open_simple_request(__LINE__,a,b,c,d,e,FALSE)
534#define open_simple_request_proxy(a,b,c,d,e) _open_simple_request(__LINE__,a,b,c,d,e,TRUE)
535static void _open_simple_request(unsigned line, test_request_t *req, const char *host,
536 int port, const char *verb, const char *url, BOOL use_proxy)
537{
539 NULL, NULL, 0);
540 ok_(__FILE__,line)(req->session != NULL, "InternetOpenA failed: %lu\n", GetLastError());
541
543 ok_(__FILE__,line)(req->connection != NULL, "InternetConnectA failed: %lu\n", GetLastError());
544
545 req->request = HttpOpenRequestA(req->connection, verb, url, NULL, NULL, NULL, 0, 0);
546 ok_(__FILE__,line)(req->request != NULL, "HttpOpenRequest failed: %lu\n", GetLastError());
547}
548
549#define close_request(a) _close_request(__LINE__,a)
550static void _close_request(unsigned line, test_request_t *req)
551{
552 BOOL ret;
553
555 ok_(__FILE__,line)(ret, "InternetCloseHandle(request) failed: %lu\n", GetLastError());
557 ok_(__FILE__,line)(ret, "InternetCloseHandle(connection) failed: %lu\n", GetLastError());
559 ok_(__FILE__,line)(ret, "InternetCloseHandle(session) failed: %lu\n", GetLastError());
560}
561
562#define receive_simple_request(a,b,c) _receive_simple_request(__LINE__,a,b,c)
563static DWORD _receive_simple_request(unsigned line, HINTERNET req, char *buf, size_t buf_size)
564{
565 DWORD read = 0;
566 BOOL ret;
567
568 ret = InternetReadFile(req, buf, buf_size, &read);
569 ok_(__FILE__,line)(ret, "InternetReadFile failed: %lu\n", GetLastError());
570
571 return read;
572}
573
574static void close_async_handle(HINTERNET handle, int handle_cnt)
575{
576 BOOL res;
577
578 close_handle_cnt = handle_cnt;
579
582 ok(res, "InternetCloseHandle failed: %lu\n", GetLastError());
585}
586
587static void InternetSetFilePointer_test(const char *host, const char *path)
588{
589 BYTE expect_response[8192], buf[8192];
590 HINTERNET hi = 0, hic = 0, hor = 0;
592 DWORD count, size, i, pos, err;
593
594 hi = InternetOpenA("Winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
595 ok(hi != 0x0, "InternetOpen failed: %lu\n", GetLastError());
596 if(hi == 0x0) goto abort;
597
600 ok(hic != 0x0, "InternetConnect failed: %lu\n", GetLastError());
601 if(hic == 0x0) goto abort;
602
603 hor = HttpOpenRequestA(hic, NULL, path, NULL, NULL, NULL,
605 0x0);
606 ok(hor != 0x0, "HttpOpenRequest failed: %lu\n", GetLastError());
607 if(hor == 0x0) goto abort;
608
609 res = HttpSendRequestA(hor, NULL, 0, NULL, 0);
610 ok(res, "HttpSendRequest failed: %lu\n", GetLastError());
611 if(!res) goto abort;
612
613 size = 0;
614 while(size < sizeof(expect_response)) {
615 res = InternetReadFile(hor, expect_response+size, sizeof(expect_response)-size, &count);
616 if(!res || !count)
617 break;
618 size += count;
619 }
620 ok(size, "InternetReadFile returned no content\n");
621 if(!size) goto abort;
622
626
627 reset_events();
628
629 hi = InternetOpenA("Winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
630 ok(hi != 0x0, "InternetOpen failed: %lu\n", GetLastError());
631 if(hi == 0x0) goto abort;
632
633 pInternetSetStatusCallbackA(hi, &callback);
634
637 NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0xdeadbeef);
638 ok(hic != 0x0, "InternetConnect failed: %lu\n", GetLastError());
639 if(hic == 0x0) goto abort;
641
643 hor = HttpOpenRequestA(hic, NULL, path, NULL, NULL, NULL,
645 0xdeadbead);
646 ok(hor != 0x0, "HttpOpenRequest failed: %lu\n", GetLastError());
647 if(hor == 0x0) goto abort;
649
650 /* NULL handle tests */
654 ok(expected, "Expected ERROR_INVALID_HANDLE. Got %lu\n", err);
658 ok(expected, "Expected ERROR_INVALID_HANDLE. Got %lu\n", err);
662 ok(expected, "Expected ERROR_INVALID_HANDLE. Got %lu\n", err);
663
664 /* INTERNET_FLAG_DONT_CACHE before sending request */
668 ok(expected, "Expected ERROR_INTERNET_INVALID_OPERATION. Got %lu\n", err);
672 ok(expected, "Expected ERROR_INTERNET_INVALID_OPERATION. Got %lu\n", err);
676 ok(expected, "Expected ERROR_INTERNET_INVALID_OPERATION. Got %lu\n", err);
677
680
685
686 res = HttpSendRequestA(hor, NULL, 0, NULL, 0);
687 err = !res ? GetLastError() : NO_ERROR;
688 expected = res && err == NO_ERROR;
689 ok(expected, "HttpSendRequest failed: %lu\n", err);
690
695
696 /* INTERNET_FLAG_DONT_CACHE after sending request */
700 ok(expected, "Expected ERROR_INTERNET_INVALID_OPERATION. Got %lu\n", err);
704 ok(expected, "Expected ERROR_INTERNET_INVALID_OPERATION. Got %lu\n", err);
708 ok(expected, "Expected ERROR_INTERNET_INVALID_OPERATION. Got %lu\n", err);
709
712
714 hor = HttpOpenRequestA(hic, NULL, path, NULL, NULL, NULL,
716 0xdeadbead);
717 ok(hor != 0x0, "HttpOpenRequest failed: %lu\n", GetLastError());
718 if(hor == 0x0) goto abort;
720
723
728
729 res = HttpSendRequestA(hor, NULL, 0, NULL, 0);
730 err = !res ? GetLastError() : NO_ERROR;
731 expected = res && err == NO_ERROR;
732 ok(expected, "HttpSendRequest failed: %lu\n", err);
733
738
739 /* FILE_BEGIN tests */
740 i = 0;
741 while(i < min(size, 4)) {
746 expected = pos == i && err == NO_ERROR;
747 ok(expected, "Expected position %#lx. Got %#lx. GetLastError() %lu\n", i, pos, err);
748 res = InternetReadFile(hor, buf, sizeof(buf), &count);
749 err = !res ? GetLastError() : NO_ERROR;
750 ok(res, "InternetReadFile failed: %lu\n", err);
751 ok(count, "InternetReadFile returned no content\n");
752 ok(!memcmp(expect_response+i, buf, min(sizeof(buf)-i, count)),
753 "Unexpected result from InternetReadFile\n");
754 i = i + 1;
755 }
756 while(i > 0) {
761 expected = pos == i && err == NO_ERROR;
762 ok(expected, "Expected position %#lx. Got %#lx. GetLastError() %lu\n", i, pos, err);
763 res = InternetReadFile(hor, buf, sizeof(buf), &count);
764 err = !res ? GetLastError() : NO_ERROR;
765 ok(res, "InternetReadFile failed: %lu\n", err);
766 ok(!memcmp(expect_response+i, buf, min(sizeof(buf)-i, count)),
767 "Unexpected result from InternetReadFile\n");
768 i = i - 1;
769 }
770 SetLastError(0xdeadbeef);
773 expected = pos == INT_MAX && err == NO_ERROR;
774 ok(expected, "Expected position %#x. Got %#lx. GetLastError() %lu\n", INT_MAX, pos, err);
775 SetLastError(0xdeadbeef);
778 expected = pos == -1 && err == NO_ERROR;
779 ok(expected, "Expected position %#x. Got %#lx. GetLastError() %lu\n", -1, pos, err);
780
781 /* FILE_CURRENT tests */
782 i = 0;
783 while(i < min(size, 4)) {
786 i = i + 1;
789 expected = pos == 0 && err == NO_ERROR;
790 ok(expected, "Expected position %#lx. Got %#lx. GetLastError() %lu\n", i, pos, err);
793 expected = pos == i && err == NO_ERROR;
794 ok(expected, "Expected position %#lx. Got %#lx. GetLastError() %lu\n", i, pos, err);
795 res = InternetReadFile(hor, buf, 1024, &count);
796 err = !res ? GetLastError() : NO_ERROR;
797 ok(res, "InternetReadFile failed: %lu\n", err);
798 ok(!memcmp(expect_response+i, buf, min(sizeof(buf)-i, count)),
799 "Unexpected result from InternetReadFile\n");
800 }
804 ok(expected, "Expected ERROR_NEGATIVE_SEEK. Got %lu\n", err);
807 expected = pos == 0 && err == NO_ERROR;
808 ok(expected, "Expected position %#x. Got %#lx. GetLastError() %lu\n", 0, pos, err);
811 expected = pos == -1 && err == NO_ERROR;
812 ok(expected, "Expected position %#x. Got %#lx. GetLastError() %lu\n", -1, pos, err);
816 ok(expected, "Expected ERROR_NEGATIVE_SEEK. Got %lu\n", err);
817
818 /* FILE_END tests */
821 expected = pos == size && err == NO_ERROR;
822 todo_wine ok(expected, "Expected position %#lx. Got %#lx. GetLastError() %lu\n", size, pos, err);
823 i = 0;
824 while(i < min(size, 4)) {
827 i = i + 1;
830 expected = pos == size+i && err == NO_ERROR;
831 todo_wine ok(expected, "Expected position %#lx. Got %#lx. GetLastError() %lu\n",
832 size+i, pos, err);
833 }
834 i = 0;
835 while(i < min(size, 4)) {
838 i = i + 1;
842 todo_wine ok(expected, "Expected ERROR_NEGATIVE_SEEK. Got %lu\n", err);
843 }
844
847
848abort:
852 if(hor) InternetCloseHandle(hor);
854 if(hic) InternetCloseHandle(hic);
855 if(hi) InternetCloseHandle(hi);
856}
857
859{
860 char *post_data = NULL;
861 BOOL res, on_async = TRUE;
862 CHAR buffer[4000];
863 WCHAR wbuffer[4000];
864 DWORD length, length2, index, exlen = 0, post_len = 0;
865 const char *types[2] = { "*", NULL };
866 HINTERNET hi, hic = 0, hor = 0;
867 DWORD contents_length, accepts_ranges;
868 BOOL not_supported;
869
870 trace("Starting InternetReadFile test with flags 0x%x on url %s\n",flags,test->url);
871 reset_events();
872
873 hi = InternetOpenA((test->flags & TESTF_COMPRESSED) ? "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" : "",
875 ok((hi != 0x0),"InternetOpen failed with error %lu\n", GetLastError());
876
877 if (hi == 0x0) goto abort;
878
879 pInternetSetStatusCallbackA(hi,&callback);
880
882
884 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
885 ok((hic != 0x0),"InternetConnect failed with error %lu\n", GetLastError());
886
887 if (hic == 0x0) goto abort;
888
891
892 hor = HttpOpenRequestA(hic, test->post_data ? "POST" : "GET", test->path, NULL, NULL, types,
894 0xdeadbead);
895 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
896 /*
897 * If the internet name can't be resolved we are probably behind
898 * a firewall or in some other way not directly connected to the
899 * Internet. Not enough reason to fail the test. Just ignore and
900 * abort.
901 */
902 } else {
903 ok((hor != 0x0),"HttpOpenRequest failed with error %lu\n", GetLastError());
904 }
905
906 if (hor == 0x0) goto abort;
907
909 test_request_url(hor, test->url);
910
911 length = sizeof(buffer);
913 ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %ld\n", GetLastError());
914 ok(length == 0 || (length == 1 && !*buffer) /* win10 */, "HTTP_QUERY_RAW_HEADERS: expected length 0, but got %ld\n", length);
915 ok(!strcmp(buffer, ""), "HTTP_QUERY_RAW_HEADERS: expected string \"\", but got \"%s\"\n", buffer);
916
923 {
926 }
933 if(test->flags & TESTF_REDIRECT) {
936 }
942
943 if(test->flags & TESTF_COMPRESSED) {
944 BOOL b = TRUE;
945
948 "InternetSetOption failed: %lu\n", GetLastError());
949 if(!res)
950 goto abort;
951 }
952
953 test_status_code(hor, 0);
954
955 if(test->post_data) {
956 post_len = strlen(test->post_data);
957 post_data = HeapAlloc(GetProcessHeap(), 0, post_len);
958 memcpy(post_data, test->post_data, post_len);
959 }
960 SetLastError(0xdeadbeef);
961 res = HttpSendRequestA(hor, test->headers, -1, post_data, post_len);
964 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
965 else
967 "Synchronous HttpSendRequest returning 0, error %lu\n", GetLastError());
968
971 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
972 }
974
978 {
979 if (! proxy_active())
980 {
983 }
984 else
985 {
988 }
989 }
990 else
991 {
994 }
999 if(test->flags & TESTF_REDIRECT)
1003 /* Sent on WinXP only if first_connection_to_test_url is TRUE, on Win98 always sent */
1006
1007 test_request_flags(hor, 0);
1008
1009 length = 100;
1011 ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed with error %ld\n", GetLastError());
1012
1013 length = sizeof(buffer)-2;
1014 memset(buffer, 0x77, sizeof(buffer));
1015 SetLastError(0xdeadbeef);
1017 ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %ld\n", GetLastError());
1018 ok(GetLastError() == 0 ||
1019 broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %lu\n", GetLastError());
1020 /* show that the function writes data past the length returned */
1021 ok(buffer[length-2], "Expected any header character, got 0x00\n");
1022 ok(!buffer[length-1], "Expected 0x00, got %02X\n", buffer[length-1]);
1023 ok(!buffer[length], "Expected 0x00, got %02X\n", buffer[length]);
1024 ok(buffer[length+1] == 0x77, "Expected 0x77, got %02X\n", buffer[length+1]);
1025
1026 length2 = length;
1027 res = HttpQueryInfoA(hor,HTTP_QUERY_RAW_HEADERS,buffer,&length2,0x0);
1028 ok(!res, "Expected 0x00, got %d\n", res);
1029 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %ld\n", GetLastError());
1030 ok(length2 == length+1, "Expected %ld, got %ld\n", length+1, length2);
1031 /* the in length of the buffer must be +1 but the length returned does not count this */
1032 length2 = length+1;
1033 memset(buffer, 0x77, sizeof(buffer));
1034 res = HttpQueryInfoA(hor,HTTP_QUERY_RAW_HEADERS,buffer,&length2,0x0);
1035 ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %ld\n", GetLastError());
1036 ok(buffer[length2] == 0x00, "Expected 0x00, got %02X\n", buffer[length2]);
1037 ok(buffer[length2+1] == 0x77, "Expected 0x77, got %02X\n", buffer[length2+1]);
1038 ok(length2 == length, "Value should not have changed: %ld != %ld\n", length2, length);
1039
1040 length = sizeof(wbuffer)-2*sizeof(WCHAR);
1041 memset(wbuffer, 0x77, sizeof(wbuffer));
1042 res = HttpQueryInfoW(hor, HTTP_QUERY_RAW_HEADERS, wbuffer, &length, 0x0);
1043 ok(res, "HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %ld\n", GetLastError());
1044 ok(length % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %ld.\n", length);
1045 length /= sizeof(WCHAR);
1046 /* show that the function writes data past the length returned */
1047 ok(wbuffer[length-2], "Expected any header character, got 0x0000\n");
1048 ok(!wbuffer[length-1], "Expected 0x0000, got %04X\n", wbuffer[length-1]);
1049 ok(!wbuffer[length], "Expected 0x0000, got %04X\n", wbuffer[length]);
1050 ok(wbuffer[length+1] == 0x7777 || broken(wbuffer[length+1] != 0x7777),
1051 "Expected 0x7777, got %04X\n", wbuffer[length+1]);
1052
1053 length2 = length*sizeof(WCHAR);
1054 res = HttpQueryInfoW(hor,HTTP_QUERY_RAW_HEADERS,wbuffer,&length2,0x0);
1055 ok(!res, "Expected 0x00, got %d\n", res);
1056 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %ld\n", GetLastError());
1057 ok(length2 % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %ld.\n", length2);
1058 length2 /= sizeof(WCHAR);
1059 ok(length2 == length+1, "Expected %ld, got %ld\n", length+1, length2);
1060 /* the in length of the buffer must be +1 but the length returned does not count this */
1061 length2 = (length+1)*sizeof(WCHAR);
1062 memset(wbuffer, 0x77, sizeof(wbuffer));
1063 res = HttpQueryInfoW(hor,HTTP_QUERY_RAW_HEADERS,wbuffer,&length2,0x0);
1064 ok(res, "HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %ld\n", GetLastError());
1065 ok(length2 % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %ld.\n", length2);
1066 length2 /= sizeof(WCHAR);
1067 ok(!wbuffer[length2], "Expected 0x0000, got %04X\n", wbuffer[length2]);
1068 ok(wbuffer[length2+1] == 0x7777, "Expected 0x7777, got %04X\n", wbuffer[length2+1]);
1069 ok(length2 == length, "Value should not have changed: %ld != %ld\n", length2, length);
1070
1071 test_request_url(hor, test->redirected_url);
1072
1073 index = 0;
1074 length = 0;
1075 SetLastError(0xdeadbeef);
1076 ok(HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,NULL,&length,&index) == FALSE,"Query worked\n");
1077 if(test->flags & TESTF_COMPRESSED)
1079 "expected ERROR_HTTP_HEADER_NOT_FOUND, got %lu\n", GetLastError());
1080 ok(index == 0, "Index was incremented\n");
1081
1082 index = 0;
1083 length = 16;
1085 trace("Option HTTP_QUERY_CONTENT_LENGTH -> %i %s (%lu)\n",res,buffer,GetLastError());
1086 if(test->flags & TESTF_COMPRESSED)
1087 {
1089 "expected ERROR_HTTP_HEADER_NOT_FOUND, got %x (%lu)\n", res, GetLastError());
1090 contents_length = 0;
1091 }
1092 else
1093 {
1094 contents_length = atoi(buffer);
1095 }
1096 ok(!res || index == 1, "Index was not incremented although result is %x (index = %lu)\n", res, index);
1097
1098 length = 64;
1099 *buffer = 0;
1101 trace("Option HTTP_QUERY_ACCEPT_RANGES -> %i %s (%lu)\n",res,buffer,GetLastError());
1102 accepts_ranges = res && !strcmp(buffer, "bytes");
1103
1104 length = 100;
1106 buffer[length]=0;
1107 trace("Option HTTP_QUERY_CONTENT_TYPE -> %i %s\n",res,buffer);
1108
1109 length = 100;
1111 buffer[length]=0;
1112 trace("Option HTTP_QUERY_CONTENT_ENCODING -> %i %s\n",res,buffer);
1113
1114 SetLastError(0xdeadbeef);
1116 not_supported = length == INVALID_SET_FILE_POINTER
1118 if (accepts_ranges)
1119 todo_wine ok((length == contents_length && (GetLastError() == ERROR_SUCCESS
1120 || broken(GetLastError() == 0xdeadbeef))) || broken(not_supported),
1121 "Got unexpected length %#lx, GetLastError() %lu, contents_length %lu, accepts_ranges %#lx.\n",
1122 length, GetLastError(), contents_length, accepts_ranges);
1123 else
1124 ok(not_supported, "Got unexpected length %#lx, GetLastError() %lu.\n", length, GetLastError());
1125
1127 {
1128 SetLastError(0xdeadbeef);
1130 ok(!length && (GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef)),
1131 "Got unexpected length %#lx, GetLastError() %lu.\n", length, GetLastError());
1132 }
1133
1134 SetLastError(0xdeadbeef);
1136 ok(!res, "InternetReadFile should have failed\n");
1138 "InternetReadFile should have set last error to ERROR_INVALID_HANDLE instead of %lu\n",
1139 GetLastError());
1140
1141 SetLastError(0xdeadbeef);
1142 res = InternetReadFile(hor, buffer, 100, NULL);
1143 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER, "got res %d, error %lu.\n", res, GetLastError());
1144
1145 SetLastError(0xdeadbeef);
1146 length = 0xdeadbeef;
1147 res = InternetReadFile(hor, NULL, 100, &length);
1148 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER, "got res %d, error %lu.\n", res, GetLastError());
1149 ok(!length, "got %lu.\n", length);
1150
1151 SetLastError(0xdeadbeef);
1152 length = 0xdeadbeef;
1153 res = InternetReadFile(hor, NULL, 0, &length);
1154 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER, "got res %d, error %lu.\n", res, GetLastError());
1155 ok(!length, "got %lu.\n", length);
1156
1157 length = 100;
1158 if(winetest_debug > 1)
1159 trace("Entering Query loop\n");
1160
1161 while (TRUE)
1162 {
1165
1166 /* IE11 calls those in InternetQueryDataAvailable call. */
1169
1170 length = 0;
1171 res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
1172
1174
1176 {
1177 if (res)
1178 {
1180 if(exlen) {
1181 ok(length >= exlen, "length %lu < exlen %lu\n", length, exlen);
1182 exlen = 0;
1183 }
1184 }
1185 else if (GetLastError() == ERROR_IO_PENDING)
1186 {
1187 if(winetest_debug > 1)
1188 trace("pending\n");
1189 /* on some tests, InternetQueryDataAvailable returns non-zero length and ERROR_IO_PENDING */
1190 if(!(test->flags & TESTF_CHUNKED))
1191 ok(!length, "InternetQueryDataAvailable returned ERROR_IO_PENDING and %lu length\n", length);
1193 exlen = length;
1194 ok(exlen, "length = 0\n");
1197 ok(req_error, "req_error = 0\n");
1198 continue;
1199 }else {
1200 ok(0, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
1201 }
1202 }else {
1203 ok(res, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
1204 }
1206
1207 if(winetest_debug > 1)
1208 trace("length %lu\n", length);
1209 if(test->flags & TESTF_CHUNKED)
1210 ok(length <= 8192, "length = %ld, expected <= 8192\n", length);
1211 if (length)
1212 {
1213 char *buffer;
1215
1217
1218 buffer[length]=0;
1219
1220 if(winetest_debug > 1)
1221 trace("ReadFile -> %s %li\n", res ? "TRUE" : "FALSE", length);
1222
1223 if(test->content)
1224 ok(!strcmp(buffer, test->content), "buffer = '%s', expected '%s'\n", buffer, test->content);
1226 }else {
1227 ok(!on_async, "Returned zero size in response to request complete\n");
1228 break;
1229 }
1230 on_async = FALSE;
1231 }
1232 if(test->flags & TESTF_REDIRECT) {
1235 }
1236abort:
1237 if(winetest_debug > 1)
1238 trace("aborting\n");
1239 close_async_handle(hi, 2);
1241}
1242
1244{
1245 BOOL res;
1246 CHAR buffer[4000];
1247 DWORD length, got;
1248 const char *types[2] = { "*", NULL };
1249 HINTERNET hi, hic = 0, hor = 0;
1250
1251 trace("Starting InternetReadFile chunked test\n");
1252
1254 ok((hi != 0x0),"InternetOpen failed with error %lu\n", GetLastError());
1255
1256 if (hi == 0x0) goto abort;
1257
1258 hic=InternetConnectA(hi, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER,
1259 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
1260 ok((hic != 0x0),"InternetConnect failed with error %lu\n", GetLastError());
1261
1262 if (hic == 0x0) goto abort;
1263
1264 hor = HttpOpenRequestA(hic, "GET", "/tests/chunked", NULL, NULL, types,
1266 0xdeadbead);
1267 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
1268 /*
1269 * If the internet name can't be resolved we are probably behind
1270 * a firewall or in some other way not directly connected to the
1271 * Internet. Not enough reason to fail the test. Just ignore and
1272 * abort.
1273 */
1274 } else {
1275 ok((hor != 0x0),"HttpOpenRequest failed with error %lu\n", GetLastError());
1276 }
1277
1278 if (hor == 0x0) goto abort;
1279
1280 SetLastError(0xdeadbeef);
1281 res = HttpSendRequestA(hor, "", -1, NULL, 0);
1283 "Synchronous HttpSendRequest returning 0, error %lu\n", GetLastError());
1284
1285 test_request_flags(hor, 0);
1286
1287 length = 100;
1289 buffer[length]=0;
1290 trace("Option CONTENT_TYPE -> %i %s\n",res,buffer);
1291
1292 SetLastError( 0xdeadbeef );
1293 length = 100;
1295 buffer[length]=0;
1296 trace("Option TRANSFER_ENCODING -> %i %s\n",res,buffer);
1298 "Failed to get TRANSFER_ENCODING option, error %lu\n", GetLastError() );
1299 ok( !strcmp( buffer, "chunked" ) || ( ! res && proxy_active() && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND ),
1300 "Wrong transfer encoding '%s'\n", buffer );
1301
1302 SetLastError( 0xdeadbeef );
1303 length = 16;
1305 ok( !res, "Found CONTENT_LENGTH option '%s'\n", buffer );
1306 ok( GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "Wrong error %lu\n", GetLastError() );
1307
1308 length = 100;
1309 trace("Entering Query loop\n");
1310
1311 while (TRUE)
1312 {
1313 res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
1314 ok(!(!res && length != 0),"InternetQueryDataAvailable failed with non-zero length\n");
1315 ok(res, "InternetQueryDataAvailable failed, error %ld\n", GetLastError());
1316 trace("got %lu available\n",length);
1317 if (length)
1318 {
1319 char *buffer = HeapAlloc(GetProcessHeap(),0,length+1);
1320
1321 SetLastError(0xdeadbeef);
1322 res = InternetReadFile(hor,buffer,length,&got);
1323 ok(GetLastError() == 0 ||
1324 broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %lu\n", GetLastError());
1325
1326 buffer[got]=0;
1327 trace("ReadFile -> %i %li\n",res,got);
1328 ok( length == got, "only got %lu of %lu available\n", got, length );
1329 ok( buffer[got-1] == '\n', "received partial line '%s'\n", buffer );
1330
1332 if (!got) break;
1333 }
1334 if (length == 0)
1335 {
1336 got = 0xdeadbeef;
1337 SetLastError(0xdeadbeef);
1338 res = InternetReadFile( hor, buffer, 1, &got );
1339 ok( res, "InternetReadFile failed: %lu\n", GetLastError() );
1340 ok(GetLastError() == 0 ||
1341 broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %lu\n", GetLastError());
1342 ok( !got, "got %lu\n", got );
1343 break;
1344 }
1345 }
1346abort:
1347 trace("aborting\n");
1348 if (hor != 0x0) {
1349 res = InternetCloseHandle(hor);
1350 ok (res, "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
1351 }
1352 if (hi != 0x0) {
1354 ok (res, "InternetCloseHandle of handle opened by InternetOpenA failed\n");
1355 }
1356}
1357
1359{
1360 DWORD rc;
1361 DWORD length;
1362 const char *types[2] = { "*", NULL };
1363 HINTERNET hi, hic = 0, hor = 0;
1364 INTERNET_BUFFERSA inetbuffers;
1365
1366 trace("Starting InternetReadFileExA test with flags 0x%x\n",flags);
1367 reset_events();
1368
1370 ok((hi != 0x0),"InternetOpen failed with error %lu\n", GetLastError());
1371
1372 if (hi == 0x0) goto abort;
1373
1374 pInternetSetStatusCallbackA(hi,&callback);
1375
1377
1378 hic=InternetConnectA(hi, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER,
1379 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
1380 ok((hic != 0x0),"InternetConnect failed with error %lu\n", GetLastError());
1381
1382 if (hic == 0x0) goto abort;
1383
1386
1387 hor = HttpOpenRequestA(hic, "GET", "/tests/redirect", NULL, NULL, types,
1389 0xdeadbead);
1390 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
1391 /*
1392 * If the internet name can't be resolved we are probably behind
1393 * a firewall or in some other way not directly connected to the
1394 * Internet. Not enough reason to fail the test. Just ignore and
1395 * abort.
1396 */
1397 } else {
1398 ok((hor != 0x0),"HttpOpenRequest failed with error %lu\n", GetLastError());
1399 }
1400
1401 if (hor == 0x0) goto abort;
1402
1407 {
1410 }
1425 else
1427
1428 SetLastError(0xdeadbeef);
1429 rc = HttpSendRequestA(hor, "", -1, NULL, 0);
1431 ok(((rc == 0)&&(GetLastError() == ERROR_IO_PENDING)),
1432 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
1433 else
1435 "Synchronous HttpSendRequest returning 0, error %lu\n", GetLastError());
1436
1437 if (!rc && (GetLastError() == ERROR_IO_PENDING)) {
1439 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
1440 }
1441
1443 {
1446 }
1447 else
1448 {
1451 }
1461 else
1464 /* Sent on WinXP only if first_connection_to_test_url is TRUE, on Win98 always sent */
1467
1468 if(is_ie7plus) {
1469 rc = InternetReadFileExW(hor, NULL, 0, 0xdeadcafe);
1471 "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %lu\n",
1472 rc ? "TRUE" : "FALSE", GetLastError());
1473 }
1474
1475 /* tests invalid dwStructSize */
1476 inetbuffers.dwStructSize = sizeof(inetbuffers)+1;
1477 inetbuffers.lpcszHeader = NULL;
1478 inetbuffers.dwHeadersLength = 0;
1479 inetbuffers.dwBufferLength = 10;
1480 inetbuffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, 10);
1481 inetbuffers.dwOffsetHigh = 1234;
1482 inetbuffers.dwOffsetLow = 5678;
1483 rc = InternetReadFileExA(hor, &inetbuffers, 0, 0xdeadcafe);
1485 "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %lu\n",
1486 rc ? "TRUE" : "FALSE", GetLastError());
1487 HeapFree(GetProcessHeap(), 0, inetbuffers.lpvBuffer);
1488
1489 test_request_flags(hor, 0);
1490
1491 /* tests to see whether lpcszHeader is used - it isn't */
1492 inetbuffers.dwStructSize = sizeof(inetbuffers);
1493 inetbuffers.lpcszHeader = (LPCSTR)0xdeadbeef;
1494 inetbuffers.dwHeadersLength = 255;
1495 inetbuffers.dwBufferLength = 0;
1496 inetbuffers.lpvBuffer = NULL;
1497 inetbuffers.dwOffsetHigh = 1234;
1498 inetbuffers.dwOffsetLow = 5678;
1499 rc = InternetReadFileExA(hor, &inetbuffers, 0, 0xdeadcafe);
1500 ok(rc, "InternetReadFileEx failed with error %lu\n", GetLastError());
1501 trace("read %li bytes\n", inetbuffers.dwBufferLength);
1502
1503 rc = InternetReadFileExA(NULL, &inetbuffers, 0, 0xdeadcafe);
1504 ok(!rc && (GetLastError() == ERROR_INVALID_HANDLE),
1505 "InternetReadFileEx should have failed with ERROR_INVALID_HANDLE instead of %s, %lu\n",
1506 rc ? "TRUE" : "FALSE", GetLastError());
1507
1508 length = 0;
1509 trace("Entering Query loop\n");
1510
1511 while (TRUE)
1512 {
1513 inetbuffers.dwStructSize = sizeof(inetbuffers);
1514 inetbuffers.dwBufferLength = 1024;
1515 inetbuffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, inetbuffers.dwBufferLength+1);
1516 inetbuffers.dwOffsetHigh = 1234;
1517 inetbuffers.dwOffsetLow = 5678;
1518
1522 rc = InternetReadFileExA(hor, &inetbuffers, IRF_ASYNC | IRF_USE_CONTEXT, 0xcafebabe);
1523 if (!rc)
1524 {
1526 {
1527 trace("InternetReadFileEx -> PENDING\n");
1529 "Should not get ERROR_IO_PENDING without INTERNET_FLAG_ASYNC\n");
1534 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
1535 }
1536 else
1537 {
1538 trace("InternetReadFileEx -> FAILED %lu\n", GetLastError());
1539 break;
1540 }
1541 }
1542 else
1543 {
1544 trace("InternetReadFileEx -> SUCCEEDED\n");
1546 if (inetbuffers.dwBufferLength)
1547 {
1550 }
1551 else
1552 {
1553 /* Win98 still sends these when 0 bytes are read, WinXP does not */
1556 }
1557 }
1558
1559 trace("read %li bytes\n", inetbuffers.dwBufferLength);
1560 ((char *)inetbuffers.lpvBuffer)[inetbuffers.dwBufferLength] = '\0';
1561
1562 ok(inetbuffers.dwOffsetHigh == 1234 && inetbuffers.dwOffsetLow == 5678,
1563 "InternetReadFileEx sets offsets to 0x%lx%08lx\n",
1564 inetbuffers.dwOffsetHigh, inetbuffers.dwOffsetLow);
1565
1566 HeapFree(GetProcessHeap(), 0, inetbuffers.lpvBuffer);
1567
1568 if (!inetbuffers.dwBufferLength)
1569 break;
1570
1571 length += inetbuffers.dwBufferLength;
1572 }
1573 ok(length > 0, "failed to read any of the document\n");
1574 trace("Finished. Read %ld bytes\n", length);
1575
1576abort:
1577 close_async_handle(hi, 2);
1579}
1580
1581static void InternetOpenUrlA_test(void)
1582{
1583 HINTERNET myhinternet, myhttp;
1584 char buffer[0x400];
1585 DWORD size, readbytes, totalbytes=0;
1586 BOOL ret;
1587
1590 "DeleteUrlCacheEntry returned %x, GetLastError() = %ld\n", ret, GetLastError());
1591
1592 myhinternet = InternetOpenA("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
1593 ok((myhinternet != 0), "InternetOpen failed, error %lu\n",GetLastError());
1594 size = 0x400;
1596 ok( ret, "InternetCanonicalizeUrl failed, error %lu\n",GetLastError());
1597
1598 SetLastError(0);
1599 myhttp = InternetOpenUrlA(myhinternet, TEST_URL, 0, 0,
1602 return; /* WinXP returns this when not connected to the net */
1603 ok((myhttp != 0),"InternetOpenUrl failed, error %lu\n",GetLastError());
1604 ret = InternetReadFile(myhttp, buffer,0x400,&readbytes);
1605 ok( ret, "InternetReadFile failed, error %lu\n",GetLastError());
1606 totalbytes += readbytes;
1607 while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
1608 totalbytes += readbytes;
1609 trace("read 0x%08lx bytes\n",totalbytes);
1610
1611 InternetCloseHandle(myhttp);
1612 InternetCloseHandle(myhinternet);
1613
1615 ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "INTERNET_FLAG_NO_CACHE_WRITE flag doesn't work\n");
1616}
1617
1618static void HttpSendRequestEx_test(void)
1619{
1620 HINTERNET hSession;
1621 HINTERNET hConnect;
1622 HINTERNET hRequest;
1623
1624 INTERNET_BUFFERSA BufferIn;
1625 DWORD dwBytesWritten, dwBytesRead, error;
1626 CHAR szBuffer[256];
1627 int i;
1628 BOOL ret;
1629
1630 static char szPostData[] = "mode=Test";
1631 static const char szContentType[] = "Content-Type: application/x-www-form-urlencoded";
1632
1633 hSession = InternetOpenA("Wine Regression Test",
1635 ok( hSession != NULL ,"Unable to open Internet session\n");
1636 hConnect = InternetConnectA(hSession, "test.winehq.org",
1638 0);
1639 ok( hConnect != NULL, "Unable to connect to http://test.winehq.org\n");
1640 hRequest = HttpOpenRequestA(hConnect, "POST", "/tests/post.php",
1642 if (!hRequest && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)
1643 {
1644 skip( "Network unreachable, skipping test\n" );
1645 goto done;
1646 }
1647 ok( hRequest != NULL, "Failed to open request handle err %lu\n", GetLastError());
1648
1650
1651 BufferIn.dwStructSize = sizeof(BufferIn);
1652 BufferIn.Next = (INTERNET_BUFFERSA*)0xdeadcab;
1653 BufferIn.lpcszHeader = szContentType;
1654 BufferIn.dwHeadersLength = sizeof(szContentType)-1;
1655 BufferIn.dwHeadersTotal = sizeof(szContentType)-1;
1656 BufferIn.lpvBuffer = szPostData;
1657 BufferIn.dwBufferLength = 3;
1658 BufferIn.dwBufferTotal = sizeof(szPostData)-1;
1659 BufferIn.dwOffsetLow = 0;
1660 BufferIn.dwOffsetHigh = 0;
1661
1662 SetLastError(0xdeadbeef);
1663 ret = HttpSendRequestExA(hRequest, &BufferIn, NULL, 0 ,0);
1664 error = GetLastError();
1665 ok(ret, "HttpSendRequestEx Failed with error %lu\n", error);
1666 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", error);
1667
1669
1670 for (i = 3; szPostData[i]; i++)
1671 ok(InternetWriteFile(hRequest, &szPostData[i], 1, &dwBytesWritten),
1672 "InternetWriteFile failed\n");
1673
1675
1676 ok(HttpEndRequestA(hRequest, NULL, 0, 0), "HttpEndRequest Failed\n");
1677
1678 test_request_flags(hRequest, 0);
1679
1680 ok(InternetReadFile(hRequest, szBuffer, 255, &dwBytesRead),
1681 "Unable to read response\n");
1682 szBuffer[dwBytesRead] = 0;
1683
1684 ok(dwBytesRead == 13,"Read %lu bytes instead of 13\n",dwBytesRead);
1685 ok(strncmp(szBuffer,"mode => Test\n",dwBytesRead)==0 || broken(proxy_active()),"Got string %s\n",szBuffer);
1686
1687 ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
1688done:
1689 ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
1690 ok(InternetCloseHandle(hSession), "Close session handle failed\n");
1691}
1692
1694{
1696 static const char *types[] = { "*", "", NULL };
1697 static const WCHAR slash[] = {'/', 0}, any[] = {'*', 0}, empty[] = {0};
1698 static const WCHAR *typesW[] = { any, empty, NULL };
1699 BOOL ret;
1700
1701 session = InternetOpenA("Wine Regression Test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
1702 ok(session != NULL ,"Unable to open Internet session\n");
1703
1705 INTERNET_SERVICE_HTTP, 0, 0);
1706 ok(connect == NULL, "InternetConnectA should have failed\n");
1707 ok(GetLastError() == ERROR_INVALID_PARAMETER, "InternetConnectA with NULL server named should have failed with ERROR_INVALID_PARAMETER instead of %ld\n", GetLastError());
1708
1710 INTERNET_SERVICE_HTTP, 0, 0);
1711 ok(connect == NULL, "InternetConnectA should have failed\n");
1712 ok(GetLastError() == ERROR_INVALID_PARAMETER, "InternetConnectA with blank server named should have failed with ERROR_INVALID_PARAMETER instead of %ld\n", GetLastError());
1713
1715 INTERNET_SERVICE_HTTP, 0, 0);
1716 ok(connect != NULL, "Unable to connect to http://test.winehq.org with error %ld\n", GetLastError());
1717
1720 {
1721 skip( "Network unreachable, skipping test\n" );
1722 goto done;
1723 }
1724 ok(request != NULL, "Failed to open request handle err %lu\n", GetLastError());
1725
1727 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
1728 ok(InternetCloseHandle(request), "Close request handle failed\n");
1729
1731 ok(request != NULL, "Failed to open request handle err %lu\n", GetLastError());
1732
1734 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
1735 ok(InternetCloseHandle(request), "Close request handle failed\n");
1736
1737done:
1738 ok(InternetCloseHandle(connect), "Close connect handle failed\n");
1739 ok(InternetCloseHandle(session), "Close session handle failed\n");
1740}
1741
1742static void test_cache_read(void)
1743{
1745 FILETIME now, tomorrow, yesterday;
1746 BYTE content[1000], buf[2000];
1747 char file_path[MAX_PATH];
1749 HANDLE file;
1750 DWORD size;
1751 unsigned i;
1752 BOOL res;
1753
1754 static const char cache_only_url[] = "http://test.winehq.org/tests/cache-only";
1755 BYTE cache_headers[] = "HTTP/1.1 200 OK\r\n\r\n";
1756
1757 trace("Testing cache read...\n");
1758 reset_events();
1759
1760 for(i = 0; i < sizeof(content); i++)
1761 content[i] = '0' + (i%10);
1762
1764 li.u.HighPart = now.dwHighDateTime;
1765 li.u.LowPart = now.dwLowDateTime;
1766 li.QuadPart += (LONGLONG)10000000 * 3600 * 24;
1767 tomorrow.dwHighDateTime = li.u.HighPart;
1768 tomorrow.dwLowDateTime = li.u.LowPart;
1769 li.QuadPart -= (LONGLONG)10000000 * 3600 * 24 * 2;
1770 yesterday.dwHighDateTime = li.u.HighPart;
1771 yesterday.dwLowDateTime = li.u.LowPart;
1772
1773 res = CreateUrlCacheEntryA(cache_only_url, sizeof(content), "", file_path, 0);
1774 ok(res, "CreateUrlCacheEntryA failed: %lu\n", GetLastError());
1775
1777 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
1778
1779 WriteFile(file, content, sizeof(content), &size, NULL);
1781
1782 res = CommitUrlCacheEntryA(cache_only_url, file_path, tomorrow, yesterday, NORMAL_CACHE_ENTRY,
1783 cache_headers, sizeof(cache_headers)-1, "", 0);
1784 ok(res, "CommitUrlCacheEntryA failed: %lu\n", GetLastError());
1785
1787 ok(session != NULL,"InternetOpen failed with error %lu\n", GetLastError());
1788
1789 pInternetSetStatusCallbackA(session, callback);
1790
1793 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
1794 ok(connection != NULL,"InternetConnect failed with error %lu\n", GetLastError());
1796
1798 req = HttpOpenRequestA(connection, "GET", "/tests/cache-only", NULL, NULL, NULL, 0, 0xdeadbead);
1799 ok(req != NULL, "HttpOpenRequest failed: %lu\n", GetLastError());
1801
1809
1810 res = HttpSendRequestA(req, NULL, -1, NULL, 0);
1811 todo_wine
1812 ok(res, "HttpSendRequest failed: %lu\n", GetLastError());
1813
1814 if(res) {
1815 size = 0;
1816 res = InternetQueryDataAvailable(req, &size, 0, 0);
1817 ok(res, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
1818 ok(size == sizeof(content), "size = %lu\n", size);
1819
1820 size = sizeof(buf);
1821 res = InternetReadFile(req, buf, sizeof(buf), &size);
1822 ok(res, "InternetReadFile failed: %lu\n", GetLastError());
1823 ok(size == sizeof(content), "size = %lu\n", size);
1824 ok(!memcmp(content, buf, sizeof(content)), "unexpected content\n");
1825 }
1826
1828
1836
1837 res = DeleteUrlCacheEntryA(cache_only_url);
1838 ok(res, "DeleteUrlCacheEntryA failed: %lu\n", GetLastError());
1839}
1840
1841static void test_http_cache(void)
1842{
1846 BYTE buf[100];
1847 HANDLE file;
1848 BOOL ret;
1849 FILETIME filetime_zero = {0};
1850
1851 static const char cached_content[] = "data read from cache";
1852 static const char *types[] = { "*", "", NULL };
1853
1854 session = InternetOpenA("Wine Regression Test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
1855 ok(session != NULL ,"Unable to open Internet session\n");
1856
1858 INTERNET_SERVICE_HTTP, 0, 0);
1859 ok(connect != NULL, "Unable to connect to http://test.winehq.org with error %ld\n", GetLastError());
1860
1863 {
1864 skip( "Network unreachable, skipping test\n" );
1865
1866 ok(InternetCloseHandle(connect), "Close connect handle failed\n");
1867 ok(InternetCloseHandle(session), "Close session handle failed\n");
1868
1869 return;
1870 }
1871 ok(request != NULL, "Failed to open request handle err %lu\n", GetLastError());
1872
1873 size = sizeof(url);
1875 ok(ret, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %lu\n", GetLastError());
1876 ok(!strcmp(url, "http://test.winehq.org/tests/hello.html"), "Wrong URL %s\n", url);
1877
1878 size = sizeof(file_name);
1880 ok(!ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
1881 ok(GetLastError() == ERROR_INTERNET_ITEM_NOT_FOUND, "GetLastError()=%lu\n", GetLastError());
1882 ok(!size, "size = %ld\n", size);
1883
1885 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
1886
1887 size = sizeof(file_name);
1889 ok(ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed: %lu\n", GetLastError());
1890
1893 ok(file != INVALID_HANDLE_VALUE, "Could not create file: %lu\n", GetLastError());
1895 ok(file_size == 106, "file size = %lu\n", file_size);
1896
1897 size = sizeof(buf);
1898 ret = InternetReadFile(request, buf, sizeof(buf), &size);
1899 ok(ret, "InternetReadFile failed: %lu\n", GetLastError());
1900 ok(size == 100, "size = %lu\n", size);
1901
1903 ok(file_size == 106, "file size = %lu\n", file_size);
1905
1907 ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%lu)\n", ret, GetLastError());
1908
1909 ok(InternetCloseHandle(request), "Close request handle failed\n");
1910
1913 ok(file != INVALID_HANDLE_VALUE, "Could not create file: %lu\n", GetLastError());
1914 ret = WriteFile(file, cached_content, sizeof(cached_content), &size, NULL);
1915 ok(ret && size, "WriteFile failed: %d, %ld\n", ret, size);
1916 ret = CommitUrlCacheEntryA(url, file_name, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, NULL, 0);
1917 ok(ret, "CommitUrlCacheEntry failed: %ld\n", GetLastError());
1919
1920 /* Send the same request, requiring it to be retrieved from the cache */
1921 request = HttpOpenRequestA(connect, "GET", "/tests/hello.html", NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
1922
1924 ok(ret, "HttpSendRequest failed\n");
1925
1926 size = sizeof(buf);
1927 ret = InternetReadFile(request, buf, sizeof(buf), &size);
1928 ok(ret, "InternetReadFile failed: %lu\n", GetLastError());
1929 ok(size == 100, "size = %lu\n", size);
1930 buf[99] = 0;
1931 todo_wine ok(!strcmp((char*)buf, cached_content), "incorrect page data: %s\n", (char*)buf);
1932
1933 ok(InternetCloseHandle(request), "Close request handle failed\n");
1934
1936 request = HttpOpenRequestA(connect, "GET", "/tests/hello.html", NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
1938 todo_wine ok(!ret, "HttpSendRequest succeeded\n");
1939 if(!ret)
1940 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() = %ld\n", GetLastError());
1941 ok(InternetCloseHandle(request), "Close request handle failed\n");
1942
1944 ok(request != NULL, "Failed to open request handle err %lu\n", GetLastError());
1945
1946 size = sizeof(file_name);
1948 ok(!ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
1949 ok(GetLastError() == ERROR_INTERNET_ITEM_NOT_FOUND, "GetLastError()=%lu\n", GetLastError());
1950 ok(!size, "size = %ld\n", size);
1951
1953 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
1954
1955 size = sizeof(file_name);
1956 file_name[0] = 0;
1958 if (ret)
1959 {
1962 ok(file != INVALID_HANDLE_VALUE, "Could not create file: %lu\n", GetLastError());
1964 }
1965 else
1966 {
1967 /* < IE8 */
1968 ok(file_name[0] == 0, "Didn't expect a file name\n");
1969 }
1970
1971 ok(InternetCloseHandle(request), "Close request handle failed\n");
1972 ok(InternetCloseHandle(connect), "Close connect handle failed\n");
1973 ok(InternetCloseHandle(session), "Close session handle failed\n");
1974
1976}
1977
1979{
1980 char file_name[MAX_PATH];
1981 test_request_t req;
1982 HANDLE lock, lock2;
1983 DWORD size;
1984 BOOL ret;
1985
1986 open_simple_request(&req, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, "/tests/hello.html");
1987
1988 size = sizeof(file_name);
1990 ok(!ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
1991 ok(GetLastError() == ERROR_INTERNET_ITEM_NOT_FOUND, "GetLastError()=%lu\n", GetLastError());
1992 ok(!size, "size = %ld\n", size);
1993
1994 lock = NULL;
1996 ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "InternetLockRequestFile returned: %x(%lu)\n", ret, GetLastError());
1997
1998 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
1999 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
2000
2001 size = sizeof(file_name);
2003 ok(ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed: %lu\n", GetLastError());
2004
2006 ok(ret, "InternetLockRequestFile returned: %x(%lu)\n", ret, GetLastError());
2007 ok(lock != NULL, "lock == NULL\n");
2008
2009 ret = InternetLockRequestFile(req.request, &lock2);
2010 ok(ret, "InternetLockRequestFile returned: %x(%lu)\n", ret, GetLastError());
2011 ok(lock == lock2, "lock != lock2\n");
2012
2014 ok(ret, "InternetUnlockRequestFile failed: %lu\n", GetLastError());
2015
2017 ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%lu)\n", ret, GetLastError());
2018
2019 ok(InternetCloseHandle(req.request), "Close request handle failed\n");
2020
2022 ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%lu)\n", ret, GetLastError());
2023
2025 ok(ret, "InternetUnlockRequestFile failed: %lu\n", GetLastError());
2026
2028 ok(ret, "Deleting file returned %x(%lu)\n", ret, GetLastError());
2029}
2030
2031static void HttpHeaders_test(void)
2032{
2033 HINTERNET hSession;
2034 HINTERNET hConnect;
2035 HINTERNET hRequest;
2036 CHAR buffer[256];
2037 WCHAR wbuffer[256];
2038 DWORD len = 256;
2039 DWORD oldlen;
2040 DWORD index = 0;
2041 BOOL ret;
2042
2043 hSession = InternetOpenA("Wine Regression Test",
2045 ok( hSession != NULL ,"Unable to open Internet session\n");
2046 hConnect = InternetConnectA(hSession, "test.winehq.org",
2048 0);
2049 ok( hConnect != NULL, "Unable to connect to http://test.winehq.org\n");
2050 hRequest = HttpOpenRequestA(hConnect, "POST", "/tests/post.php",
2052 if (!hRequest && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)
2053 {
2054 skip( "Network unreachable, skipping test\n" );
2055 goto done;
2056 }
2057 ok( hRequest != NULL, "Failed to open request handle\n");
2058
2059 index = 0;
2060 len = sizeof(buffer);
2061 strcpy(buffer,"Warning");
2063 buffer,&len,&index)==0,"Warning hearder reported as Existing\n");
2064
2065 ok(HttpAddRequestHeadersA(hRequest,"Warning:test1",-1,HTTP_ADDREQ_FLAG_ADD),
2066 "Failed to add new header\n");
2067
2068 index = 0;
2069 len = sizeof(buffer);
2070 strcpy(buffer,"Warning");
2072 buffer,&len,&index),"Unable to query header\n");
2073 ok(index == 1, "Index was not incremented\n");
2074 ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
2075 ok(len == 5, "Invalid length (exp. 5, got %ld)\n", len);
2076 ok((len < sizeof(buffer)) && (buffer[len] == 0), "Buffer not NULL-terminated\n"); /* len show only 5 characters but the buffer is NULL-terminated*/
2077 len = sizeof(buffer);
2078 strcpy(buffer,"Warning");
2080 buffer,&len,&index)==0,"Second Index Should Not Exist\n");
2081
2082 index = 0;
2083 len = 5; /* could store the string but not the NULL terminator */
2084 strcpy(buffer,"Warning");
2086 buffer,&len,&index) == FALSE,"Query succeeded on a too small buffer\n");
2087 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %ld\n", GetLastError());
2088 ok(index == 0, "Index was incremented\n");
2089 ok(strcmp(buffer,"Warning")==0, "incorrect string was returned(%s)\n",buffer); /* string not touched */
2090 ok(len == 6, "Invalid length (exp. 6, got %ld)\n", len); /* unlike success, the length includes the NULL-terminator */
2091
2092 /* a call with NULL will fail but will return the length */
2093 index = 0;
2094 len = sizeof(buffer);
2095 SetLastError(0xdeadbeef);
2097 NULL,&len,&index) == FALSE,"Query worked\n");
2098 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %ld\n", GetLastError());
2099 ok(len > 40, "Invalid length (exp. more than 40, got %ld)\n", len);
2100 ok(index == 0, "Index was incremented\n");
2101
2102 /* even for a len that is too small */
2103 index = 0;
2104 len = 15;
2105 SetLastError(0xdeadbeef);
2107 NULL,&len,&index) == FALSE,"Query worked\n");
2108 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %ld\n", GetLastError());
2109 ok(len > 40, "Invalid length (exp. more than 40, got %ld)\n", len);
2110 ok(index == 0, "Index was incremented\n");
2111
2112 index = 0;
2113 len = 0;
2114 SetLastError(0xdeadbeef);
2116 NULL,&len,&index) == FALSE,"Query worked\n");
2117 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %ld\n", GetLastError());
2118 ok(len > 40, "Invalid length (exp. more than 40, got %ld)\n", len);
2119 ok(index == 0, "Index was incremented\n");
2120 oldlen = len; /* bytes; at least long enough to hold buffer & nul */
2121
2122
2123 /* a working query */
2124 index = 0;
2125 len = sizeof(buffer);
2126 memset(buffer, 'x', sizeof(buffer));
2128 buffer,&len,&index),"Unable to query header\n");
2129 ok(len + sizeof(CHAR) <= oldlen, "Result longer than advertised\n");
2130 ok((len < sizeof(buffer)-sizeof(CHAR)) && (buffer[len/sizeof(CHAR)] == 0),"No NUL at end\n");
2131 ok(len == strlen(buffer) * sizeof(CHAR), "Length wrong\n");
2132 /* what's in the middle differs between Wine and Windows so currently we check only the beginning and the end */
2133 ok(strncmp(buffer, "POST /tests/post.php HTTP/1", 25)==0, "Invalid beginning of headers string\n");
2134 ok(strcmp(buffer + strlen(buffer) - 4, "\r\n\r\n")==0, "Invalid end of headers string\n");
2135 ok(index == 0, "Index was incremented\n");
2136
2137 /* Like above two tests, but for W version */
2138
2139 index = 0;
2140 len = 0;
2141 SetLastError(0xdeadbeef);
2143 NULL,&len,&index) == FALSE,"Query worked\n");
2144 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %ld\n", GetLastError());
2145 ok(len > 80, "Invalid length (exp. more than 80, got %ld)\n", len);
2146 ok(index == 0, "Index was incremented\n");
2147 oldlen = len; /* bytes; at least long enough to hold buffer & nul */
2148
2149 /* a working query */
2150 index = 0;
2151 len = sizeof(wbuffer);
2152 memset(wbuffer, 'x', sizeof(wbuffer));
2154 wbuffer,&len,&index),"Unable to query header\n");
2155 ok(len + sizeof(WCHAR) <= oldlen, "Result longer than advertised\n");
2156 ok(len == lstrlenW(wbuffer) * sizeof(WCHAR), "Length wrong\n");
2157 ok((len < sizeof(wbuffer)-sizeof(WCHAR)) && (wbuffer[len/sizeof(WCHAR)] == 0),"No NUL at end\n");
2158 ok(index == 0, "Index was incremented\n");
2159
2160 /* end of W version tests */
2161
2162 /* Without HTTP_QUERY_FLAG_REQUEST_HEADERS */
2163 index = 0;
2164 len = sizeof(buffer);
2165 memset(buffer, 'x', sizeof(buffer));
2167 buffer,&len,&index) == TRUE,"Query failed\n");
2168 ok(len == 2 || len == 4 /* win10 */, "Expected 2 or 4, got %ld\n", len);
2169 ok(memcmp(buffer, "\r\n\r\n", len) == 0, "Expected CRLF, got '%s'\n", buffer);
2170 ok(index == 0, "Index was incremented\n");
2171
2172 ok(HttpAddRequestHeadersA(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
2173 "Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
2174
2175 index = 0;
2176 len = sizeof(buffer);
2177 strcpy(buffer,"Warning");
2179 buffer,&len,&index),"Unable to query header\n");
2180 ok(index == 1, "Index was not incremented\n");
2181 ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
2182 len = sizeof(buffer);
2183 strcpy(buffer,"Warning");
2185 buffer,&len,&index),"Failed to get second header\n");
2186 ok(index == 2, "Index was not incremented\n");
2187 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
2188 len = sizeof(buffer);
2189 strcpy(buffer,"Warning");
2191 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2192
2193 ok(HttpAddRequestHeadersA(hRequest,"Warning:test3",-1,HTTP_ADDREQ_FLAG_REPLACE), "Failed to replace header using HTTP_ADDREQ_FLAG_REPLACE\n");
2194
2195 index = 0;
2196 len = sizeof(buffer);
2197 strcpy(buffer,"Warning");
2199 buffer,&len,&index),"Unable to query header\n");
2200 ok(index == 1, "Index was not incremented\n");
2201 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
2202 len = sizeof(buffer);
2203 strcpy(buffer,"Warning");
2205 buffer,&len,&index),"Failed to get second header\n");
2206 ok(index == 2, "Index was not incremented\n");
2207 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
2208 len = sizeof(buffer);
2209 strcpy(buffer,"Warning");
2211 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2212
2213 ok(HttpAddRequestHeadersA(hRequest,"Warning:test4",-1,HTTP_ADDREQ_FLAG_ADD_IF_NEW)==0, "HTTP_ADDREQ_FLAG_ADD_IF_NEW replaced existing header\n");
2214
2215 index = 0;
2216 len = sizeof(buffer);
2217 strcpy(buffer,"Warning");
2219 buffer,&len,&index),"Unable to query header\n");
2220 ok(index == 1, "Index was not incremented\n");
2221 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
2222 len = sizeof(buffer);
2223 strcpy(buffer,"Warning");
2225 buffer,&len,&index),"Failed to get second header\n");
2226 ok(index == 2, "Index was not incremented\n");
2227 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
2228 len = sizeof(buffer);
2229 strcpy(buffer,"Warning");
2231 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2232
2233 ok(HttpAddRequestHeadersA(hRequest,"Warning:test4",-1, HTTP_ADDREQ_FLAG_COALESCE), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
2234
2235 index = 0;
2236 len = sizeof(buffer);
2237 strcpy(buffer,"Warning");
2239 buffer,&len,&index),"Unable to query header\n");
2240 ok(index == 1, "Index was not incremented\n");
2241 ok(strcmp(buffer,"test2, test4")==0, "incorrect string was returned(%s)\n", buffer);
2242 len = sizeof(buffer);
2243 strcpy(buffer,"Warning");
2244 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
2245 ok(index == 2, "Index was not incremented\n");
2246 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
2247 len = sizeof(buffer);
2248 strcpy(buffer,"Warning");
2249 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2250
2251 ok(HttpAddRequestHeadersA(hRequest,"Warning:test5",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
2252
2253 index = 0;
2254 len = sizeof(buffer);
2255 strcpy(buffer,"Warning");
2256 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2257 ok(index == 1, "Index was not incremented\n");
2258 ok(strcmp(buffer,"test2, test4, test5")==0, "incorrect string was returned(%s)\n",buffer);
2259 len = sizeof(buffer);
2260 strcpy(buffer,"Warning");
2261 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
2262 ok(index == 2, "Index was not incremented\n");
2263 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
2264 len = sizeof(buffer);
2265 strcpy(buffer,"Warning");
2266 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2267
2268 ok(HttpAddRequestHeadersA(hRequest,"Warning:test6",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
2269
2270 index = 0;
2271 len = sizeof(buffer);
2272 strcpy(buffer,"Warning");
2273 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2274 ok(index == 1, "Index was not incremented\n");
2275 ok(strcmp(buffer,"test2, test4, test5; test6")==0, "incorrect string was returned(%s)\n",buffer);
2276 len = sizeof(buffer);
2277 strcpy(buffer,"Warning");
2278 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
2279 ok(index == 2, "Index was not incremented\n");
2280 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
2281 len = sizeof(buffer);
2282 strcpy(buffer,"Warning");
2283 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2284
2285 ok(HttpAddRequestHeadersA(hRequest,"Warning:test7",-1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE), "HTTP_ADDREQ_FLAG_ADD with HTTP_ADDREQ_FLAG_REPALCE Did not work\n");
2286
2287 index = 0;
2288 len = sizeof(buffer);
2289 strcpy(buffer,"Warning");
2290 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2291 ok(index == 1, "Index was not incremented\n");
2292 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
2293 len = sizeof(buffer);
2294 strcpy(buffer,"Warning");
2295 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
2296 ok(index == 2, "Index was not incremented\n");
2297 ok(strcmp(buffer,"test7")==0, "incorrect string was returned(%s)\n",buffer);
2298 len = sizeof(buffer);
2299 strcpy(buffer,"Warning");
2300 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2301
2302 /* Ensure that blank headers are ignored and don't cause a failure */
2303 ok(HttpAddRequestHeadersA(hRequest,"\r\nBlankTest:value\r\n\r\n",-1, HTTP_ADDREQ_FLAG_ADD_IF_NEW), "Failed to add header with blank entries in list\n");
2304
2305 index = 0;
2306 len = sizeof(buffer);
2307 strcpy(buffer,"BlankTest");
2308 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2309 ok(index == 1, "Index was not incremented\n");
2310 ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
2311
2312 /* Ensure that malformed header separators are ignored and don't cause a failure */
2313 ok(HttpAddRequestHeadersA(hRequest,"\r\rMalformedTest:value\n\nMalformedTestTwo: value2\rMalformedTestThree: value3\n\n\r\r\n",-1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE),
2314 "Failed to add header with malformed entries in list\n");
2315
2316 index = 0;
2317 len = sizeof(buffer);
2318 strcpy(buffer,"MalformedTest");
2319 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2320 ok(index == 1, "Index was not incremented\n");
2321 ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
2322 index = 0;
2323 len = sizeof(buffer);
2324 strcpy(buffer,"MalformedTestTwo");
2325 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2326 ok(index == 1, "Index was not incremented\n");
2327 ok(strcmp(buffer,"value2")==0, "incorrect string was returned(%s)\n",buffer);
2328 index = 0;
2329 len = sizeof(buffer);
2330 strcpy(buffer,"MalformedTestThree");
2331 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2332 ok(index == 1, "Index was not incremented\n");
2333 ok(strcmp(buffer,"value3")==0, "incorrect string was returned(%s)\n",buffer);
2334
2335 ret = HttpAddRequestHeadersA(hRequest, "Authorization: Basic\r\n", -1, HTTP_ADDREQ_FLAG_ADD);
2336 ok(ret, "unable to add header %lu\n", GetLastError());
2337
2338 index = 0;
2339 buffer[0] = 0;
2340 len = sizeof(buffer);
2342 ok(ret, "unable to query header %lu\n", GetLastError());
2343 ok(index == 1, "index was not incremented\n");
2344 ok(!strcmp(buffer, "Basic"), "incorrect string was returned (%s)\n", buffer);
2345
2346 ret = HttpAddRequestHeadersA(hRequest, "Authorization:\r\n", -1, HTTP_ADDREQ_FLAG_REPLACE);
2347 ok(ret, "unable to remove header %lu\n", GetLastError());
2348
2349 index = 0;
2350 len = sizeof(buffer);
2351 SetLastError(0xdeadbeef);
2353 "header still present\n");
2355
2356 /* Header with empty value should cause a failure */
2357 todo_wine
2358 {
2359 SetLastError(0xdeadbeef);
2360 ok(!HttpAddRequestHeadersA(hRequest, "EmptyTest1:", -1, HTTP_ADDREQ_FLAG_ADD), "Empty header should not be added.\n");
2361 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error code %lu.\n", GetLastError());
2362
2363 SetLastError(0xdeadbeef);
2364 ok(!HttpAddRequestHeadersA(hRequest, "EmptyTest2:\r\n", -1, HTTP_ADDREQ_FLAG_ADD), "Empty header should not be added.\n");
2365 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error code %lu.\n", GetLastError());
2366
2367 len = sizeof(buffer);
2368 strcpy(buffer, "EmptyTest1");
2369 SetLastError(0xdeadbeef);
2371 "Header with empty value is present.\n");
2372 ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "Got unexpected error code %lu.\n", GetLastError());
2373
2374 len = sizeof(buffer);
2375 strcpy(buffer, "EmptyTest2");
2376 SetLastError(0xdeadbeef);
2378 "Header with empty value is present.\n");
2379 ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "Got unexpected error code %lu.\n", GetLastError());
2380 }
2381
2382 ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
2383done:
2384 ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
2385 ok(InternetCloseHandle(hSession), "Close session handle failed\n");
2386}
2387
2388static const char garbagemsg[] =
2389"Garbage: Header\r\n";
2390
2391static const char contmsg[] =
2392"HTTP/1.1 100 Continue\r\n";
2393
2394static const char expandcontmsg[] =
2395"HTTP/1.1 100 Continue\r\n"
2396"Server: winecontinue\r\n"
2397"Tag: something witty\r\n";
2398
2399static const char okmsg[] =
2400"HTTP/1.1 200 OK\r\n"
2401"Server: winetest\r\n"
2402"\r\n";
2403
2404static const char okmsg201[] =
2405"HTTP/1.1 201 OK\r\n"
2406"Server: winetest\r\n"
2407"\r\n";
2408
2409static const char okmsg2[] =
2410"HTTP/1.1 200 OK\r\n"
2411"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n"
2412"Server: winetest\r\n"
2413"Content-Length: 0\r\n"
2414"Set-Cookie: one\r\n"
2415"Set-Cookie: two\r\n"
2416"Last-Modified: Mon, 01 Dec 2008 13:44:34 UTC\r\n"
2417"\r\n";
2418
2420static const char largemsg[] =
2421"HTTP/1.1 200 OK\r\n"
2422"Content-Length: %I64u\r\n"
2423"\r\n";
2424
2425static const char notokmsg[] =
2426"HTTP/1.1 400 Bad Request\r\n"
2427"Server: winetest\r\n"
2428"\r\n";
2429
2430static const char noauthmsg[] =
2431"HTTP/1.1 401 Unauthorized\r\n"
2432"Server: winetest\r\n"
2433"Connection: close\r\n"
2434"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
2435"\r\n";
2436
2437static const char noauthmsg2[] =
2438"HTTP/1.0 401 Anonymous requests or requests on unsecure channel are not allowed\r\n"
2439"HTTP/1.0 401 Anonymous requests or requests on unsecure channel are not allowed"
2440"\0d`0|6\n"
2441"Server: winetest\r\n";
2442
2443static const char proxymsg[] =
2444"HTTP/1.1 407 Proxy Authentication Required\r\n"
2445"Server: winetest\r\n"
2446"Proxy-Connection: close\r\n"
2447"Proxy-Authenticate: Basic realm=\"placebo\"\r\n"
2448"\r\n";
2449
2450static const char page1[] =
2451"<HTML>\r\n"
2452"<HEAD><TITLE>wininet test page</TITLE></HEAD>\r\n"
2453"<BODY>The quick brown fox jumped over the lazy dog<P></BODY>\r\n"
2454"</HTML>\r\n\r\n";
2455
2456static const char ok_with_length[] =
2457"HTTP/1.1 200 OK\r\n"
2458"Connection: Keep-Alive\r\n"
2459"Content-Length: 18\r\n\r\n"
2460"HTTP/1.1 211 OK\r\n\r\n";
2461
2462static const char ok_with_length2[] =
2463"HTTP/1.1 210 OK\r\n"
2464"Connection: Keep-Alive\r\n"
2465"Content-Length: 19\r\n\r\n"
2466"HTTP/1.1 211 OK\r\n\r\n";
2467
2468static const char proxy_pac[] =
2469"function FindProxyForURL(url, host) {\r\n"
2470" return 'PROXY localhost:%d';\r\n"
2471"}\r\n\r\n";
2472
2473struct server_info {
2475 int port;
2476};
2477
2479static const char *send_buffer;
2480static int server_socket;
2481
2483{
2484 struct server_info *si = param;
2485 int r, c = -1, i, on, count = 0;
2486 SOCKET s;
2487 struct sockaddr_in sa;
2488 char *buffer;
2489 size_t buffer_size;
2490 WSADATA wsaData;
2491 int last_request = 0;
2492 char host_header[22];
2493 char host_header_override[30];
2494 static int test_no_cache = 0;
2495
2496 WSAStartup(MAKEWORD(1,1), &wsaData);
2497
2498 s = socket(AF_INET, SOCK_STREAM, 0);
2499 if (s == INVALID_SOCKET)
2500 return 1;
2501
2502 on = 1;
2503 setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof on);
2504
2505 memset(&sa, 0, sizeof sa);
2506 sa.sin_family = AF_INET;
2507 sa.sin_port = htons(si->port);
2508 sa.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
2509
2510 r = bind(s, (struct sockaddr*) &sa, sizeof sa);
2511 if (r<0)
2512 return 1;
2513
2514 listen(s, 0);
2515
2516 SetEvent(si->hEvent);
2517
2518 sprintf(host_header, "Host: localhost:%d", si->port);
2519 sprintf(host_header_override, "Host: test.local:%d\r\n", si->port);
2521
2522 do
2523 {
2524 if(c == -1)
2525 c = accept(s, NULL, NULL);
2526
2528 for(i=0;; i++)
2529 {
2530 if(i == buffer_size)
2532
2533 r = recv(c, buffer+i, 1, 0);
2534 if (r != 1)
2535 break;
2536 if (i<4) continue;
2537 if (buffer[i-2] == '\n' && buffer[i] == '\n' &&
2538 buffer[i-3] == '\r' && buffer[i-1] == '\r')
2539 break;
2540 }
2541 if (strstr(buffer, "GET /test1"))
2542 {
2543 if (!strstr(buffer, "Content-Length: 0"))
2544 {
2545 send(c, okmsg, sizeof okmsg-1, 0);
2546 send(c, page1, sizeof page1-1, 0);
2547 }
2548 else
2549 send(c, notokmsg, sizeof notokmsg-1, 0);
2550 }
2551 if (strstr(buffer, "CONNECT "))
2552 {
2553 if (!strstr(buffer, "Content-Length: 0"))
2554 send(c, notokmsg, sizeof notokmsg-1, 0);
2555 else
2556 send(c, proxymsg, sizeof proxymsg-1, 0);
2557 }
2558 if (strstr(buffer, "/test2"))
2559 {
2560 if (strstr(buffer, "Proxy-Authorization: Basic bWlrZToxMTAx"))
2561 {
2562 send(c, okmsg, sizeof okmsg-1, 0);
2563 send(c, page1, sizeof page1-1, 0);
2564 }
2565 else
2566 send(c, proxymsg, sizeof proxymsg-1, 0);
2567 }
2568 if (strstr(buffer, "/test3"))
2569 {
2570 if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2571 send(c, okmsg, sizeof okmsg-1, 0);
2572 else
2573 send(c, noauthmsg, sizeof noauthmsg-1, 0);
2574 }
2575 if (strstr(buffer, "/test4"))
2576 {
2577 if (strstr(buffer, "Connection: Close"))
2578 send(c, okmsg, sizeof okmsg-1, 0);
2579 else
2580 send(c, notokmsg, sizeof notokmsg-1, 0);
2581 }
2582 if (strstr(buffer, "POST /test5") ||
2583 strstr(buffer, "RPC_IN_DATA /test5") ||
2584 strstr(buffer, "RPC_OUT_DATA /test5"))
2585 {
2586 if (strstr(buffer, "Content-Length: 0"))
2587 {
2588 send(c, okmsg, sizeof okmsg-1, 0);
2589 send(c, page1, sizeof page1-1, 0);
2590 }
2591 else
2592 send(c, notokmsg, sizeof notokmsg-1, 0);
2593 }
2594 if (strstr(buffer, "GET /test6"))
2595 {
2596 send(c, contmsg, sizeof contmsg-1, 0);
2597 send(c, contmsg, sizeof contmsg-1, 0);
2598 send(c, okmsg, sizeof okmsg-1, 0);
2599 send(c, page1, sizeof page1-1, 0);
2600 }
2601 if (strstr(buffer, "POST /test7"))
2602 {
2603 if (strstr(buffer, "Content-Length: 100"))
2604 {
2605 if (strstr(buffer, "POST /test7b"))
2607 send(c, okmsg, sizeof okmsg-1, 0);
2608 send(c, page1, sizeof page1-1, 0);
2609 }
2610 else
2611 send(c, notokmsg, sizeof notokmsg-1, 0);
2612 }
2613 if (strstr(buffer, "/test8"))
2614 {
2615 if (!strstr(buffer, "Connection: Close") &&
2616 strstr(buffer, "Connection: Keep-Alive") &&
2617 !strstr(buffer, "Cache-Control: no-cache") &&
2618 !strstr(buffer, "Pragma: no-cache") &&
2619 strstr(buffer, host_header))
2620 send(c, okmsg, sizeof okmsg-1, 0);
2621 else
2622 send(c, notokmsg, sizeof notokmsg-1, 0);
2623 }
2624 if (strstr(buffer, "/test9"))
2625 {
2626 if (!strstr(buffer, "Connection: Close") &&
2627 !strstr(buffer, "Connection: Keep-Alive") &&
2628 !strstr(buffer, "Cache-Control: no-cache") &&
2629 !strstr(buffer, "Pragma: no-cache") &&
2630 strstr(buffer, host_header))
2631 send(c, okmsg, sizeof okmsg-1, 0);
2632 else
2633 send(c, notokmsg, sizeof notokmsg-1, 0);
2634 }
2635 if (strstr(buffer, "/testA"))
2636 {
2637 if (!strstr(buffer, "Connection: Close") &&
2638 !strstr(buffer, "Connection: Keep-Alive") &&
2639 (strstr(buffer, "Cache-Control: no-cache") ||
2640 strstr(buffer, "Pragma: no-cache")) &&
2641 strstr(buffer, host_header))
2642 send(c, okmsg, sizeof okmsg-1, 0);
2643 else
2644 send(c, notokmsg, sizeof notokmsg-1, 0);
2645 }
2646 if (strstr(buffer, "/testC"))
2647 {
2648 if (strstr(buffer, "Cookie: cookie=biscuit"))
2649 send(c, okmsg, sizeof okmsg-1, 0);
2650 else
2651 send(c, notokmsg, sizeof notokmsg-1, 0);
2652 }
2653 if (strstr(buffer, "/testD"))
2654 {
2655 send(c, okmsg2, sizeof okmsg2-1, 0);
2656 }
2657 if (strstr(buffer, "/testE"))
2658 {
2659 send(c, noauthmsg2, sizeof noauthmsg2-1, 0);
2660 }
2661 if (strstr(buffer, "GET /quit"))
2662 {
2663 send(c, okmsg, sizeof okmsg-1, 0);
2664 send(c, page1, sizeof page1-1, 0);
2665 last_request = 1;
2666 }
2667 if (strstr(buffer, "GET /testF"))
2668 {
2669 send(c, expandcontmsg, sizeof expandcontmsg-1, 0);
2670 send(c, garbagemsg, sizeof garbagemsg-1, 0);
2671 send(c, contmsg, sizeof contmsg-1, 0);
2672 send(c, garbagemsg, sizeof garbagemsg-1, 0);
2673 send(c, okmsg, sizeof okmsg-1, 0);
2674 send(c, page1, sizeof page1-1, 0);
2675 }
2676 if (strstr(buffer, "GET /testG"))
2677 {
2678 send(c, page1, sizeof page1-1, 0);
2679 }
2680
2681 if (strstr(buffer, "GET /testJ"))
2682 {
2683 if (count == 0)
2684 {
2685 count++;
2686 send(c, ok_with_length, sizeof(ok_with_length)-1, 0);
2687 }
2688 else
2689 {
2690 send(c, ok_with_length2, sizeof(ok_with_length2)-1, 0);
2691 count = 0;
2692 }
2693 }
2694 if (strstr(buffer, "GET /testH"))
2695 {
2696 send(c, ok_with_length2, sizeof(ok_with_length2)-1, 0);
2698 send(c, ok_with_length, sizeof(ok_with_length)-1, 0);
2699 }
2700 if (strstr(buffer, "GET /test_no_content_content_length"))
2701 {
2702 static const char nocontentmsg[] = "HTTP/1.1 204 No Content\r\nConnection: close\r\n"
2703 "Content-Length: 10\r\n\r\n0123456789";
2704 send(c, nocontentmsg, sizeof(nocontentmsg)-1, 0);
2705 }
2706 else if (strstr(buffer, "GET /test_no_content"))
2707 {
2708 static const char nocontentmsg[] = "HTTP/1.1 204 No Content\r\nConnection: close\r\n\r\n"
2709 "0123456789";
2710 send(c, nocontentmsg, sizeof(nocontentmsg)-1, 0);
2711 }
2712 if (strstr(buffer, "GET /test_not_modified_content_length"))
2713 {
2714 static const char notmodifiedmsg[] = "HTTP/1.1 304 Not Modified\r\nConnection: close\r\n"
2715 "Content-Length: 10\r\n\r\n0123456789";
2716 send(c, notmodifiedmsg, sizeof(notmodifiedmsg)-1, 0);
2717 }
2718 else if (strstr(buffer, "GET /test_not_modified"))
2719 {
2720 static const char notmodifiedmsg[] = "HTTP/1.1 304 Not Modified\r\nConnection: close\r\n"
2721 "\r\n0123456789";
2722 send(c, notmodifiedmsg, sizeof(notmodifiedmsg)-1, 0);
2723 }
2724 if (strstr(buffer, "HEAD /head_content_length"))
2725 {
2726 static const char headmsg[] = "HTTP/1.1 200 OK\r\nConnection: close\r\n"
2727 "Content-Length: 10\r\n\r\n0123456789";
2728 send(c, headmsg, sizeof(headmsg)-1, 0);
2729 }
2730 else if (strstr(buffer, "HEAD /head"))
2731 {
2732 static const char headmsg[] = "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n0123456789";
2733 send(c, headmsg, sizeof(headmsg)-1, 0);
2734 }
2735 if (strstr(buffer, "GET /test_large_header"))
2736 {
2737 static const char allokmsg[] = "HTTP/1.1 200 OK\r\nServer: winetest\r\n";
2738 char header[4000 + sizeof("wine-header: ") - 1];
2739
2740 memset(header, 'A', sizeof(header));
2741 memcpy(header, "wine-header: ", sizeof("wine-header: ") - 1);
2742 send(c, allokmsg, sizeof(allokmsg) - 1, 0);
2743 send(c, header, sizeof(header), 0);
2744 send(c, "\r\n\r\n", 4, 0);
2745 }
2746 if (strstr(buffer, "GET /test_conn_close"))
2747 {
2748 static const char conn_close_response[] = "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\nsome content";
2749 send(c, conn_close_response, sizeof(conn_close_response)-1, 0);
2751 trace("closing connection\n");
2752 }
2753 if (strstr(buffer, "GET /test_cache_control_no_cache"))
2754 {
2755 static const char no_cache_response[] = "HTTP/1.1 200 OK\r\nCache-Control: no-cache\r\n\r\nsome content";
2756 if(!test_no_cache++)
2757 send(c, no_cache_response, sizeof(no_cache_response)-1, 0);
2758 else
2759 send(c, okmsg, sizeof(okmsg)-1, 0);
2760 }
2761 if (strstr(buffer, "GET /test_cache_control_no_store"))
2762 {
2763 static const char no_cache_response[] = "HTTP/1.1 200 OK\r\nCache-Control: junk, \t No-StOrE\r\n\r\nsome content";
2764 send(c, no_cache_response, sizeof(no_cache_response)-1, 0);
2765 }
2766 if (strstr(buffer, "GET /test_cache_gzip"))
2767 {
2768 static const char gzip_response[] = "HTTP/1.1 200 OK\r\nContent-Encoding: gzip\r\nContent-Type: text/html\r\n\r\n"
2769 "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x4b\xaf\xca\x2c\x50\x28"
2770 "\x49\x2d\x2e\xe1\x02\x00\x62\x92\xc7\x6c\x0a\x00\x00\x00";
2771 if(!test_cache_gzip++)
2772 send(c, gzip_response, sizeof(gzip_response), 0);
2773 else
2774 send(c, notokmsg, sizeof(notokmsg)-1, 0);
2775 }
2776 if (strstr(buffer, "HEAD /test_head")) {
2777 static const char head_response[] =
2778 "HTTP/1.1 200 OK\r\n"
2779 "Connection: Keep-Alive\r\n"
2780 "Content-Length: 100\r\n"
2781 "\r\n";
2782
2783 send(c, head_response, sizeof(head_response), 0);
2784 continue;
2785 }
2786 if (strstr(buffer, "GET /send_from_buffer"))
2788 if (strstr(buffer, "/test_cache_control_verb"))
2789 {
2790 if (!memcmp(buffer, "GET ", sizeof("GET ")-1) &&
2791 !strstr(buffer, "Cache-Control: no-cache\r\n")) send(c, okmsg, sizeof(okmsg)-1, 0);
2792 else if (strstr(buffer, "Cache-Control: no-cache\r\n")) send(c, okmsg, sizeof(okmsg)-1, 0);
2793 else send(c, notokmsg, sizeof(notokmsg)-1, 0);
2794 }
2795 if (strstr(buffer, "/test_request_content_length"))
2796 {
2797 static char msg[] = "HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\n\r\n";
2798 static int seen_content_length;
2799
2800 if (!seen_content_length)
2801 {
2802 if (strstr(buffer, "Content-Length: 0"))
2803 {
2804 seen_content_length = 1;
2805 send(c, msg, sizeof msg-1, 0);
2806 }
2807 else send(c, notokmsg, sizeof notokmsg-1, 0);
2809 }
2810 else
2811 {
2812 if (strstr(buffer, "Content-Length: 0")) send(c, msg, sizeof msg-1, 0);
2813 else send(c, notokmsg, sizeof notokmsg-1, 0);
2815 }
2816 }
2817 if (strstr(buffer, "GET /test_premature_disconnect"))
2818 trace("closing connection\n");
2819 if (strstr(buffer, "HEAD /upload.txt"))
2820 {
2821 if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2822 send(c, okmsg, sizeof okmsg-1, 0);
2823 else
2824 send(c, noauthmsg, sizeof noauthmsg-1, 0);
2825 }
2826 if (strstr(buffer, "PUT /upload2.txt"))
2827 {
2828 if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2829 send(c, okmsg, sizeof okmsg-1, 0);
2830 else
2831 send(c, notokmsg, sizeof notokmsg-1, 0);
2832 }
2833 if (strstr(buffer, "HEAD /upload3.txt"))
2834 {
2835 if (strstr(buffer, "Authorization: Basic dXNlcjE6cHdkMQ=="))
2836 send(c, okmsg, sizeof okmsg-1, 0);
2837 else
2838 send(c, noauthmsg, sizeof noauthmsg-1, 0);
2839 }
2840 if (strstr(buffer, "HEAD /upload4.txt"))
2841 {
2842 if (strstr(buffer, "Authorization: Bearer dXNlcjE6cHdkMQ=="))
2843 send(c, okmsg, sizeof okmsg-1, 0);
2844 else if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2845 send(c, okmsg201, sizeof okmsg-1, 0);
2846 else
2847 send(c, noauthmsg, sizeof noauthmsg-1, 0);
2848 }
2849 if (strstr(buffer, "/test_host_override"))
2850 {
2851 if (strstr(buffer, host_header_override))
2852 send(c, okmsg, sizeof okmsg-1, 0);
2853 else
2854 send(c, notokmsg, sizeof notokmsg-1, 0);
2855 }
2856 if (strstr(buffer, "/async_read"))
2857 {
2858 const char *page1_mid = page1 + (sizeof page1 - 1)/2;
2859 const char *page1_end = page1 + sizeof page1 - 1;
2860 send(c, okmsg, sizeof okmsg-1, 0);
2861 send(c, page1, page1_mid - page1, 0);
2863 send(c, page1_mid, page1_end - page1_mid, 0);
2864 }
2865 if (strstr(buffer, "/socket"))
2866 {
2867 server_socket = c;
2870 }
2871 if (strstr(buffer, "/echo_request"))
2872 {
2873 send(c, okmsg, sizeof(okmsg)-1, 0);
2874 send(c, buffer, strlen(buffer), 0);
2875 }
2876 if (strstr(buffer, "GET /test_remove_dot_segments"))
2877 {
2878 send(c, okmsg, sizeof(okmsg)-1, 0);
2879 }
2880 if (strstr(buffer, "HEAD /test_large_content"))
2881 {
2882 char msg[sizeof(largemsg) + 16];
2884 send(c, msg, strlen(msg), 0);
2885 }
2886 if (strstr(buffer, "GET /proxy.pac"))
2887 {
2888 char script[sizeof(proxy_pac) + 16];
2889 sprintf(script, proxy_pac, si->port);
2890 send(c, okmsg, sizeof(okmsg)-1, 0);
2891 send(c, script, strlen(script), 0);
2892 }
2893 if (strstr(buffer, "GET http://test.winehq.org/tests/hello.html"))
2894 {
2895 send(c, okmsg, sizeof(okmsg)-1, 0);
2896 send(c, page1, sizeof(page1)-1, 0);
2897 }
2898 shutdown(c, 2);
2899 closesocket(c);
2900 c = -1;
2901 } while (!last_request);
2902
2903 closesocket(s);
2905
2906 return 0;
2907}
2908
2909static void test_basic_request(int port, const char *verb, const char *url)
2910{
2911 test_request_t req;
2912 DWORD r, count, error;
2913 char buffer[0x100];
2914
2915 trace("basic request %s %s\n", verb, url);
2916
2917 open_simple_request(&req, "localhost", port, verb, url);
2918
2919 SetLastError(0xdeadbeef);
2920 r = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
2921 error = GetLastError();
2922 ok(error == ERROR_SUCCESS || broken(error != ERROR_SUCCESS), "expected ERROR_SUCCESS, got %lu\n", error);
2923 ok(r, "HttpSendRequest failed: %lu\n", GetLastError());
2924
2925 count = 0;
2926 memset(buffer, 0, sizeof buffer);
2927 SetLastError(0xdeadbeef);
2928 r = InternetReadFile(req.request, buffer, sizeof buffer, &count);
2929 ok(r, "InternetReadFile failed %lu\n", GetLastError());
2930 ok(count == sizeof page1 - 1, "count was wrong\n");
2931 ok(!memcmp(buffer, page1, sizeof page1), "http data wrong, got: %s\n", buffer);
2932
2933 close_request(&req);
2934}
2935
2937{
2938 test_request_t req;
2939 DWORD r, sz;
2940 char buffer[0x40];
2941
2942 open_simple_request(&req, "localhost", port, NULL, "/test2");
2943
2944 r = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
2945 ok(r, "HttpSendRequest failed %lu\n", GetLastError());
2946
2947 sz = sizeof buffer;
2949 ok(r || GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo failed: %ld\n", GetLastError());
2950 if (!r)
2951 {
2952 skip("missing proxy header, not testing remaining proxy headers\n");
2953 goto out;
2954 }
2955 ok(!strcmp(buffer, "Basic realm=\"placebo\""), "proxy auth info wrong\n");
2956
2957 test_status_code(req.request, 407);
2959
2960 sz = sizeof buffer;
2962 ok(r, "HttpQueryInfo failed\n");
2963 ok(!strcmp(buffer, "Proxy Authentication Required"), "proxy text wrong\n");
2964
2965 sz = sizeof buffer;
2967 ok(r, "HttpQueryInfo failed\n");
2968 ok(!strcmp(buffer, "HTTP/1.1"), "http version wrong\n");
2969
2970 sz = sizeof buffer;
2972 ok(r, "HttpQueryInfo failed\n");
2973 ok(!strcmp(buffer, "winetest"), "http server wrong\n");
2974
2975 sz = sizeof buffer;
2977 ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo should fail\n");
2978 ok(r == FALSE, "HttpQueryInfo failed\n");
2979
2980out:
2981 close_request(&req);
2982}
2983
2984static void test_proxy_direct(int port)
2985{
2986 HINTERNET hi, hc, hr;
2987 DWORD r, sz, error;
2988 char buffer[0x40], *url;
2989 WCHAR bufferW[0x40];
2990 static const char url_fmt[] = "http://test.winehq.org:%u/test2";
2991 static CHAR username[] = "mike",
2992 password[] = "1101",
2993 useragent[] = "winetest";
2994 static const WCHAR usernameW[] = {'m','i','k','e',0},
2995 passwordW[] = {'1','1','0','1',0},
2996 useragentW[] = {'w','i','n','e','t','e','s','t',0};
2997
2998 /* specify proxy type without the proxy and bypass */
2999 SetLastError(0xdeadbeef);
3001 error = GetLastError();
3003 broken(error == ERROR_SUCCESS) /* WinXPProSP2 */, "got %lu\n", error);
3004 ok(hi == NULL || broken(!!hi) /* WinXPProSP2 */, "open should have failed\n");
3005
3006 sprintf(buffer, "localhost:%d\n", port);
3008 ok(hi != NULL, "open failed\n");
3009
3010 /* try connect without authorization */
3011 hc = InternetConnectA(hi, "test.winehq.org", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3012 ok(hc != NULL, "connect failed\n");
3013
3014 hr = HttpOpenRequestA(hc, NULL, "/test2", NULL, NULL, NULL, 0, 0);
3015 ok(hr != NULL, "HttpOpenRequest failed\n");
3016
3017 sz = 0;
3018 SetLastError(0xdeadbeef);
3021 ok(!r, "unexpected success\n");
3022 ok(sz == 1, "got %lu\n", sz);
3023
3024 sz = 0;
3025 SetLastError(0xdeadbeef);
3028 ok(!r, "unexpected success\n");
3029 ok(sz == 1, "got %lu\n", sz);
3030
3031 sz = sizeof(buffer);
3032 SetLastError(0xdeadbeef);
3034 ok(r, "unexpected failure %lu\n", GetLastError());
3035 ok(!sz, "got %lu\n", sz);
3036
3037 sz = sizeof(buffer);
3038 SetLastError(0xdeadbeef);
3040 ok(r, "unexpected failure %lu\n", GetLastError());
3041 ok(!sz, "got %lu\n", sz);
3042
3043 sz = 0;
3044 SetLastError(0xdeadbeef);
3047 ok(!r, "unexpected success\n");
3048 ok(sz == 1, "got %lu\n", sz);
3049
3050 sz = 0;
3051 SetLastError(0xdeadbeef);
3054 ok(!r, "unexpected success\n");
3055 ok(sz == 1, "got %lu\n", sz);
3056
3057 sz = sizeof(buffer);
3058 SetLastError(0xdeadbeef);
3060 ok(r, "unexpected failure %lu\n", GetLastError());
3061 ok(!sz, "got %lu\n", sz);
3062
3063 sz = sizeof(buffer);
3064 SetLastError(0xdeadbeef);
3066 ok(r, "unexpected failure %lu\n", GetLastError());
3067 ok(!sz, "got %lu\n", sz);
3068
3069 sz = 0;
3070 SetLastError(0xdeadbeef);
3073 ok(!r, "unexpected success\n");
3074 ok(sz == 34, "got %lu\n", sz);
3075
3076 sz = sizeof(buffer);
3077 SetLastError(0xdeadbeef);
3079 ok(r, "unexpected failure %lu\n", GetLastError());
3080 ok(sz == 33, "got %lu\n", sz);
3081
3082 r = HttpSendRequestW(hr, NULL, 0, NULL, 0);
3083 ok(r || broken(!r), "HttpSendRequest failed %lu\n", GetLastError());
3084 if (!r)
3085 {
3086 win_skip("skipping proxy tests on broken wininet\n");
3087 goto done;
3088 }
3089
3090 test_status_code(hr, 407);
3091
3092 /* set the user + password then try again */
3094 ok(!r, "unexpected success\n");
3095
3097 ok(r, "failed to set user\n");
3098
3100 ok(r, "failed to set user\n");
3101
3102 buffer[0] = 0;
3103 sz = 3;
3104 SetLastError(0xdeadbeef);
3106 ok(!r, "unexpected failure %lu\n", GetLastError());
3107 ok(!buffer[0], "got %s\n", buffer);
3108 ok(sz == strlen(username) + 1, "got %lu\n", sz);
3109
3110 buffer[0] = 0;
3111 sz = 0;
3112 SetLastError(0xdeadbeef);
3115 ok(!r, "unexpected success\n");
3116 ok(sz == strlen(username) + 1, "got %lu\n", sz);
3117
3118 bufferW[0] = 0;
3119 sz = 0;
3120 SetLastError(0xdeadbeef);
3123 ok(!r, "unexpected success\n");
3124 ok(sz == (lstrlenW(usernameW) + 1) * sizeof(WCHAR), "got %lu\n", sz);
3125
3126 buffer[0] = 0;
3127 sz = sizeof(buffer);
3129 ok(r, "failed to get username\n");
3130 ok(!strcmp(buffer, username), "got %s\n", buffer);
3131 ok(sz == strlen(username), "got %lu\n", sz);
3132
3133 buffer[0] = 0;
3134 sz = sizeof(bufferW);
3136 ok(r, "failed to get username\n");
3137 ok(!lstrcmpW(bufferW, usernameW), "wrong username\n");
3138 ok(sz == lstrlenW(usernameW), "got %lu\n", sz);
3139
3141 ok(r, "failed to set user\n");
3142
3143 buffer[0] = 0;
3144 sz = sizeof(buffer);
3146 ok(r, "failed to get username\n");
3147 ok(!strcmp(buffer, username), "got %s\n", buffer);
3148 ok(sz == strlen(username), "got %lu\n", sz);
3149
3150 r = InternetSetOptionA(hi, INTERNET_OPTION_USER_AGENT, useragent, 1);
3151 ok(r, "failed to set useragent\n");
3152
3153 buffer[0] = 0;
3154 sz = 0;
3155 SetLastError(0xdeadbeef);
3158 ok(!r, "unexpected success\n");
3159 ok(sz == strlen(useragent) + 1, "got %lu\n", sz);
3160
3161 buffer[0] = 0;
3162 sz = sizeof(buffer);
3164 ok(r, "failed to get user agent\n");
3165 ok(!strcmp(buffer, useragent), "got %s\n", buffer);
3166 ok(sz == strlen(useragent), "got %lu\n", sz);
3167
3168 bufferW[0] = 0;
3169 sz = 0;
3170 SetLastError(0xdeadbeef);
3173 ok(!r, "unexpected success\n");
3174 ok(sz == (lstrlenW(useragentW) + 1) * sizeof(WCHAR), "got %lu\n", sz);
3175
3176 bufferW[0] = 0;
3177 sz = sizeof(bufferW);
3179 ok(r, "failed to get user agent\n");
3180 ok(!lstrcmpW(bufferW, useragentW), "wrong user agent\n");
3181 ok(sz == lstrlenW(useragentW), "got %lu\n", sz);
3182
3184 ok(r, "failed to set user\n");
3185
3186 buffer[0] = 0;
3187 sz = 0;
3188 SetLastError(0xdeadbeef);
3191 ok(!r, "unexpected success\n");
3192 ok(sz == strlen(username) + 1, "got %lu\n", sz);
3193
3194 buffer[0] = 0;
3195 sz = sizeof(buffer);
3197 ok(r, "failed to get user\n");
3198 ok(!strcmp(buffer, username), "got %s\n", buffer);
3199 ok(sz == strlen(username), "got %lu\n", sz);
3200
3201 bufferW[0] = 0;
3202 sz = 0;
3203 SetLastError(0xdeadbeef);
3206 ok(!r, "unexpected success\n");
3207 ok(sz == (lstrlenW(usernameW) + 1) * sizeof(WCHAR), "got %lu\n", sz);
3208
3209 bufferW[0] = 0;
3210 sz = sizeof(bufferW);
3212 ok(r, "failed to get user\n");
3213 ok(!lstrcmpW(bufferW, usernameW), "wrong user\n");
3214 ok(sz == lstrlenW(usernameW), "got %lu\n", sz);
3215
3217 ok(r, "failed to set password\n");
3218
3219 buffer[0] = 0;
3220 sz = 0;
3221 SetLastError(0xdeadbeef);
3224 ok(!r, "unexpected success\n");
3225 ok(sz == strlen(password) + 1, "got %lu\n", sz);
3226
3227 buffer[0] = 0;
3228 sz = sizeof(buffer);
3230 ok(r, "failed to get password\n");
3231 ok(!strcmp(buffer, password), "got %s\n", buffer);
3232 ok(sz == strlen(password), "got %lu\n", sz);
3233
3234 bufferW[0] = 0;
3235 sz = 0;
3236 SetLastError(0xdeadbeef);
3239 ok(!r, "unexpected success\n");
3240 ok(sz == (lstrlenW(passwordW) + 1) * sizeof(WCHAR), "got %lu\n", sz);
3241
3242 bufferW[0] = 0;
3243 sz = sizeof(bufferW);
3245 ok(r, "failed to get password\n");
3246 ok(!lstrcmpW(bufferW, passwordW), "wrong password\n");
3247 ok(sz == lstrlenW(passwordW), "got %lu\n", sz);
3248
3249 url = HeapAlloc(GetProcessHeap(), 0, strlen(url_fmt) + 11);
3250 sprintf(url, url_fmt, port);
3251 buffer[0] = 0;
3252 sz = 0;
3253 SetLastError(0xdeadbeef);
3256 ok(!r, "unexpected success\n");
3257 ok(sz == strlen(url) + 1, "got %lu\n", sz);
3258
3259 buffer[0] = 0;
3260 sz = sizeof(buffer);
3262 ok(r, "failed to get url\n");
3263 ok(!strcmp(buffer, url), "got %s\n", buffer);
3264 ok(sz == strlen(url), "got %lu\n", sz);
3265
3266 bufferW[0] = 0;
3267 sz = 0;
3268 SetLastError(0xdeadbeef);
3269 r = InternetQueryOptionW(hr, INTERNET_OPTION_URL, bufferW, &sz);
3271 ok(!r, "unexpected success\n");
3272 ok(sz == (strlen(url) + 1) * sizeof(WCHAR), "got %lu\n", sz);
3273
3274 bufferW[0] = 0;
3275 sz = sizeof(bufferW);
3276 r = InternetQueryOptionW(hr, INTERNET_OPTION_URL, bufferW, &sz);
3277 ok(r, "failed to get url\n");
3278 ok(!strcmp_wa(bufferW, url), "wrong url\n");
3279 ok(sz == strlen(url), "got %lu\n", sz);
3281
3283 ok(r, "failed to set password\n");
3284
3285 buffer[0] = 0;
3286 sz = 0;
3287 SetLastError(0xdeadbeef);
3290 ok(!r, "unexpected success\n");
3291 ok(sz == strlen(password) + 1, "got %lu\n", sz);
3292
3293 buffer[0] = 0;
3294 sz = sizeof(buffer);
3296 ok(r, "failed to get password\n");
3297 ok(!strcmp(buffer, password), "got %s\n", buffer);
3298 ok(sz == strlen(password), "got %lu\n", sz);
3299
3300 bufferW[0] = 0;
3301 sz = 0;
3302 SetLastError(0xdeadbeef);
3305 ok(!r, "unexpected success\n");
3306 ok(sz == (lstrlenW(passwordW) + 1) * sizeof(WCHAR), "got %lu\n", sz);
3307
3308 bufferW[0] = 0;
3309 sz = sizeof(bufferW);
3311 ok(r, "failed to get password\n");
3312 ok(!lstrcmpW(bufferW, passwordW), "wrong password\n");
3313 ok(sz == lstrlenW(passwordW), "got %lu\n", sz);
3314
3315 r = HttpSendRequestW(hr, NULL, 0, NULL, 0);
3316 if (!r)
3317 {
3318 win_skip("skipping proxy tests on broken wininet\n");
3319 goto done;
3320 }
3321 ok(r, "HttpSendRequest failed %lu\n", GetLastError());
3322 sz = sizeof buffer;
3324 ok(r, "HttpQueryInfo failed\n");
3325 ok(!strcmp(buffer, "200"), "proxy code wrong\n");
3326
3330
3331 sprintf(buffer, "localhost:%d\n", port);
3332 hi = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PROXY, buffer, NULL, 0);
3333 ok(hi != NULL, "InternetOpen failed\n");
3334
3335 hc = InternetConnectA(hi, "test.winehq.org", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3336 ok(hc != NULL, "InternetConnect failed\n");
3337
3338 hr = HttpOpenRequestA(hc, "POST", "/test2", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0);
3339 ok(hr != NULL, "HttpOpenRequest failed\n");
3340
3341 r = HttpSendRequestA(hr, NULL, 0, (char *)"data", sizeof("data"));
3342 ok(r, "HttpSendRequest failed %lu\n", GetLastError());
3343
3344 test_status_code(hr, 407);
3345
3346done:
3350}
3351
3353{
3354 static const char authorization[] = "Authorization: Basic dXNlcjpwd2Q=";
3355 static const char connection[] = "Connection: Close";
3356 static const char *types[2] = { "*", NULL };
3357 char data[32];
3359 DWORD size, status, data_len;
3360 BOOL ret;
3361
3363 ok(session != NULL, "InternetOpen failed\n");
3364
3366 ok(connect != NULL, "InternetConnect failed\n");
3367
3369 ok(request != NULL, "HttpOpenRequest failed\n");
3370
3372 ok(ret, "HttpAddRequestHeaders failed\n");
3373
3375 ok(ret, "HttpSendRequest failed\n");
3376
3379
3381
3383 ok(request != NULL, "HttpOpenRequest failed\n");
3384
3386 ok(ret, "HttpSendRequest failed\n");
3387
3388 status = 0;
3389 size = sizeof(status);
3391 ok(ret, "HttpQueryInfo failed\n");
3392 ok(status == 200 || status == 400 /* IE6 */, "got status %lu, expected 200 or 400\n", status);
3393
3396
3398 ok(connect != NULL, "InternetConnect failed\n");
3399
3401 ok(request != NULL, "HttpOpenRequest failed\n");
3402
3403 ret = HttpAddRequestHeadersA(request, "Content-Length: 100\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
3404 ok(ret, "HttpAddRequestHeaders failed\n");
3405
3407 ok(ret, "HttpSendRequest failed\n");
3408
3409 status = 0;
3410 size = sizeof(status);
3412 ok(ret, "HttpQueryInfo failed\n");
3413 ok(status == 200, "got status %lu, expected 200\n", status);
3414
3417
3419 ok(connect != NULL, "InternetConnect failed\n");
3420
3422 ok(request != NULL, "HttpOpenRequest failed\n");
3423
3424 ret = HttpAddRequestHeadersA(request, "Content-Length: 100\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
3425 ok(ret, "HttpAddRequestHeaders failed\n");
3426
3427 data_len = sizeof(data);
3428 memset(data, 'a', sizeof(data));
3429 ret = HttpSendRequestA(request, NULL, 0, data, data_len);
3430 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
3431
3432 status = 0;
3433 size = sizeof(status);
3435 ok(ret, "HttpQueryInfo failed\n");
3436 ok(status == 200, "got status %lu, expected 200\n", status);
3437
3441}
3442
3444{
3445 HINTERNET ses, con, req;
3446 BOOL ret;
3447
3448 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3449 ok(ses != NULL, "InternetOpen failed\n");
3450
3451 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3452 ok(con != NULL, "InternetConnect failed\n");
3453
3454 req = HttpOpenRequestA(con, NULL, "/test8", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3455 ok(req != NULL, "HttpOpenRequest failed\n");
3456
3457 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3458 ok(ret, "HttpSendRequest failed\n");
3459
3460 test_status_code(req, 200);
3461
3463
3464 req = HttpOpenRequestA(con, NULL, "/test9", NULL, NULL, NULL, 0, 0);
3465 ok(req != NULL, "HttpOpenRequest failed\n");
3466
3467 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3468 ok(ret, "HttpSendRequest failed\n");
3469
3470 test_status_code(req, 200);
3471
3473
3474 req = HttpOpenRequestA(con, NULL, "/test9", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
3475 ok(req != NULL, "HttpOpenRequest failed\n");
3476
3477 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3478 ok(ret, "HttpSendRequest failed\n");
3479
3480 test_status_code(req, 200);
3481
3483
3484 req = HttpOpenRequestA(con, "POST", "/testA", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
3485 ok(req != NULL, "HttpOpenRequest failed\n");
3486
3487 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3488 ok(ret, "HttpSendRequest failed\n");
3489
3490 test_status_code(req, 200);
3491
3495}
3496
3498{
3499 char buffer[128], host_header_override[30], full_url[128];
3500 HINTERNET ses, con, req;
3501 DWORD size, count, err;
3502 BOOL ret;
3503
3504 sprintf(host_header_override, "Host: test.local:%d\r\n", port);
3505 sprintf(full_url, "http://localhost:%d/test_host_override", port);
3506
3507 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3508 ok(ses != NULL, "InternetOpen failed\n");
3509
3510 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3511 ok(con != NULL, "InternetConnect failed\n");
3512
3513 req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3514 ok(req != NULL, "HttpOpenRequest failed\n");
3515
3516 size = sizeof(buffer) - 1;
3517 count = 0;
3518 memset(buffer, 0, sizeof(buffer));
3520 err = GetLastError();
3521 ok(!ret, "HttpQueryInfo succeeded\n");
3522 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "Expected error ERROR_HTTP_HEADER_NOT_FOUND, got %ld\n", err);
3523
3524 test_request_url(req, full_url);
3525
3526 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_COALESCE);
3527 ok(ret, "HttpAddRequestHeaders failed\n");
3528
3529 size = sizeof(buffer) - 1;
3530 count = 0;
3531 memset(buffer, 0, sizeof(buffer));
3533 ok(ret, "HttpQueryInfo failed\n");
3534
3535 test_request_url(req, full_url);
3536
3537 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3538 ok(ret, "HttpSendRequest failed\n");
3539
3540 test_status_code(req, 200);
3541
3543 req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3544 ok(req != NULL, "HttpOpenRequest failed\n");
3545
3546 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_COALESCE);
3547 ok(ret, "HttpAddRequestHeaders failed\n");
3548
3549 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_COALESCE);
3550 ok(ret, "HttpAddRequestHeaders failed\n");
3551
3552 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3553 ok(ret, "HttpSendRequest failed\n");
3554
3555 test_status_code(req, 400);
3556
3558 req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3559 ok(req != NULL, "HttpOpenRequest failed\n");
3560
3561 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
3562 ok(ret, "HttpAddRequestHeaders failed\n");
3563
3564 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3565 ok(ret, "HttpSendRequest failed\n");
3566
3567 test_status_code(req, 200);
3568
3570 req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3571 ok(req != NULL, "HttpOpenRequest failed\n");
3572
3573 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_REPLACE);
3574 if(ret) { /* win10 returns success */
3575 trace("replacing host header is supported.\n");
3576
3577 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3578 ok(ret, "HttpSendRequest failed\n");
3579
3580 test_status_code(req, 200);
3581 }else {
3582 trace("replacing host header is not supported.\n");
3583
3584 err = GetLastError();
3585 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "Expected error ERROR_HTTP_HEADER_NOT_FOUND, got %ld\n", err);
3586
3587 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3588 ok(ret, "HttpSendRequest failed\n");
3589
3590 test_status_code(req, 400);
3591 }
3592
3596}
3597
3599{
3601 DWORD res;
3602
3603 reset_events();
3604
3606 ok(session != NULL,"InternetOpen failed with error %lu\n", GetLastError());
3607
3608 pInternetSetStatusCallbackA(session, callback);
3609
3611 connection = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
3612 ok(connection != NULL,"InternetConnect failed with error %lu\n", GetLastError());
3614
3616 req = HttpOpenRequestA(connection, "GET", "/testJ", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0xdeadbeaf);
3617 ok(req != NULL, "HttpOpenRequest failed: %lu\n", GetLastError());
3619
3631
3632 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
3634 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3636 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
3637
3649
3650 test_status_code(req, 200);
3651
3661
3662 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
3664 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3666 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
3667
3677
3678 test_status_code(req, 210);
3679
3691
3692 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
3694 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3696 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
3697
3709
3710 test_status_code(req, 200);
3711
3714
3716}
3717
3719{
3721 DWORD res;
3722
3723 reset_events();
3724
3726 ok(session != NULL,"InternetOpen failed with error %lu\n", GetLastError());
3727
3728 pInternetSetStatusCallbackA(session, callback);
3729
3731 connection = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
3732 ok(connection != NULL,"InternetConnect failed with error %lu\n", GetLastError());
3734
3736 req = HttpOpenRequestA(connection, "GET", "/testH", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0xdeadbeaf);
3737 ok(req != NULL, "HttpOpenRequest failed: %lu\n", GetLastError());
3739
3749
3750 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
3752 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3754 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
3755
3765
3766 test_status_code(req, 210);
3767
3777
3778 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
3780 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3782 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
3783
3793
3794 test_status_code(req, 200);
3795
3798
3800}
3801
3802static void test_no_content(int port)
3803{
3805 DWORD res;
3806
3807 trace("Testing 204 no content response...\n");
3808
3809 reset_events();
3810
3812 ok(session != NULL,"InternetOpen failed with error %lu\n", GetLastError());
3813
3814 pInternetSetStatusCallbackA(session, callback);
3815
3817 connection = InternetConnectA(session, "localhost", port,
3818 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
3819 ok(connection != NULL,"InternetConnect failed with error %lu\n", GetLastError());
3821
3823 req = HttpOpenRequestA(connection, "GET", "/test_no_content", NULL, NULL, NULL,
3825 ok(req != NULL, "HttpOpenRequest failed: %lu\n", GetLastError());
3827
3838
3839 res = HttpSendRequestA(req, NULL, -1, NULL, 0);
3841 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3843 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
3844
3853
3855
3856 /*
3857 * The connection should be closed before closing handle. This is true for most
3858 * wininet versions (including Wine), but some old win2k versions fail to do that.
3859 */
3862}
3863
3864static void test_not_modified(int port)
3865{
3866 DWORD avail;
3867 HINTERNET ses, con, req;
3868 BOOL ret;
3869
3870 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3871 ok(ses != NULL, "InternetOpen failed\n");
3872
3873 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3874 ok(con != NULL, "InternetConnect failed\n");
3875
3876 req = HttpOpenRequestA(con, NULL, "/test_not_modified", NULL, NULL, NULL, 0, 0);
3877 ok(req != NULL, "HttpOpenRequest failed\n");
3878
3879 SetLastError(0xdeadbeef);
3880 ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
3881 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
3882 test_status_code(req, 304);
3883
3884 avail = 0xdeadbeef;
3885 ret = InternetQueryDataAvailable(req, &avail, 0, 0);
3886 ok(ret, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
3887 ok(!avail, "got %ld\n", avail);
3889
3890 req = HttpOpenRequestA(con, NULL, "/test_not_modified_content_length", NULL, NULL, NULL, 0, 0);
3891 ok(req != NULL, "HttpOpenRequest failed\n");
3892
3893 SetLastError(0xdeadbeef);
3894 ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
3895 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
3896 test_status_code(req, 304);
3897
3898 avail = 0xdeadbeef;
3899 ret = InternetQueryDataAvailable(req, &avail, 0, 0);
3900 ok(ret, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
3901 ok(avail == 10, "got %ld\n", avail);
3903
3904 req = HttpOpenRequestA(con, NULL, "/test_no_content", NULL, NULL, NULL, 0, 0);
3905 ok(req != NULL, "HttpOpenRequest failed\n");
3906
3907 SetLastError(0xdeadbeef);
3908 ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
3909 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
3910 test_status_code(req, 204);
3911
3912 avail = 0xdeadbeef;
3913 ret = InternetQueryDataAvailable(req, &avail, 0, 0);
3914 ok(ret, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
3915 ok(!avail, "got %ld\n", avail);
3917
3918 req = HttpOpenRequestA(con, NULL, "/test_no_content_content_length", NULL, NULL, NULL, 0, 0);
3919 ok(req != NULL, "HttpOpenRequest failed\n");
3920
3921 SetLastError(0xdeadbeef);
3922 ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
3923 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
3924 test_status_code(req, 204);
3925
3926 avail = 0xdeadbeef;
3927 ret = InternetQueryDataAvailable(req, &avail, 0, 0);
3928 ok(ret, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
3929 ok(avail == 10, "got %ld\n", avail);
3931
3932 req = HttpOpenRequestA(con, "HEAD", "/head", NULL, NULL, NULL, 0, 0);
3933 ok(req != NULL, "HttpOpenRequest failed\n");
3934
3935 SetLastError(0xdeadbeef);
3936 ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
3937 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
3938 test_status_code(req, 200);
3939
3940 avail = 0xdeadbeef;
3941 ret = InternetQueryDataAvailable(req, &avail, 0, 0);
3942 ok(ret, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
3943 ok(!avail, "got %ld\n", avail);
3945
3946 req = HttpOpenRequestA(con, "HEAD", "/head_content_length", NULL, NULL, NULL, 0, 0);
3947 ok(req != NULL, "HttpOpenRequest failed\n");
3948
3949 SetLastError(0xdeadbeef);
3950 ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
3951 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
3952 test_status_code(req, 200);
3953
3954 avail = 0xdeadbeef;
3955 ret = InternetQueryDataAvailable(req, &avail, 0, 0);
3956 ok(ret, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
3957 ok(!avail, "got %ld\n", avail);
3958
3962}
3963
3964static void test_large_header(int port)
3965{
3966 HINTERNET ses, con, req;
3967 BOOL ret;
3969 char buffer[13];
3970
3971 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3972 ok(ses != NULL, "InternetOpen failed\n");
3973
3974 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3975 ok(con != NULL, "InternetConnect failed\n");
3976
3977 req = HttpOpenRequestA(con, NULL, "/test_large_header", NULL, NULL, NULL, 0, 0);
3978 ok(req != NULL, "HttpOpenRequest failed\n");
3979
3980 SetLastError(0xdeadbeef);
3981 ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
3982 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
3983 test_status_code(req, 200);
3984
3985 index = 0;
3986 size = sizeof(buffer);
3987 strcpy(buffer, "wine-header");
3989 error = GetLastError();
3990 ok(!ret, "HttpQueryInfoA succeeded\n");
3991 ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", error);
3992 ok(size == 4001, "got %lu\n", size);
3993
3997}
3998
3999static void test_conn_close(int port)
4000{
4002 DWORD res, avail, size;
4003 BYTE buf[1024];
4004
4005 trace("Testing connection close connection...\n");
4006
4007 reset_events();
4008
4010 ok(session != NULL,"InternetOpen failed with error %lu\n", GetLastError());
4011
4012 pInternetSetStatusCallbackA(session, callback);
4013
4015 connection = InternetConnectA(session, "localhost", port,
4016 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
4017 ok(connection != NULL,"InternetConnect failed with error %lu\n", GetLastError());
4019
4021 req = HttpOpenRequestA(connection, "GET", "/test_conn_close", NULL, NULL, NULL,
4023 ok(req != NULL, "HttpOpenRequest failed: %lu\n", GetLastError());
4025
4034
4035 res = HttpSendRequestA(req, NULL, -1, NULL, 0);
4037 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
4039 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
4040
4049
4050 avail = 0;
4051 res = InternetQueryDataAvailable(req, &avail, 0, 0);
4052 ok(res, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
4053 ok(avail != 0, "avail = 0\n");
4054
4055 size = 0;
4056 res = InternetReadFile(req, buf, avail, &size);
4057 ok(res, "InternetReadFile failed: %lu\n", GetLastError());
4058
4059 /* IE11 calls those in InternetQueryDataAvailable call. */
4062
4063 res = InternetQueryDataAvailable(req, &avail, 0, 0);
4065 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
4066 ok(!avail, "avail = %lu, expected 0\n", avail);
4067
4069
4075 ok(req_error == ERROR_SUCCESS, "req_error = %lu\n", req_error);
4080
4082}
4083
4084static void test_no_cache(int port)
4085{
4086 static const char cache_control_no_cache[] = "/test_cache_control_no_cache";
4087 static const char cache_control_no_store[] = "/test_cache_control_no_store";
4088 static const char cache_url_fmt[] = "http://localhost:%d%s";
4089
4090 char cache_url[256], buf[256];
4091 HINTERNET ses, con, req;
4092 DWORD read, size;
4093 BOOL ret;
4094
4095 trace("Testing no-cache header\n");
4096
4097 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4098 ok(ses != NULL,"InternetOpen failed with error %lu\n", GetLastError());
4099
4100 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4101 ok(con != NULL, "InternetConnect failed with error %lu\n", GetLastError());
4102
4103 req = HttpOpenRequestA(con, NULL, cache_control_no_cache, NULL, NULL, NULL, 0, 0);
4104 ok(req != NULL, "HttpOpenRequest failed\n");
4105
4106 sprintf(cache_url, cache_url_fmt, port, cache_control_no_cache);
4107 DeleteUrlCacheEntryA(cache_url);
4108
4109 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4110 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
4111 size = 0;
4112 while(InternetReadFile(req, buf, sizeof(buf), &read) && read)
4113 size += read;
4114 ok(size == 12, "read %ld bytes of data\n", size);
4116
4117 req = HttpOpenRequestA(con, NULL, cache_control_no_cache, NULL, NULL, NULL, 0, 0);
4118 ok(req != NULL, "HttpOpenRequest failed\n");
4119
4120 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4121 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
4122 size = 0;
4123 while(InternetReadFile(req, buf, sizeof(buf), &read) && read)
4124 size += read;
4125 ok(size == 0, "read %ld bytes of data\n", size);
4127 DeleteUrlCacheEntryA(cache_url);
4128
4129 req = HttpOpenRequestA(con, NULL, cache_control_no_store, NULL, NULL, NULL, 0, 0);
4130 ok(req != NULL, "HttpOpenRequest failed\n");
4131
4132 sprintf(cache_url, cache_url_fmt, port, cache_control_no_store);
4133 DeleteUrlCacheEntryA(cache_url);
4134
4135 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4136 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
4137 size = 0;
4138 while(InternetReadFile(req, buf, sizeof(buf), &read) && read)
4139 size += read;
4140 ok(size == 12, "read %ld bytes of data\n", size);
4142
4143 ret = DeleteUrlCacheEntryA(cache_url);
4144 ok(!ret && GetLastError()==ERROR_FILE_NOT_FOUND, "cache entry should not exist\n");
4145
4148}
4149
4151{
4152 static const char cache_url_fmt[] = "http://localhost:%d%s";
4153 static const char get_gzip[] = "/test_cache_gzip";
4154 static const char content[] = "gzip test\n";
4155 static const char text_html[] = "text/html";
4156 static const char raw_header[] = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
4157
4158 HINTERNET ses, con, req;
4159 DWORD read, size;
4160 char cache_url[256], buf[256];
4161 BOOL ret;
4162
4163 trace("Testing reading compressed content from cache\n");
4164
4165 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4166 ok(ses != NULL,"InternetOpen failed with error %lu\n", GetLastError());
4167
4168 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4169 ok(con != NULL, "InternetConnect failed with error %lu\n", GetLastError());
4170
4171 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
4172 ok(req != NULL, "HttpOpenRequest failed\n");
4173
4174 ret = TRUE;
4177 win_skip("INTERNET_OPTION_HTTP_DECODING not supported\n");
4181 return;
4182 }
4183 ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %ld\n", GetLastError());
4184
4185 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
4186 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
4187 size = 0;
4188 while(InternetReadFile(req, buf+size, sizeof(buf)-size, &read) && read)
4189 size += read;
4190 ok(size == 10, "read %ld bytes of data\n", size);
4191 buf[size] = 0;
4192 ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf);
4193
4194 size = sizeof(buf)-1;
4196 ok(ret, "HttpQueryInfo(HTTP_QUERY_CONTENT_TYPE) failed: %ld\n", GetLastError());
4197 buf[size] = 0;
4198 ok(!strncmp(text_html, buf, size), "buf = %s\n", buf);
4199
4200 size = sizeof(buf)-1;
4202 ok(ret, "HttpQueryInfo(HTTP_QUERY_CONTENT_TYPE) failed: %ld\n", GetLastError());
4203 buf[size] = 0;
4204 ok(!strncmp(raw_header, buf, size), "buf = %s\n", buf);
4206
4207 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
4208 ok(req != NULL, "HttpOpenRequest failed\n");
4209
4210 ret = TRUE;
4212 ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %ld\n", GetLastError());
4213
4214 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
4215 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
4216 size = 0;
4217 while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
4218 size += read;
4219 todo_wine ok(size == 10, "read %ld bytes of data\n", size);
4220 buf[size] = 0;
4221 ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf);
4222
4223 size = sizeof(buf);
4226 "HttpQueryInfo(HTTP_QUERY_CONTENT_ENCODING) returned %d, %ld\n",
4227 ret, GetLastError());
4228
4229 size = sizeof(buf)-1;
4231 todo_wine ok(ret, "HttpQueryInfo(HTTP_QUERY_CONTENT_TYPE) failed: %ld\n", GetLastError());
4232 buf[size] = 0;
4233 todo_wine ok(!strncmp(text_html, buf, size), "buf = %s\n", buf);
4235
4236 /* Decompression doesn't work while reading from cache */
4237 test_cache_gzip = 0;
4238 sprintf(cache_url, cache_url_fmt, port, get_gzip);
4239 DeleteUrlCacheEntryA(cache_url);
4240
4241 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
4242 ok(req != NULL, "HttpOpenRequest failed\n");
4243
4244 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
4245 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
4246 size = 0;
4247 while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
4248 size += read;
4249 ok(size == 31, "read %ld bytes of data\n", size);
4251
4252 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
4253 ok(req != NULL, "HttpOpenRequest failed\n");
4254
4255 ret = TRUE;
4257 ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %ld\n", GetLastError());
4258
4259 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
4260 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
4261 size = 0;
4262 while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
4263 size += read;
4264 todo_wine ok(size == 31, "read %ld bytes of data\n", size);
4265
4266 size = sizeof(buf);
4268 todo_wine ok(ret, "HttpQueryInfo(HTTP_QUERY_CONTENT_ENCODING) failed: %ld\n", GetLastError());
4270
4273
4274 /* Decompression doesn't work while reading from cache */
4275 test_cache_gzip = 0;
4276 sprintf(cache_url, cache_url_fmt, port, get_gzip);
4277 DeleteUrlCacheEntryA(cache_url);
4278
4279 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4280 ok(ses != NULL,"InternetOpen failed with error %lu\n", GetLastError());
4281
4282 ret = TRUE;
4284 ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %ld\n", GetLastError());
4285
4286 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4287 ok(con != NULL, "InternetConnect failed with error %lu\n", GetLastError());
4288
4289 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
4290 ok(req != NULL, "HttpOpenRequest failed\n");
4291
4292 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
4293 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
4294 size = 0;
4295 while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
4296 size += read;
4297 ok(size == 10, "read %ld bytes of data\n", size);
4298 buf[size] = 0;
4299 ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf);
4301
4304
4305 /* Decompression doesn't work while reading from cache */
4306 test_cache_gzip = 0;
4307 sprintf(cache_url, cache_url_fmt, port, get_gzip);
4308 DeleteUrlCacheEntryA(cache_url);
4309
4310 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4311 ok(ses != NULL,"InternetOpen failed with error %lu\n", GetLastError());
4312
4313 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4314 ok(con != NULL, "InternetConnect failed with error %lu\n", GetLastError());
4315
4316 ret = TRUE;
4318 ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %ld\n", GetLastError());
4319
4320 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
4321 ok(req != NULL, "HttpOpenRequest failed\n");
4322
4323 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
4324 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
4325 size = 0;
4326 while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
4327 size += read;
4328 ok(size == 10, "read %ld bytes of data\n", size);
4329 buf[size] = 0;
4330 ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf);
4332
4335
4336 DeleteUrlCacheEntryA(cache_url);
4337}
4338
4340{
4341 static const WCHAR header[] = {'U','A','-','C','P','U',':',' ','x','8','6',0};
4342 HINTERNET ses, con, req;
4343 DWORD error;
4344 BOOL ret;
4345
4347 ok(ses != NULL, "InternetOpen failed\n");
4348
4349 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4350 ok(con != NULL, "InternetConnect failed\n");
4351
4352 req = HttpOpenRequestA(con, NULL, "/test1", NULL, NULL, NULL, 0, 0);
4353 ok(req != NULL, "HttpOpenRequest failed\n");
4354
4355 SetLastError(0xdeadbeef);
4356 ret = HttpSendRequestW(req, header, ~0u, NULL, 0);
4357 error = GetLastError();
4358 ok(!ret, "HttpSendRequestW succeeded\n");
4361 broken(error == ERROR_INVALID_PARAMETER), /* IE5 */
4362 "got %lu expected ERROR_IO_PENDING\n", error);
4363
4367}
4368
4369static void test_cookie_header(int port)
4370{
4371 HINTERNET ses, con, req;
4372 DWORD size, error;
4373 BOOL ret;
4374 char buffer[64];
4375
4376 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4377 ok(ses != NULL, "InternetOpen failed\n");
4378
4379 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4380 ok(con != NULL, "InternetConnect failed\n");
4381
4382 InternetSetCookieA("http://localhost", "cookie", "biscuit");
4383
4384 req = HttpOpenRequestA(con, NULL, "/testC", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
4385 ok(req != NULL, "HttpOpenRequest failed\n");
4386
4387 buffer[0] = 0;
4388 size = sizeof(buffer);
4389 SetLastError(0xdeadbeef);
4391 error = GetLastError();
4392 ok(!ret, "HttpQueryInfo succeeded\n");
4393 ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "got %lu expected ERROR_HTTP_HEADER_NOT_FOUND\n", error);
4394
4395 ret = HttpAddRequestHeadersA(req, "Cookie: cookie=not biscuit\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD);
4396 ok(ret, "HttpAddRequestHeaders failed: %lu\n", GetLastError());
4397
4398 buffer[0] = 0;
4399 size = sizeof(buffer);
4401 ok(ret, "HttpQueryInfo failed: %lu\n", GetLastError());
4402 ok(!strcmp(buffer, "cookie=not biscuit"), "got '%s' expected \'cookie=not biscuit\'\n", buffer);
4403
4404 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4405 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
4406
4407 test_status_code(req, 200);
4408
4409 buffer[0] = 0;
4410 size = sizeof(buffer);
4412 ok(ret, "HttpQueryInfo failed: %lu\n", GetLastError());
4413 ok(!strcmp(buffer, "cookie=biscuit"), "got '%s' expected \'cookie=biscuit\'\n", buffer);
4414
4418}
4419
4421{
4423 BOOL ret;
4424
4426 ok(session != NULL, "InternetOpen failed\n");
4427
4428 connect = InternetConnectA(session, "localhost", port, "user", "pwd", INTERNET_SERVICE_HTTP, 0, 0);
4429 ok(connect != NULL, "InternetConnect failed\n");
4430
4431 request = HttpOpenRequestA(connect, NULL, "/test3", NULL, NULL, NULL, 0, 0);
4432 ok(request != NULL, "HttpOpenRequest failed\n");
4433
4435 ok(ret, "HttpSendRequest failed %lu\n", GetLastError());
4436
4439
4443}
4444
4446{
4447 test_request_t req;
4448 DWORD err;
4449 BOOL ret;
4450
4451 open_simple_request(&req, "localhost", port, NULL, "/premature_disconnect");
4452
4453 SetLastError(0xdeadbeef);
4454 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4455 err = GetLastError();
4456 todo_wine ok(!ret, "HttpSendRequest succeeded\n");
4458
4459 close_request(&req);
4460}
4461
4463{
4464 test_request_t req;
4465 DWORD size;
4466 BOOL ret;
4467 char buffer[256];
4468
4469 open_simple_request(&req, "localhost", port, NULL, "/testE");
4470
4471 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4472 ok(ret, "HttpSendRequest failed %lu\n", GetLastError());
4473
4474 test_status_code(req.request, 401);
4476
4477 buffer[0] = 0;
4478 size = sizeof(buffer);
4480 ok(ret, "HttpQueryInfo failed\n");
4481 ok(!strcmp(buffer, "HTTP/1.0 401 Anonymous requests or requests on unsecure channel are not allowed"),
4482 "headers wrong \"%s\"\n", buffer);
4483
4484 buffer[0] = 0;
4485 size = sizeof(buffer);
4487 ok(ret, "HttpQueryInfo failed\n");
4488 ok(!strcmp(buffer, "winetest"), "server wrong \"%s\"\n", buffer);
4489
4490 close_request(&req);
4491}
4492
4494{
4495 test_request_t req;
4496 DWORD r, count, size;
4497 char buffer[1024];
4498
4499 open_simple_request(&req, "localhost", port, NULL, "/testG");
4500
4502
4503 r = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4504 ok(r, "HttpSendRequest failed %lu\n", GetLastError());
4505
4507
4508 count = 0;
4509 memset(buffer, 0, sizeof buffer);
4510 r = InternetReadFile(req.request, buffer, sizeof buffer, &count);
4511 ok(r, "InternetReadFile failed %lu\n", GetLastError());
4512 todo_wine ok(count == sizeof page1 - 1, "count was wrong\n");
4513 todo_wine ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
4514
4515 test_status_code(req.request, 200);
4517
4518 buffer[0] = 0;
4519 size = sizeof(buffer);
4521 ok(r, "HttpQueryInfo failed %lu\n", GetLastError());
4522 ok(!strcmp(buffer, "OK"), "expected OK got: \"%s\"\n", buffer);
4523
4524 buffer[0] = 0;
4525 size = sizeof(buffer);
4527 ok(r, "HttpQueryInfo failed %lu\n", GetLastError());
4528 ok(!strcmp(buffer, "HTTP/1.0"), "expected HTTP/1.0 got: \"%s\"\n", buffer);
4529
4530 buffer[0] = 0;
4531 size = sizeof(buffer);
4533 ok(r, "HttpQueryInfo failed %lu\n", GetLastError());
4534 ok(!strcmp(buffer, "HTTP/1.0 200 OK"), "raw headers wrong: \"%s\"\n", buffer);
4535
4536 close_request(&req);
4537}
4538
4539static void test_head_request(int port)
4540{
4542 test_request_t req;
4543 BYTE buf[100];
4544 BOOL ret;
4545
4546 open_simple_request(&req, "localhost", port, "HEAD", "/test_head");
4547
4548 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4549 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
4550
4551 len = sizeof(content_length);
4552 content_length = -1;
4554 ok(ret, "HttpQueryInfo failed: %lu\n", GetLastError());
4555 ok(len == sizeof(DWORD), "len = %lu\n", len);
4556 ok(content_length == 100, "content_length = %lu\n", content_length);
4557
4558 len = -1;
4559 ret = InternetReadFile(req.request, buf, sizeof(buf), &len);
4560 ok(ret, "InternetReadFile failed: %lu\n", GetLastError());
4561
4562 len = -1;
4563 ret = InternetReadFile(req.request, buf, sizeof(buf), &len);
4564 ok(ret, "InternetReadFile failed: %lu\n", GetLastError());
4565
4566 close_request(&req);
4567}
4568
4569static void test_HttpQueryInfo(int port)
4570{
4571 static const SYSTEMTIME expect = {2008, 12, 1, 1, 13, 44, 34};
4572 test_request_t req;
4574 char buffer[1024];
4575 SYSTEMTIME st;
4576 BOOL ret;
4577
4578 open_simple_request(&req, "localhost", port, NULL, "/testD");
4579
4580 size = sizeof(buffer);
4582 error = GetLastError();
4583 ok(!ret || broken(ret), "HttpQueryInfo succeeded\n");
4584 if (!ret) ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "got %lu expected ERROR_HTTP_HEADER_NOT_FOUND\n", error);
4585
4586 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4587 ok(ret, "HttpSendRequest failed\n");
4588
4589 index = 0;
4590 size = sizeof(buffer);
4592 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4593 ok(index == 1, "expected 1 got %lu\n", index);
4594
4595 index = 0;
4596 size = 0;
4598 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", GetLastError());
4599 ok(size == sizeof(st), "got %lu\n", size);
4600
4601 index = 0;
4602 size = sizeof(st) + 1;
4603 memset(&st, 0, sizeof(st));
4605 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4606 ok(!memcmp(&st, &expect, sizeof(st)), "wrong time\n");
4607 ok(size == sizeof(st), "got %lu\n", size);
4608 ok(index == 1, "expected 1 got %lu\n", index);
4609
4610 index = 0;
4611 size = sizeof(st);
4612 memset(&st, 0, sizeof(st));
4614 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4615 ok(!memcmp(&st, &expect, sizeof(st)), "wrong time\n");
4616 ok(size == sizeof(st), "got %lu\n", size);
4617 ok(index == 1, "expected 1 got %lu\n", index);
4618
4619 index = 0;
4620 size = sizeof(buffer);
4622 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4623 ok(index == 0, "expected 0 got %lu\n", index);
4624
4625 size = sizeof(buffer);
4627 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4628 ok(index == 0, "expected 0 got %lu\n", index);
4629
4630 index = 0xdeadbeef; /* invalid start index */
4631 size = sizeof(buffer);
4633 todo_wine ok(!ret, "HttpQueryInfo should have failed\n");
4635 "Expected ERROR_HTTP_HEADER_NOT_FOUND, got %lu\n", GetLastError());
4636
4637 index = 0;
4638 size = sizeof(buffer);
4640 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4641 ok(index == 0, "expected 0 got %lu\n", index);
4642
4643 size = sizeof(buffer);
4645 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4646 ok(index == 0, "expected 0 got %lu\n", index);
4647
4648 size = sizeof(buffer);
4650 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4651 ok(index == 0, "expected 0 got %lu\n", index);
4652
4653 test_status_code(req.request, 200);
4654
4655 index = 0xdeadbeef;
4656 size = sizeof(buffer);
4658 ok(!ret, "HttpQueryInfo succeeded\n");
4659 ok(index == 0xdeadbeef, "expected 0xdeadbeef got %lu\n", index);
4660
4661 index = 0;
4662 size = sizeof(buffer);
4664 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4665 ok(index == 1, "expected 1 got %lu\n", index);
4666
4667 index = 0;
4668 size = sizeof(buffer);
4669 strcpy(buffer, "Server");
4671 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4672 ok(index == 1, "expected 1 got %lu\n", index);
4673
4674 index = 0;
4675 size = sizeof(buffer);
4677 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4678 ok(index == 1, "expected 1 got %lu\n", index);
4679
4680 size = sizeof(buffer);
4682 ok(ret, "HttpQueryInfo failed %lu\n", GetLastError());
4683 ok(index == 2, "expected 2 got %lu\n", index);
4684
4685 close_request(&req);
4686}
4687
4688static void test_options(int port)
4689{
4691 HINTERNET ses, con, req;
4692 DWORD size, error;
4693 DWORD_PTR ctx;
4694 BOOL ret;
4695
4696 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4697 ok(ses != NULL, "InternetOpen failed\n");
4698
4699 SetLastError(0xdeadbeef);
4701 error = GetLastError();
4702 ok(!ret, "InternetSetOption succeeded\n");
4703 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
4704
4705 SetLastError(0xdeadbeef);
4707 ok(!ret, "InternetSetOption succeeded\n");
4708 error = GetLastError();
4709 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
4710
4711 SetLastError(0xdeadbeef);
4713 ok(!ret, "InternetSetOption succeeded\n");
4714 error = GetLastError();
4715 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
4716
4717 ctx = 1;
4719 ok(ret, "InternetSetOption failed %lu\n", GetLastError());
4720
4721 SetLastError(0xdeadbeef);
4723 error = GetLastError();
4724 ok(!ret, "InternetQueryOption succeeded\n");
4725 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
4726
4727 SetLastError(0xdeadbeef);
4729 error = GetLastError();
4730 ok(!ret, "InternetQueryOption succeeded\n");
4731 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
4732
4733 size = 0;
4734 SetLastError(0xdeadbeef);
4736 error = GetLastError();
4737 ok(!ret, "InternetQueryOption succeeded\n");
4738 ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", error);
4739
4740 size = sizeof(ctx);
4741 SetLastError(0xdeadbeef);
4743 error = GetLastError();
4744 ok(!ret, "InternetQueryOption succeeded\n");
4745 ok(error == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %lu\n", error);
4746
4747 ctx = 0xdeadbeef;
4748 size = sizeof(ctx);
4750 ok(ret, "InternetQueryOption failed %lu\n", GetLastError());
4751 ok(ctx == 1, "expected 1 got %Iu\n", ctx);
4752
4753 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4754 ok(con != NULL, "InternetConnect failed\n");
4755
4756 ctx = 0xdeadbeef;
4757 size = sizeof(ctx);
4759 ok(ret, "InternetQueryOption failed %lu\n", GetLastError());
4760 ok(ctx == 0, "expected 0 got %Iu\n", ctx);
4761
4762 ctx = 2;
4764 ok(ret, "InternetSetOption failed %lu\n", GetLastError());
4765
4766 ctx = 0xdeadbeef;
4767 size = sizeof(ctx);
4769 ok(ret, "InternetQueryOption failed %lu\n", GetLastError());
4770 ok(ctx == 2, "expected 2 got %Iu\n", ctx);
4771
4772 req = HttpOpenRequestA(con, NULL, "/test1", NULL, NULL, NULL, 0, 0);
4773 ok(req != NULL, "HttpOpenRequest failed\n");
4774
4775 ctx = 0xdeadbeef;
4776 size = sizeof(ctx);
4778 ok(ret, "InternetQueryOption failed %lu\n", GetLastError());
4779 ok(ctx == 0, "expected 0 got %Iu\n", ctx);
4780
4781 ctx = 3;
4783 ok(ret, "InternetSetOption failed %lu\n", GetLastError());
4784
4785 ctx = 0xdeadbeef;
4786 size = sizeof(ctx);
4788 ok(ret, "InternetQueryOption failed %lu\n", GetLastError());
4789 ok(ctx == 3, "expected 3 got %Iu\n", ctx);
4790
4791 size = sizeof(idsi);
4793 ok(ret, "InternetQueryOption failed %lu\n", GetLastError());
4794
4795 size = 0;
4796 SetLastError(0xdeadbeef);
4798 error = GetLastError();
4799 ok(!ret, "InternetQueryOption succeeded\n");
4800 ok(error == ERROR_INTERNET_INVALID_OPERATION, "expected ERROR_INTERNET_INVALID_OPERATION, got %lu\n", error);
4801
4802 /* INTERNET_OPTION_PROXY */
4803 SetLastError(0xdeadbeef);
4805 error = GetLastError();
4806 ok(!ret, "InternetQueryOption succeeded\n");
4807 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
4808
4809 SetLastError(0xdeadbeef);
4811 error = GetLastError();
4812 ok(!ret, "InternetQueryOption succeeded\n");
4813 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
4814
4815 size = 0;
4816 SetLastError(0xdeadbeef);
4818 error = GetLastError();
4819 ok(!ret, "InternetQueryOption succeeded\n");
4820 ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %lu\n", error);
4821 ok(size >= sizeof(INTERNET_PROXY_INFOA), "expected size to be greater or equal to the struct size\n");
4822
4826}
4827
4828typedef struct {
4829 const char *response_text;
4831 const char *status_text;
4832 const char *raw_headers;
4834
4836 {
4837 "HTTP/1.1 200 OK\r\n"
4838 "Content-Length: 1\r\n"
4839 "\r\nx",
4840 200,
4841 "OK"
4842 },
4843 {
4844 "HTTP/1.1 404 Fail\r\n"
4845 "Content-Length: 1\r\n"
4846 "\r\nx",
4847 404,
4848 "Fail"
4849 },
4850 {
4851 "HTTP/1.1 200\r\n"
4852 "Content-Length: 1\r\n"
4853 "\r\nx",
4854 200,
4855 ""
4856 },
4857 {
4858 "HTTP/1.1 200 \r\n"
4859 "Content-Length: 1\r\n"
4860 "\r\nx",
4861 200,
4862 ""
4863 },
4864 {
4865 "HTTP/1.1 410 \r\n"
4866 "Content-Length: 1\r\n"
4867 "\r\nx",
4868 410,
4869 ""
4870 }
4871};
4872
4873static void test_http_status(int port)
4874{
4875 test_request_t req;
4876 char buf[1000];
4877 DWORD i, size;
4878 BOOL res;
4879
4880 for(i = 0; i < ARRAY_SIZE(http_status_tests); i++) {
4882
4883 open_simple_request(&req, "localhost", port, NULL, "/send_from_buffer");
4884
4885 res = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4886 ok(res, "HttpSendRequest failed\n");
4887
4889
4890 size = sizeof(buf);
4892 ok(res, "HttpQueryInfo failed: %lu\n", GetLastError());
4893 ok(!strcmp(buf, http_status_tests[i].status_text), "[%lu] Unexpected status text \"%s\", expected \"%s\"\n",
4894 i, buf, http_status_tests[i].status_text);
4895
4896 close_request(&req);
4897 }
4898}
4899
4901{
4903 BOOL ret;
4904
4906 ok(session != NULL, "InternetOpen failed\n");
4907
4909 ok(connect != NULL, "InternetConnect failed\n");
4910
4911 request = HttpOpenRequestA(connect, "RPC_OUT_DATA", "/test_cache_control_verb", NULL, NULL, NULL,
4913 ok(request != NULL, "HttpOpenRequest failed\n");
4915 ok(ret, "HttpSendRequest failed %lu\n", GetLastError());
4918
4919 request = HttpOpenRequestA(connect, "POST", "/test_cache_control_verb", NULL, NULL, NULL,
4921 ok(request != NULL, "HttpOpenRequest failed\n");
4923 ok(ret, "HttpSendRequest failed %lu\n", GetLastError());
4926
4927 request = HttpOpenRequestA(connect, "HEAD", "/test_cache_control_verb", NULL, NULL, NULL,
4929 ok(request != NULL, "HttpOpenRequest failed\n");
4931 ok(ret, "HttpSendRequest failed %lu\n", GetLastError());
4934
4935 request = HttpOpenRequestA(connect, "GET", "/test_cache_control_verb", NULL, NULL, NULL,
4937 ok(request != NULL, "HttpOpenRequest failed\n");
4939 ok(ret, "HttpSendRequest failed %lu\n", GetLastError());
4942
4945}
4946
4948{
4949 char data[] = {'t','e','s','t'};
4950 test_request_t req;
4951 BOOL ret;
4952
4953 reset_events();
4954 open_simple_request(&req, "localhost", port, "POST", "/test_request_content_length");
4955
4956 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4957 ok(ret, "HttpSendRequest failed %lu\n", GetLastError());
4958 test_status_code(req.request, 200);
4959
4961
4962 ret = HttpSendRequestA(req.request, NULL, 0, data, sizeof(data));
4963 ok(ret, "HttpSendRequest failed %lu\n", GetLastError());
4964 test_status_code(req.request, 200);
4965
4967 close_request(&req);
4968}
4969
4971{
4972 HINTERNET ses, con, req;
4973 char buf[1000];
4974 BOOL ret;
4975
4976 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4977 ok(ses != NULL, "InternetOpen failed\n");
4978
4979 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4980 ok(con != NULL, "InternetConnect failed\n");
4981
4982 req = HttpOpenRequestA(con, "GET", "/echo_request", "HTTP/1.0", NULL, NULL, 0, 0);
4983 ok(req != NULL, "HttpOpenRequest failed\n");
4984
4985 ret = HttpAddRequestHeadersA(req, "Accept-Encoding: gzip\r\n", ~0u, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD);
4986 ok(ret, "HttpAddRequestHeaders failed\n");
4987
4988 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4989 ok(ret, "HttpSendRequestA failed\n");
4990
4991 test_status_code(req, 200);
4992 receive_simple_request(req, buf, sizeof(buf));
4993 ok(strstr(buf, "Accept-Encoding: gzip") != NULL, "Accept-Encoding header not found in %s\n", buf);
4994
4996
4997 req = HttpOpenRequestA(con, "GET", "/echo_request", "HTTP/1.0", NULL, NULL, 0, 0);
4998 ok(req != NULL, "HttpOpenRequest failed\n");
4999
5000 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", ~0u, NULL, 0);
5001 ok(ret, "HttpSendRequestA failed\n");
5002
5003 test_status_code(req, 200);
5004 receive_simple_request(req, buf, sizeof(buf));
5005 ok(strstr(buf, "Accept-Encoding: gzip") != NULL, "Accept-Encoding header not found in %s\n", buf);
5006
5010}
5011
5013{
5014 HINTERNET ses, con, req;
5015 DWORD status, size;
5016 BOOL ret;
5017 char buffer[0x40];
5018
5019 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5020 ok( ses != NULL, "InternetOpenA failed\n" );
5021
5022 con = InternetConnectA( ses, "localhost", port, "user", "pwd",
5023 INTERNET_SERVICE_HTTP, 0, 0 );
5024 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5025
5026 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
5027 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5028
5029 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5030 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5031
5032 size = sizeof(buffer);
5033 SetLastError(0xdeadbeef);
5035 ok(ret, "unexpected failure %lu\n", GetLastError());
5036 ok(!strcmp(buffer, "user"), "got %s\n", buffer);
5037 ok(size == 4, "got %lu\n", size);
5038
5039 size = sizeof(buffer);
5040 SetLastError(0xdeadbeef);
5042 ok(ret, "unexpected failure %lu\n", GetLastError());
5043 ok(!strcmp(buffer, "pwd"), "got %s\n", buffer);
5044 ok(size == 3, "got %lu\n", size);
5045
5046 status = 0xdeadbeef;
5047 size = sizeof(status);
5049 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5050 ok( status == 200, "got %lu\n", status );
5051
5052 InternetCloseHandle( req );
5053 InternetCloseHandle( con );
5054 InternetCloseHandle( ses );
5055
5056 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5057 ok( ses != NULL, "InternetOpenA failed\n" );
5058
5059 con = InternetConnectA( ses, "localhost", port, NULL, NULL,
5060 INTERNET_SERVICE_HTTP, 0, 0 );
5061 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5062
5063 req = HttpOpenRequestA( con, "PUT", "/upload2.txt", NULL, NULL, NULL, 0, 0 );
5064 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5065
5066 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5067 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5068
5069 size = sizeof(buffer);
5070 SetLastError(0xdeadbeef);
5072 ok(ret, "unexpected failure %lu\n", GetLastError());
5073 ok(!strcmp(buffer, "user"), "got %s\n", buffer);
5074 ok(size == 4, "got %lu\n", size);
5075
5076 size = sizeof(buffer);
5077 SetLastError(0xdeadbeef);
5079 ok(ret, "unexpected failure %lu\n", GetLastError());
5080 ok(!strcmp(buffer, "pwd"), "got %s\n", buffer);
5081 ok(size == 3, "got %lu\n", size);
5082
5083 status = 0xdeadbeef;
5084 size = sizeof(status);
5086 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5087 ok( status == 200, "got %lu\n", status );
5088
5089 InternetCloseHandle( req );
5090 InternetCloseHandle( con );
5091 InternetCloseHandle( ses );
5092}
5093
5095{
5096 HINTERNET ses, con, req;
5097 DWORD status, size;
5098 BOOL ret;
5099 char buffer[0x40];
5100
5101 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5102 ok( ses != NULL, "InternetOpenA failed\n" );
5103
5104 con = InternetConnectA( ses, "localhost", port, "user", "pwd",
5105 INTERNET_SERVICE_HTTP, 0, 0 );
5106 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5107
5108 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
5109 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5110
5111 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5112 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5113
5114 size = sizeof(buffer);
5115 SetLastError(0xdeadbeef);
5117 ok(ret, "unexpected failure %lu\n", GetLastError());
5118 ok(!strcmp(buffer, "user"), "got %s\n", buffer);
5119 ok(size == 4, "got %lu\n", size);
5120
5121 size = sizeof(buffer);
5122 SetLastError(0xdeadbeef);
5124 ok(ret, "unexpected failure %lu\n", GetLastError());
5125 ok(!strcmp(buffer, "pwd"), "got %s\n", buffer);
5126 ok(size == 3, "got %lu\n", size);
5127
5128 status = 0xdeadbeef;
5129 size = sizeof(status);
5131 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5132 ok( status == HTTP_STATUS_OK, "got %lu\n", status );
5133
5134 InternetCloseHandle( req );
5135 InternetCloseHandle( con );
5136 InternetCloseHandle( ses );
5137
5138 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5139 ok( ses != NULL, "InternetOpenA failed\n" );
5140
5141 /* Clear the cached credentials */
5143 ok(ret, "unexpected failure %lu\n", GetLastError());
5144
5145 con = InternetConnectA( ses, "localhost", port, NULL, NULL,
5146 INTERNET_SERVICE_HTTP, 0, 0 );
5147 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5148
5149 req = HttpOpenRequestA( con, "PUT", "/upload2.txt", NULL, NULL, NULL, 0, 0 );
5150 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5151
5152 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5153 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5154
5155 size = sizeof(buffer);
5156 SetLastError(0xdeadbeef);
5158 ok(ret, "unexpected failure %lu\n", GetLastError());
5159 ok(!strcmp(buffer, ""), "got %s\n", buffer);
5160 ok(size == 0, "got %lu\n", size);
5161
5162 size = sizeof(buffer);
5163 SetLastError(0xdeadbeef);
5165 ok(ret, "unexpected failure %lu\n", GetLastError());
5166 ok(!strcmp(buffer, ""), "got %s\n", buffer);
5167 ok(size == 0, "got %lu\n", size);
5168
5169 status = 0xdeadbeef;
5170 size = sizeof(status);
5172 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5173 ok( status == HTTP_STATUS_BAD_REQUEST, "got %lu\n", status );
5174
5175 InternetCloseHandle( req );
5176 InternetCloseHandle( con );
5177 InternetCloseHandle( ses );
5178}
5179
5181{
5182 HINTERNET ses, con, req;
5183 DWORD status, size;
5184 BOOL ret;
5185 char buffer[0x40];
5186
5187 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5188 ok( ses != NULL, "InternetOpenA failed\n" );
5189
5190 con = InternetConnectA( ses, "localhost", port, "user", "pwd",
5191 INTERNET_SERVICE_HTTP, 0, 0 );
5192 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5193
5194 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
5195 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5196
5197 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5198 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5199
5200 size = sizeof(buffer);
5201 SetLastError(0xdeadbeef);
5203 ok(ret, "unexpected failure %lu\n", GetLastError());
5204 ok(!strcmp(buffer, "user"), "got %s\n", buffer);
5205 ok(size == 4, "got %lu\n", size);
5206
5207 size = sizeof(buffer);
5208 SetLastError(0xdeadbeef);
5210 ok(ret, "unexpected failure %lu\n", GetLastError());
5211 ok(!strcmp(buffer, "pwd"), "got %s\n", buffer);
5212 ok(size == 3, "got %lu\n", size);
5213
5214 status = 0xdeadbeef;
5215 size = sizeof(status);
5217 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5218 ok( status == 200, "got %lu\n", status );
5219
5220 InternetCloseHandle( req );
5221 InternetCloseHandle( con );
5222 InternetCloseHandle( ses );
5223
5224 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5225 ok( ses != NULL, "InternetOpenA failed\n" );
5226
5227 con = InternetConnectA( ses, "localhost", port, "user1", "pwd1",
5228 INTERNET_SERVICE_HTTP, 0, 0 );
5229 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5230
5231 req = HttpOpenRequestA( con, "HEAD", "/upload3.txt", NULL, NULL, NULL, 0, 0 );
5232 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5233
5234 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5235 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5236
5237 size = sizeof(buffer);
5238 SetLastError(0xdeadbeef);
5240 ok(ret, "unexpected failure %lu\n", GetLastError());
5241 ok(!strcmp(buffer, "user1"), "got %s\n", buffer);
5242 ok(size == 5, "got %lu\n", size);
5243
5244 size = sizeof(buffer);
5245 SetLastError(0xdeadbeef);
5247 ok(ret, "unexpected failure %lu\n", GetLastError());
5248 ok(!strcmp(buffer, "pwd1"), "got %s\n", buffer);
5249 ok(size == 4, "got %lu\n", size);
5250
5251 status = 0xdeadbeef;
5252 size = sizeof(status);
5254 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5255 ok( status == 200, "got %lu\n", status );
5256
5257 InternetCloseHandle( req );
5258 InternetCloseHandle( con );
5259 InternetCloseHandle( ses );
5260}
5261
5262/*
5263 * Manually set the Authorization for both calls.
5264 */
5266{
5267 HINTERNET ses, con, req;
5268 DWORD status, size;
5269 BOOL ret;
5270
5271 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5272 ok( ses != NULL, "InternetOpenA failed\n" );
5273
5274 /* Clear the cached credentials */
5276 ok(ret, "unexpected failure %lu\n", GetLastError());
5277
5278 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 );
5279 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5280
5281 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
5282 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5283
5284 /* Set Authorization Header */
5285 ret = HttpAddRequestHeadersA(req, "Authorization: Basic dXNlcjpwd2Q=\r\n", ~0u,
5287 ok(ret, "HttpAddRequestHeaders Failed\n");
5288
5289 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5290 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5291
5292 status = 0xdeadbeef;
5293 size = sizeof(status);
5295 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5296 ok( status == 200, "got %lu\n", status );
5297
5298 InternetCloseHandle( req );
5299 InternetCloseHandle( con );
5300 InternetCloseHandle( ses );
5301
5302 /* Show manual headers are cached. */
5303 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5304 ok( ses != NULL, "InternetOpenA failed\n" );
5305
5306 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 );
5307 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5308
5309 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
5310 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5311
5312 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5313 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5314
5315 status = 0xdeadbeef;
5316 size = sizeof(status);
5318 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5319 ok( status == 401, "got %lu\n", status );
5320
5321 InternetCloseHandle( req );
5322 InternetCloseHandle( con );
5323 InternetCloseHandle( ses );
5324
5325 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5326 ok( ses != NULL, "InternetOpenA failed\n" );
5327
5328 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 );
5329 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5330
5331 req = HttpOpenRequestA( con, "HEAD", "/upload4.txt", NULL, NULL, NULL, 0, 0 );
5332 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5333
5334 /* Set Authorization Header */
5335 ret = HttpAddRequestHeadersA(req, "Authorization: Bearer dXNlcjE6cHdkMQ==\r\n", ~0u,
5337 ok(ret, "HttpAddRequestHeaders Failed\n");
5338
5339 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5340 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5341
5342 status = 0xdeadbeef;
5343 size = sizeof(status);
5345 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5346 ok( status == 200, "got %lu\n", status );
5347
5348 InternetCloseHandle( req );
5349 InternetCloseHandle( con );
5350 InternetCloseHandle( ses );
5351}
5352
5353/*
5354 * Manually set the Authorization for the bearer call, which shows the cached is used.
5355 */
5357{
5358 HINTERNET ses, con, req;
5359 DWORD status, size;
5360 BOOL ret;
5361
5362 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5363 ok( ses != NULL, "InternetOpenA failed\n" );
5364
5365 /* Clear the cached credentials */
5367 ok(ret, "unexpected failure %lu\n", GetLastError());
5368
5369 con = InternetConnectA( ses, "localhost", port, "user", "pwd",
5370 INTERNET_SERVICE_HTTP, 0, 0 );
5371 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5372
5373 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
5374 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5375
5376 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5377 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5378
5379 status = 0xdeadbeef;
5380 size = sizeof(status);
5382 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5383 ok( status == 200, "got %lu\n", status );
5384
5385 InternetCloseHandle( req );
5386 InternetCloseHandle( con );
5387 InternetCloseHandle( ses );
5388
5389 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5390 ok( ses != NULL, "InternetOpenA failed\n" );
5391
5392 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 );
5393 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5394
5395 req = HttpOpenRequestA( con, "HEAD", "/upload4.txt", NULL, NULL, NULL, 0, 0 );
5396 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5397
5398 /* Setting an Authorization Header doesn't override the cached one. */
5399 ret = HttpAddRequestHeadersA(req, "Authorization: Bearer dXNlcjE6cHdkMQ==\r\n", ~0u,
5401 ok(ret, "HttpAddRequestHeaders Failed\n");
5402
5403 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5404 ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
5405
5406 status = 0xdeadbeef;
5407 size = sizeof(status);
5409 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
5410 ok( status == 201, "got %lu\n", status );
5411
5412 InternetCloseHandle( req );
5413 InternetCloseHandle( con );
5414 InternetCloseHandle( ses );
5415}
5416
5417static void test_async_read(int port)
5418{
5419 HINTERNET ses, con, req;
5421 char buffer[0x100];
5422 DWORD pending_reads;
5423 DWORD res, count, bytes;
5424 BOOL ret;
5425
5426 reset_events();
5427
5428 /* test asynchronous InternetReadFileEx */
5430 ok( ses != NULL, "InternetOpenA failed\n" );
5431 pInternetSetStatusCallbackA( ses, &callback );
5432
5434 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0xdeadbeef );
5435 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5437
5439 req = HttpOpenRequestA( con, "GET", "/async_read", NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef );
5440 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5442
5454
5455 SetLastError( 0xdeadbeef );
5456 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5457 ok( !ret, "HttpSendRequestA unexpectedly succeeded\n" );
5458 ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %lu\n", GetLastError() );
5460 ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error );
5461
5473
5474 pending_reads = 0;
5475 memset( &ib, 0, sizeof(ib) );
5476 memset( buffer, 0, sizeof(buffer) );
5477 ib.dwStructSize = sizeof(ib);
5478 for (count = 0; count < sizeof(buffer); count += ib.dwBufferLength)
5479 {
5480 ib.lpvBuffer = buffer + count;
5481 ib.dwBufferLength = min(16, sizeof(buffer) - count);
5482
5485
5486 ret = InternetReadFileExA( req, &ib, 0, 0xdeadbeef );
5487 if (!count) /* the first part should arrive immediately */
5489 ok( ret, "InternetReadFileExA failed %lu\n", GetLastError() );
5490 if (!ret)
5491 {
5492 ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %lu\n", GetLastError() );
5496 if (!pending_reads++)
5497 {
5499 ok( res == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %lu\n", res );
5501 }
5503 ok( res == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", res );
5504 ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error );
5505 todo_wine_if( pending_reads > 1 )
5506 ok( ib.dwBufferLength != 0, "expected ib.dwBufferLength != 0\n" );
5509 }
5510
5513 if (!ib.dwBufferLength) break;
5514 }
5515
5516 ok( pending_reads == 1, "expected 1 pending read, got %lu\n", pending_reads );
5517 ok( !strcmp(buffer, page1), "unexpected buffer content\n" );
5518 close_async_handle( ses, 2 );
5520
5521 /* test asynchronous InternetReadFile */
5523 ok( ses != NULL, "InternetOpenA failed\n" );
5524 pInternetSetStatusCallbackA( ses, &callback );
5525
5527 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0xdeadbeef );
5528 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
5530
5532 req = HttpOpenRequestA( con, "GET", "/async_read", NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef );
5533 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
5535
5547
5548 SetLastError( 0xdeadbeef );
5549 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5550 ok( !ret, "HttpSendRequestA unexpectedly succeeded\n" );
5551 ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %lu\n", GetLastError() );
5553 ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error );
5554
5566
5567 pending_reads = 0;
5568 memset( buffer, 0, sizeof(buffer) );
5569 for (count = 0; count < sizeof(buffer); count += bytes)
5570 {
5573
5574 bytes = 0xdeadbeef;
5575 ret = InternetReadFile( req, buffer + count, min(16, sizeof(buffer) - count), &bytes );
5576 if (!count) /* the first part should arrive immediately */
5577 ok( ret, "InternetReadFile failed %lu\n", GetLastError() );
5578 if (!ret)
5579 {
5580 ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %lu\n", GetLastError() );
5582 ok( bytes == 0, "expected 0, got %lu\n", bytes );
5585 if (!pending_reads++)
5586 {
5588 ok( res == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %lu\n", res );
5590 }
5593 ok( res == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", res );
5594 ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error );
5595 todo_wine_if( pending_reads > 1 )
5596 ok( bytes != 0, "expected bytes != 0\n" );
5597 }
5602 }
5603
5606 if (!bytes) break;
5607 }
5608
5610 ok( pending_reads == 1, "expected 1 pending read, got %lu\n", pending_reads );
5611 ok( !strcmp(buffer, page1), "unexpected buffer content\n" );
5612 close_async_handle( ses, 2 );
5613}
5614
5615static void server_send_string(const char *msg)
5616{
5618}
5619
5620static size_t server_read_data(char *buf, size_t buf_size)
5621{
5622 return recv(server_socket, buf, buf_size, 0);
5623}
5624
5625#define server_read_request(a) _server_read_request(__LINE__,a)
5626static void _server_read_request(unsigned line, const char *expected_request)
5627{
5628 char buf[4000], *p;
5629 size_t size;
5630
5631 size = server_read_data(buf, sizeof(buf) - 1);
5632 buf[size] = 0;
5633 p = strstr(buf, "\r\n");
5634 if(p) *p = 0;
5635 ok_(__FILE__,line)(p && !strcmp(buf, expected_request), "unexpected request %s\n", buf);
5636}
5637
5640
5642{
5643 switch(status) {
5646 callback(handle, context, status, info, info_size);
5647 break;
5650 callback(handle, context, status, info, info_size);
5652 break;
5654 callback(handle, context, status, info, info_size);
5656 break;
5657 default:
5658 callback(handle, context, status, info, info_size);
5659 }
5660}
5661
5662static void send_socket_request(test_request_t *req, BOOL new_connection)
5663{
5664 BOOL ret;
5665
5668 if(new_connection) {
5671 }
5676
5677 SetLastError(0xdeadbeef);
5678 ret = HttpSendRequestA(req->request, NULL, 0, NULL, 0);
5679 ok(!ret, "HttpSendRequestA unexpectedly succeeded\n");
5680 ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %lu\n", GetLastError());
5681
5682 if(new_connection)
5685
5688 if(new_connection) {
5691 }
5694}
5695
5696static void open_socket_request(int port, test_request_t *req, const char *verb)
5697{
5698 /* We're connecting to new socket */
5699 if(!verb)
5700 reset_events();
5701
5703 ok(req->session != NULL, "InternetOpenA failed\n");
5704 pInternetSetStatusCallbackA(req->session, readex_callback);
5705
5707 req->connection = InternetConnectA(req->session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0xdeadbeef);
5708 ok(req->connection != NULL, "InternetConnectA failed %lu\n", GetLastError());
5710
5712 req->request = HttpOpenRequestA(req->connection, "GET", verb ? verb : "/socket",
5713 NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef);
5714 ok(req->request != NULL, "HttpOpenRequestA failed %lu\n", GetLastError());
5716
5717 send_socket_request(req, !verb);
5718}
5719
5720static void open_read_test_request(int port, test_request_t *req, const char *response)
5721{
5724
5726
5729 received_response_size = 0xdeadbeef;
5730 }
5732
5733 server_send_string(response);
5735
5739 todo_wine
5740 ok(received_response_size == strlen(response), "received_response_size = %lu\n", received_response_size);
5741 }
5743 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error);
5744}
5745
5746#define readex_expect_sync_data_len(a,b,c,d,e,f,g) _readex_expect_sync_data_len(__LINE__,a,b,c,d,e,f,g)
5748 DWORD buf_size, const char *exdata, DWORD len, DWORD expect_receive)
5749{
5750 BOOL ret;
5751
5752 if(!skip_receive_notification_tests && expect_receive) {
5755 received_response_size = 0xdeadbeef;
5756 }
5757
5758 memset(buf->lpvBuffer, 0xff, buf_size);
5759 buf->dwBufferLength = buf_size;
5760 ret = InternetReadFileExW(req, buf, flags, 0xdeadbeef);
5761 ok_(__FILE__,line)(ret, "InternetReadFileExW failed: %lu\n", GetLastError());
5762 ok_(__FILE__,line)(buf->dwBufferLength == len, "dwBufferLength = %lu, expected %lu\n", buf->dwBufferLength, len);
5763 if(len && exdata)
5764 ok_(__FILE__,line)(!memcmp(buf->lpvBuffer, exdata, len), "Unexpected data\n");
5765
5766 if(!skip_receive_notification_tests && expect_receive) {
5769 ok_(__FILE__,line)(received_response_size == len, "received_response_size = %lu\n", received_response_size);
5770 }
5771}
5772
5773#define readex_expect_sync_data(a,b,c,d,e,f) _readex_expect_sync_data(__LINE__,a,b,c,d,e,f)
5775 DWORD buf_size, const char *exdata, DWORD expect_receive)
5776{
5777 _readex_expect_sync_data_len(line, req, flags, buf, buf_size, exdata, strlen(exdata), expect_receive);
5778}
5779
5780#define read_expect_sync_data_len(a,b,c,d,e) _read_expect_sync_data_len(__LINE__,a,b,c,d,e)
5781static void _read_expect_sync_data_len(unsigned line, HINTERNET req, void *buf, DWORD buf_size,
5782 const char *exdata, DWORD len)
5783{
5784 DWORD ret_size = 0xdeadbeef;
5785 BOOL ret;
5786
5790 received_response_size = 0xdeadbeef;
5791
5792 memset(buf, 0xff, buf_size);
5793 ret = InternetReadFile(req, buf, buf_size, &ret_size);
5794 ok_(__FILE__,line)(ret, "InternetReadFileExW failed: %lu\n", GetLastError());
5795 ok_(__FILE__,line)(ret_size == len, "dwBufferLength = %lu, expected %lu\n", ret_size, len);
5796 if(len && exdata)
5797 ok_(__FILE__,line)(!memcmp(buf, exdata, len), "Unexpected data\n");
5798
5802 ok_(__FILE__,line)(received_response_size == len, "received_response_size = %lu\n", received_response_size);
5803 ok_(__FILE__,line)(!req_error, "req_error = %lu\n", req_error);
5804}
5805
5806#define read_expect_sync_data(a,b,c,d) _read_expect_sync_data(__LINE__,a,b,c,d)
5807static void _read_expect_sync_data(unsigned line, HINTERNET req, void *buf,
5808 DWORD buf_size, const char *exdata)
5809{
5810 _read_expect_sync_data_len(line, req, buf, buf_size, exdata, strlen(exdata));
5811}
5812
5813static void close_connection(void)
5814{
5815 char c;
5817 recv(server_socket, &c, 1, 0);
5818}
5819
5820#define send_response_and_wait(a,b,c,d,e,f,g,h) _send_response_and_wait(__LINE__,a,b,c,d,e,f,g,h)
5821static void _send_response_and_wait(unsigned line, const char *response, BOOL do_close_connection,
5822 void *buf, DWORD *ret_size, const char *exdata,
5823 DWORD expected_size, DWORD expected_req_error, DWORD expected_receive_size)
5824{
5828
5829 if(response)
5830 server_send_string(response);
5831
5832 if(do_close_connection)
5834
5836
5840 if(!skip_receive_notification_tests && expected_receive_size != -1)
5841 todo_wine_if(received_response_size != expected_receive_size) /* FIXME! remove when wine is fixed */
5842 ok_(__FILE__,line)(received_response_size == expected_receive_size,
5843 "received_response_size = %lu\n", received_response_size);
5844 ok_(__FILE__,line)(req_error == expected_req_error, "req_error = %lu, expected %lu\n", req_error, expected_req_error);
5845
5846 /* If IRF_NO_WAIT is used, buffer is not changed. */
5847 ok_(__FILE__,line)(*ret_size == expected_size, "dwBufferLength = %lu\n", *ret_size);
5848 if(exdata)
5849 ok_(__FILE__,line)(!memcmp(buf, exdata, strlen(exdata)), "unexpected buffer data\n");
5850 else if(buf)
5851 ok_(__FILE__,line)(!*(DWORD*)buf, "buffer data changed\n");
5852}
5853
5854#define send_response_ex_and_wait(a,b,c,d,e,f) _send_response_ex_and_wait(__LINE__,a,b,c,d,e,f)
5855static void _send_response_ex_and_wait(unsigned line, const char *response, BOOL close_connection,
5856 INTERNET_BUFFERSW *buf, const char *exdata, DWORD expected_req_error,
5857 DWORD expected_receive_size)
5858{
5859 _send_response_and_wait(line, response, close_connection, buf->lpvBuffer, &buf->dwBufferLength,
5860 exdata, exdata ? strlen(exdata) : buf->dwBufferLength, expected_req_error,
5861 expected_receive_size);
5862}
5863
5865{
5866 char *response;
5867
5868 response = HeapAlloc(GetProcessHeap(), 0, len+1);
5869 memset(response, 'x', len);
5870 response[len] = 0;
5872 HeapFree(GetProcessHeap(), 0, response);
5873}
5874
5875#define readex_expect_async(a,b,c,d,e) _readex_expect_async(__LINE__,a,b,c,d,e)
5877 DWORD buf_size, const char *exdata)
5878{
5879 unsigned len = 0;
5880 BOOL ret;
5881
5884
5885 memset(buf->lpvBuffer, 0, max(buf_size, sizeof(DWORD)));
5886 buf->dwBufferLength = buf_size;
5887 ret = InternetReadFileExW(req, buf, flags, 0xdeadbeef);
5888 ok_(__FILE__,line)(!ret && GetLastError() == ERROR_IO_PENDING, "InternetReadFileExW returned %x (%lu)\n", ret, GetLastError());
5889 ok_(__FILE__,line)(buf->dwBufferLength == buf_size, "dwBufferLength = %lu, expected %lu\n", buf->dwBufferLength, buf_size);
5890 if(exdata) {
5891 len = strlen(exdata);
5892 ok_(__FILE__,line)(!memcmp(buf->lpvBuffer, exdata, len), "unexpected buffer data\n");
5893 }else {
5894 ok_(__FILE__,line)(!*(DWORD*)buf->lpvBuffer, "buffer data changed\n");
5895 }
5896
5899}
5900
5901static void read_expect_async(HINTERNET req, void *buf, DWORD buf_size, DWORD *ret_size, const char *exdata)
5902{
5903 unsigned len = 0;
5904 const char *p;
5905 BOOL ret;
5906
5908
5909 *ret_size = 0xdeadbeef;
5910 memset(buf, 0, buf_size);
5911 ret = InternetReadFile(req, buf, buf_size, ret_size);
5912 ok(!ret && GetLastError() == ERROR_IO_PENDING, "InternetReadFileExW returned %x (%lu)\n", ret, GetLastError());
5913 ok(*ret_size == 0, "dwBufferLength = %lu\n", *ret_size);
5914 if(exdata) {
5915 len = strlen(exdata);
5916 ok(!memcmp(buf, exdata, len), "unexpected buffer data\n");
5917 }
5918 for(p = (const char*)buf + len; p < (const char*)buf + buf_size; p++) {
5919 if(*p)
5920 ok(0, "buffer data changed\n");
5921 }
5922
5924}
5925
5926#define expect_data_available(a,b) _expect_data_available(__LINE__,a,b)
5927static DWORD _expect_data_available(unsigned line, HINTERNET req, int exsize)
5928{
5929 DWORD size = 0;
5930 BOOL res;
5931
5932 res = InternetQueryDataAvailable(req, &size, 0, 0);
5933 ok_(__FILE__,line)(res, "InternetQueryDataAvailable failed: %lu\n", GetLastError());
5934 if(exsize != -1)
5935 ok_(__FILE__,line)(size == exsize, "size = %lu, expected %u\n", size, exsize);
5936
5937 return size;
5938}
5939
5940#define async_query_data_available(a,b) _async_query_data_available(__LINE__,a,b)
5942{
5943 BOOL res;
5944
5947
5948 *size = 0xdeadbeef;
5949 res = InternetQueryDataAvailable(req, size, 0, 0);
5950 ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING,
5951 "InternetQueryDataAvailable returned: %x(%lu)\n", res, GetLastError());
5952 ok_(__FILE__,line)(!*size, "size = %lu\n", *size);
5953
5956}
5957
5958static void test_http_read(int port)
5959{
5961 test_request_t req;
5962 DWORD read_size;
5963 char buf[24000];
5964 DWORD avail, i;
5965
5966 if(!is_ie7plus)
5967 return;
5968
5969 memset(&ib, 0, sizeof(ib));
5970 ib.dwStructSize = sizeof(ib);
5971 ib.lpvBuffer = buf;
5972
5973 trace("Testing InternetReadFileExW with IRF_ASYNC flag...\n");
5974
5976 "HTTP/1.1 200 OK\r\n"
5977 "Server: winetest\r\n"
5978 "\r\n"
5979 "xx");
5980
5981 readex_expect_async(req.request, IRF_ASYNC, &ib, 4, "xx");
5982
5983 send_response_ex_and_wait("yy1234567890", FALSE, &ib, "xxyy", 0, 2);
5984 readex_expect_sync_data(req.request, IRF_ASYNC, &ib, 4, "1234", 4);
5985 readex_expect_sync_data(req.request, IRF_ASYNC, &ib, 5, "56789", 5);
5986
5987 readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), "0");
5988 send_response_ex_and_wait("123", TRUE, &ib, "0123", 0, 4);
5989
5991
5992 trace("Testing InternetReadFileExW with no flags...\n");
5993
5995 "HTTP/1.1 200 OK\r\n"
5996 "Server: winetest\r\n"
5997 "\r\n"
5998 "xx");
5999
6000 readex_expect_async(req.request, 0, &ib, 4, "xx");
6001
6002 send_response_ex_and_wait("yy1234567890", FALSE, &ib, "xxyy", 0, 2);
6003 readex_expect_sync_data(req.request, 0, &ib, 4, "1234", 4);
6004 readex_expect_sync_data(req.request, 0, &ib, 5, "56789", 5);
6005
6006 readex_expect_async(req.request, 0, &ib, sizeof(buf), "0");
6007 send_response_ex_and_wait("123", TRUE, &ib, "0123", 0, 4);
6008
6010
6011 trace("Testing InternetReadFile...\n");
6012
6014 "HTTP/1.1 200 OK\r\n"
6015 "Server: winetest\r\n"
6016 "\r\n"
6017 "xx");
6018
6019 read_expect_async(req.request, buf, 4, &read_size, "xx");
6020
6021 send_response_and_wait("yy1234567890", FALSE, buf, &read_size, "xxyy", 4, 0, 2);
6022 read_expect_sync_data(req.request, buf, 4, "1234");
6023 read_expect_sync_data(req.request, buf, 5, "56789");
6024
6025 read_expect_async(req.request, buf, sizeof(buf), &read_size, "0");
6026 send_response_and_wait("123", TRUE, buf, &read_size, "0123", 4, 0, 4);
6027
6029
6030 trace("Testing InternetReadFileExW with IRF_NO_WAIT flag...\n");
6031
6033 "HTTP/1.1 200 OK\r\n"
6034 "Server: winetest\r\n"
6035 "\r\n"
6036 "xx");
6037
6039
6040 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "xx", 0);
6041
6043 win_skip("Skipping receive notification tests on too old Windows.\n");
6045 }
6047
6048 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
6049 send_response_ex_and_wait("1234567890", FALSE, &ib, NULL, 0, 10);
6050 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, 5, "12345", 0);
6051 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "67890", 0);
6052
6053 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
6054 send_response_ex_and_wait("12345", TRUE, &ib, NULL, 0, 5);
6055
6056 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "12345", 0);
6057 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", TRUE);
6058
6060
6062 "HTTP/1.1 200 OK\r\n"
6063 "Server: winetest\r\n"
6064 "Transfer-Encoding: chunked\r\n"
6065 "\r\n"
6066 "9\r\n123456789");
6067 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123456789", 0);
6068 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
6069
6070 send_response_ex_and_wait("\r\n1\r\na\r\n1\r\nb\r", FALSE, &ib, NULL, 0, 13);
6071 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0);
6072 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
6073
6074 send_response_ex_and_wait("\n3\r\nab", FALSE, &ib, NULL, 0, 6);
6075 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0);
6076 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
6077
6078 send_response_ex_and_wait("c", FALSE, &ib, NULL, 0, 1);
6079 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "c", 0);
6080 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
6081
6082 send_response_ex_and_wait("\r\n1\r\nx\r\n0\r\n\r\n", TRUE, &ib, NULL, 0, 13);
6083 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "x", 0);
6084 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", 0);
6085
6087
6089 "HTTP/1.1 200 OK\r\n"
6090 "Server: winetest\r\n"
6091 "Transfer-Encoding: chunked\r\n"
6092 "\r\n"
6093 "3\r\n123\r\n");
6094 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123", 0);
6095 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
6096
6097 send_response_ex_and_wait("0\r\n\r\n", TRUE, &ib, NULL, 0, 5);
6098 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", 0);
6099
6101
6103 "HTTP/1.1 200 OK\r\n"
6104 "Server: winetest\r\n"
6105 "Connection: close\r\n"
6106 "\r\n");
6107 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
6108 send_response_ex_and_wait("123", TRUE, &ib, NULL, 0, 3);
6109 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123", 0);
6110
6116
6117 trace("Testing InternetQueryDataAvailable...\n");
6118
6120 "HTTP/1.1 200 OK\r\n"
6121 "Server: winetest\r\n"
6122 "\r\n"
6123 "123");
6125 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123", 0);
6126 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
6127
6128 send_response_len_and_wait(20000, TRUE, &ib);
6130 ok(avail <= 20000, "avail = %lu\n", avail);
6131
6137
6139 "HTTP/1.1 200 OK\r\n"
6140 "Server: winetest\r\n"
6141 "Connection: close\r\n"
6142 "\r\n"
6143 "123");
6144
6146 readex_expect_sync_data(req.request, 0, &ib, 3, "123", 0);
6147
6148 async_query_data_available(req.request, &read_size);
6149 send_response_and_wait("1234567890", FALSE, NULL, &read_size, NULL, 10, 10, 10);
6150
6151 readex_expect_sync_data(req.request, 0, &ib, 9, "123456789", 0);
6153 readex_expect_sync_data(req.request, 0, &ib, 1, "0", 0);
6154
6155 async_query_data_available(req.request, &read_size);
6156 send_response_and_wait("1234567890", FALSE, NULL, &read_size, NULL, 10, 10, 10);
6158 for(i = 0; i < 10; i++)
6159 server_send_string("x");
6161
6162 readex_expect_async(req.request, IRF_ASYNC, &ib, 21, "1234567890");
6163 send_response_ex_and_wait("X", FALSE, &ib, "1234567890xxxxxxxxxxX", 0, 11);
6164 async_query_data_available(req.request, &read_size);
6165
6168 send_response_and_wait(NULL, TRUE, NULL, &read_size, NULL, 0, 0, 0);
6171
6173
6175}
6176
6177static void test_file_pointer(int port)
6178{
6180 test_request_t req;
6181 char buf[24000];
6182 DWORD pos, read_size;
6183
6185
6186 memset(&ib, 0, sizeof(ib));
6187 ib.dwStructSize = sizeof(ib);
6188 ib.lpvBuffer = buf;
6189
6191 "HTTP/1.1 200 OK\r\n"
6192 "Server: winetest\r\n"
6193 "Content-Length: 100\r\n"
6194 "\r\n"
6195 "xyz");
6196
6198 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "xyz", 0);
6200
6201 /* jump back to 2nd byte */
6203 ok(pos == 2, "pos = %ld (gle %lu)\n", pos, GetLastError());
6204
6206 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "z", 0);
6207
6208 /* jump forward to 5th byte (not yet available) */
6210 ok(pos == 5, "pos = %ld (gle %lu)\n", pos, GetLastError());
6211
6212 /* querying available data will wait until we have enough data */
6213 async_query_data_available(req.request, &read_size);
6214 send_response_and_wait("12345", FALSE, NULL, &read_size, NULL, 3, 3, 61);
6216
6217 /* skip one byte and verify that we're at expected position by reading one byte */
6219 ok(pos == 6, "pos = %ld (gle %lu)\n", pos, GetLastError());
6220 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, 1, "4", 0);
6221
6222 /* jump past available bytes, read will wait for available data */
6224 ok(pos == 9, "pos = %ld (gle %lu)\n", pos, GetLastError());
6225
6226 readex_expect_async(req.request, IRF_ASYNC, &ib, 3, "");
6227 send_response_ex_and_wait("abcde", FALSE, &ib, "bcd", 0, 61);
6228
6229 /* jump back to the beginning */
6231 ok(pos == 0, "pos = %ld (gle %lu)\n", pos, GetLastError());
6232 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, 12, "xyz12345abcd", 0);
6233
6234 /* jump past the available data then send more data and close the connection */
6236 ok(pos == 15, "pos = %ld (gle %lu)\n", pos, GetLastError());
6237 readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), "");
6238 send_response_ex_and_wait("12345", TRUE, &ib, "345", 0, 61);
6239
6243 todo_wine
6245 todo_wine
6247
6249}
6250
6252{
6254 test_request_t req;
6255 char buf[24000];
6256
6257 if(!is_ie7plus)
6258 return;
6259
6260 memset(&ib, 0, sizeof(ib));
6261 ib.dwStructSize = sizeof(ib);
6262 ib.lpvBuffer = buf;
6263
6264 trace("Testing InternetReadFileExW on broken connection...\n");
6265
6267 "HTTP/1.1 200 OK\r\n"
6268 "Server: winetest\r\n"
6269 "Content-Length: 10000\r\n"
6270 "\r\n"
6271 "xx");
6272
6273 /* close connection and make sure that it's closed on handle release. */
6280}
6281
6282static void test_long_url(int port)
6283{
6284 char long_path[INTERNET_MAX_PATH_LENGTH*2] = "/echo_request?";
6285 char buf[sizeof(long_path)*2], url[sizeof(buf)];
6286 test_request_t req;
6287 DWORD size, len;
6288 BOOL ret;
6289
6290 if(!is_ie7plus)
6291 return;
6292
6293 memset(long_path+strlen(long_path), 'x', sizeof(long_path)-strlen(long_path));
6294 long_path[sizeof(long_path)-1] = 0;
6295 open_simple_request(&req, "localhost", port, NULL, long_path);
6296
6297 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
6298 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
6299 test_status_code(req.request, 200);
6300
6301 receive_simple_request(req.request, buf, sizeof(buf));
6302 ok(strstr(buf, long_path) != NULL, "long pathnot found in %s\n", buf);
6303
6304 sprintf(url, "http://localhost:%u%s", port, long_path);
6305
6306 size = sizeof(buf);
6308 ok(ret, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %lu\n", GetLastError());
6309 len = strlen(url);
6310 ok(size == len, "size = %lu, expected %lu\n", size, len);
6311 ok(!strcmp(buf, url), "Wrong URL %s, expected %s\n", buf, url);
6312
6313 close_request(&req);
6314}
6315
6317{
6319 test_request_t req;
6320 char buf[24000];
6321
6322 if(!is_ie7plus)
6323 return;
6324
6325 memset(&ib, 0, sizeof(ib));
6326 ib.dwStructSize = sizeof(ib);
6327 ib.lpvBuffer = buf;
6328
6330
6331 trace("Testing persistent connection...\n");
6332
6334 "HTTP/1.1 200 OK\r\n"
6335 "Server: winetest\r\n"
6336 "Content-Length: 2\r\n"
6337 "\r\n"
6338 "xx");
6339 readex_expect_sync_data(req.request, IRF_ASYNC, &ib, 4, "xx", 0);
6341
6342 open_socket_request(port, &req, "/test_simple_chunked");
6343 server_read_request("GET /test_simple_chunked HTTP/1.1");
6344
6346 server_send_string("HTTP/1.1 200 OK\r\n"
6347 "Server: winetest\r\n"
6348 "Transfer-Encoding: chunked\r\n"
6349 "\r\n"
6350 "2\r\nab\r\n");
6353 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error);
6354
6355 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0);
6356 readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), NULL);
6357 send_response_ex_and_wait("3\r\nabc\r\n0\r\n\r\n", FALSE, &ib, "abc", 0, 13);
6359
6360 open_socket_request(port, &req, "/chunked");
6361 server_read_request("GET /chunked HTTP/1.1");
6362
6364 server_send_string("HTTP/1.1 200 OK\r\n"
6365 "Server: winetest\r\n"
6366 "Transfer-Encoding: chunked\r\n"
6367 "\r\n"
6368 "2\r\nab\r\n");
6371 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error);
6372
6373 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, 3, "ab", 0);
6375 send_response_ex_and_wait("3\r\nabc\r\n", FALSE, &ib, "abc", 0, 13);
6376
6377 /* send another request on the same request handle, it must drain remaining last chunk marker */
6378 server_send_string("0\r\n\r\n");
6379
6381 server_read_request("GET /chunked HTTP/1.1");
6382
6385 server_send_string("HTTP/1.1 201 OK\r\n"
6386 "Server: winetest\r\n"
6387 "Content-Length: 0\r\n"
6388 "Connection: keep-alive\r\n"
6389 "\r\n");
6392 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error);
6393
6394 test_status_code(req.request, 201);
6396
6397 /* the connection is still valid */
6398 open_socket_request(port, &req, "/another_chunked");
6399 server_read_request("GET /another_chunked HTTP/1.1");
6400
6402 server_send_string("HTTP/1.1 200 OK\r\n"
6403 "Server: winetest\r\n"
6404 "Transfer-Encoding: chunked\r\n"
6405 "\r\n"
6406 "2\r\nab\r\n");
6409 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error);
6410
6411 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0);
6412 readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), NULL);
6413
6414 /* we're missing trailing '\n'; the connection can't be drained without blocking,
6415 * so it will be closed */
6416 send_response_ex_and_wait("3\r\nabc\r\n0\r\n\r", FALSE, &ib, "abc", 0, 13);
6417
6423
6426}
6427
6428static void test_redirect(int port)
6429{
6430 char buf[4000], expect_url[INTERNET_MAX_URL_LENGTH];
6432 test_request_t req;
6433
6434 if(!is_ie7plus)
6435 return;
6436
6438
6439 memset(&ib, 0, sizeof(ib));
6440 ib.dwStructSize = sizeof(ib);
6441 ib.lpvBuffer = buf;
6442
6443 trace("Testing redirection...\n");
6444
6446
6451
6452 server_send_string("HTTP/1.1 302 Found\r\n"
6453 "Server: winetest\r\n"
6454 "Location: test_redirection\r\n"
6455 "Connection: keep-alive\r\n"
6456 "Content-Length: 0\r\n"
6457 "\r\n");
6458
6459 server_read_request("GET /test_redirection HTTP/1.1");
6460
6462
6463 sprintf(expect_url, "http://localhost:%u/test_redirection", port);
6464 test_request_url(req.request, expect_url);
6465
6467
6468 server_send_string("HTTP/1.1 200 OK\r\n"
6469 "Server: winetest\r\n"
6470 "Content-Length: 3\r\n"
6471 "\r\n"
6472 "xxx");
6473
6475
6480 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error);
6481
6482 test_status_code(req.request, 200);
6483
6486
6487 trace("Test redirect to non-http URL...\n");
6488
6490
6492
6493 server_send_string("HTTP/1.1 302 Found\r\n"
6494 "Server: winetest\r\n"
6495 "Location: test:non:http/url\r\n"
6496 "Connection: keep-alive\r\n"
6497 "Content-Length: 0\r\n"
6498 "\r\n");
6499
6501
6503 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %lu\n", req_error);
6504
6505 sprintf(expect_url, "http://localhost:%u/socket", port);
6506 test_request_url(req.request, expect_url);
6507 test_status_code(req.request, 302);
6508
6511
6512 trace("Test redirect to http URL with no host name...\n");
6513
6515
6517
6518 server_send_string("HTTP/1.1 302 Found\r\n"
6519 "Server: winetest\r\n"
6520 "Location: http:///nohost\r\n"
6521 "Connection: keep-alive\r\n"
6522 "Content-Length: 0\r\n"
6523 "\r\n");
6524
6526
6528 ok(req_error == ERROR_INTERNET_INVALID_URL, "expected ERROR_INTERNET_INVALID_URL, got %lu\n", req_error);
6529
6530 sprintf(expect_url, "http://localhost:%u/socket", port);
6531 test_request_url(req.request, expect_url);
6532 test_status_code(req.request, 302);
6533
6536
6538}
6539
6541{
6542 test_request_t req;
6543 BOOL ret;
6544
6545 open_simple_request(&req, "localhost", port, NULL, "/A/../B/./C/../../test_remove_dot_segments");
6546
6547 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
6548 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
6549 test_status_code(req.request, 200);
6550
6551 close_request(&req);
6552}
6553
6555{
6558};
6559
6560static void test_large_content(int port)
6561{
6562 struct large_test tests[] = {
6563 { 0, TRUE },
6564 { UINT_MAX-1, TRUE },
6565 { UINT_MAX, TRUE },
6566 { (DWORD64)UINT_MAX+1, FALSE },
6567 { ~0, FALSE },
6568 };
6569 test_request_t req;
6570 DWORD sizelen, len;
6571 DWORD read_size;
6572 DWORD64 len64;
6573 char buf[16];
6574 BOOL ret;
6575 size_t i;
6576
6577 open_simple_request(&req, "localhost", port, "HEAD", "/test_large_content");
6578
6579 for (i = 0; i < ARRAY_SIZE(tests); i++)
6580 {
6581 content_length = tests[i].content_length;
6582 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
6583 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
6584
6585 len = ~0;
6586 sizelen = sizeof(len);
6587 SetLastError(0xdeadbeef);
6589 &len, &sizelen, 0);
6590 if (tests[i].ret)
6591 {
6592 ok(ret, "HttpQueryInfo should have succeeded\n");
6594 broken(GetLastError() == 0xdeadbeef), /* xp, 2k8, vista */
6595 "expected ERROR_SUCCESS, got %lx\n", GetLastError());
6596 ok(len == (DWORD)tests[i].content_length, "expected %lu, got %lu\n",
6598 }
6599 else
6600 {
6601 ok(!ret, "HttpQueryInfo should have failed\n");
6603 "expected ERROR_HTTP_INVALID_HEADER, got %lx\n", GetLastError());
6604 ok(len == ~0, "expected ~0, got %lu\n", len);
6605 }
6606 ok(sizelen == sizeof(DWORD), "sizelen %lu\n", sizelen);
6607 }
6608
6609 /* test argument size */
6610 len64 = ~0;
6611 sizelen = sizeof(len64);
6612 SetLastError(0xdeadbeef);
6614 &len64, &len, 0);
6615 ok(!ret, "HttpQueryInfo should have failed\n");
6617 "expected ERROR_HTTP_INVALID_HEADER, got %lx\n", GetLastError());
6618 ok(sizelen == sizeof(DWORD64), "sizelen %lu\n", sizelen);
6619 ok(len64 == ~0, "len64 %I64x\n", len64);
6620
6621 close_request(&req);
6622
6623 /* test internal use of HttpQueryInfo on large size */
6625 "HTTP/1.1 200 OK\r\n"
6626 "Server: winetest\r\n"
6627 "Content-Length: 4294967296\r\n"
6628 "\r\n"
6629 "xx");
6630 read_expect_async(req.request, buf, 4, &read_size, "xx");
6631 send_response_and_wait("yy1234567890", FALSE, buf, &read_size, "xxyy", 4, 0, 2);
6632 read_expect_sync_data(req.request, buf, 10, "1234567890");
6633
6640}
6641
6642static void test_header_length(int port)
6643{
6644 test_request_t req;
6645 BOOL ret;
6646 char buf[1000];
6647 char header[] = "Test-Header: winetest";
6648 WCHAR wheader[] = L"Test-Header: winetest";
6649 INTERNET_BUFFERSA buffer_in;
6650 INTERNET_BUFFERSW wbuffer_in;
6651
6652 open_simple_request(&req, "localhost", port, "GET", "/echo_request");
6653
6654 ret = HttpSendRequestA(req.request, header, 0, NULL, 0);
6655 ok(ret == FALSE, "HttpSendRequestA should have failed\n");
6656 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER\n");
6657
6658 ret = HttpSendRequestW(req.request, wheader, 0, NULL, 0);
6659 ok(ret, "HttpSendRequestW failed: %lu\n", GetLastError());
6660 test_status_code(req.request, 200);
6661
6662 receive_simple_request(req.request, buf, sizeof(buf));
6663 ok(strstr(buf, header) != NULL, "custom header was not sent: %s\n", buf);
6664
6665 close_request(&req);
6666
6667 open_simple_request(&req, "localhost", port, "GET", "/echo_request");
6668
6669 ZeroMemory(&buffer_in, sizeof(buffer_in));
6670 buffer_in.dwStructSize = sizeof(buffer_in);
6671 buffer_in.lpcszHeader = header;
6672 ret = HttpSendRequestExA(req.request, &buffer_in, NULL, 0, 0);
6673 ok(ret == FALSE, "HttpSendRequestExA should have failed\n");
6674 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER\n");
6675
6676 ZeroMemory(&wbuffer_in, sizeof(wbuffer_in));
6677 wbuffer_in.dwStructSize = sizeof(wbuffer_in);
6678 wbuffer_in.lpcszHeader = wheader;
6679 ret = HttpSendRequestExW(req.request, &wbuffer_in, NULL, 0, 0);
6680 ok(ret, "HttpSendRequestExW failed: %lu\n", GetLastError());
6681
6682 ret = HttpEndRequestW(req.request, NULL, 0, 0);
6683 ok(ret, "HttpEndRequestW failed: %lu\n", GetLastError());
6684
6685 test_status_code(req.request, 200);
6686
6687 receive_simple_request(req.request, buf, sizeof(buf));
6688 ok(strstr(buf, header) != NULL, "custom header was not sent: %s\n", buf);
6689
6690 close_request(&req);
6691}
6692
6693static void test_pac(int port)
6694{
6695 static const WCHAR autoconf_url_fmt[] = L"http://localhost:%d/proxy.pac?ver=1";
6698 WCHAR autoconf_url[64];
6699 test_request_t req;
6700 char buf[1000];
6701 DWORD len;
6702 BOOL r;
6703
6704 open_simple_request_proxy(&req, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, "GET", "/tests/hello.html");
6705
6706 swprintf(autoconf_url, ARRAY_SIZE(autoconf_url), autoconf_url_fmt, port);
6707 memset(&option_list, 0, sizeof(option_list));
6708 option_list.dwSize = sizeof(option_list);
6709 option_list.dwOptionCount = ARRAY_SIZE(options);
6710 option_list.pOptions = options;
6712 options[0].Value.pszValue = autoconf_url;
6713 options[1].dwOption = INTERNET_PER_CONN_FLAGS;
6714 options[1].Value.dwValue = PROXY_TYPE_AUTO_PROXY_URL;
6715 r = InternetSetOptionW(req.session, INTERNET_OPTION_PER_CONNECTION_OPTION, (void*)&option_list, sizeof(option_list));
6716 ok(r, "InternetSetOptionW failed: %lu\n", GetLastError());
6717
6718 r = HttpSendRequestW(req.request, NULL, 0, NULL, 0);
6719 ok(r, "HttpSendRequestW failed: %lu\n", GetLastError());
6720
6721 test_status_code(req.request, 200);
6722 len = receive_simple_request(req.request, buf, sizeof(buf));
6723 todo_wine
6724 ok(len == sizeof(page1) - 1, "unexpected buffer size\n");
6725 buf[len] = 0;
6726 todo_wine
6727 ok(!strcmp(buf, page1), "unexpected buffer content\n");
6728
6729 len = sizeof(option_list);
6731 ok(r, "InternetGetOptionW failed: %lu\n", GetLastError());
6732 r = InternetSetOptionW(req.session, INTERNET_OPTION_PER_CONNECTION_OPTION, (void*)&option_list, sizeof(option_list));
6733 ok(r, "InternetSetOptionW failed: %lu\n", GetLastError());
6734 GlobalFree(options[0].Value.pszValue);
6735
6736 close_request(&req);
6737}
6738
6739static void test_http_connection(void)
6740{
6741 struct server_info si;
6743 DWORD id = 0, r;
6744
6745 si.hEvent = CreateEventW(NULL, 0, 0, NULL);
6746 si.port = 7531;
6747
6748 hThread = CreateThread(NULL, 0, server_thread, &si, 0, &id);
6749 ok( hThread != NULL, "create thread failed\n");
6750
6751 r = WaitForSingleObject(si.hEvent, 10000);
6752 ok (r == WAIT_OBJECT_0, "failed to start wininet test server\n");
6753 if (r != WAIT_OBJECT_0)
6754 {
6756 return;
6757 }
6758
6759 test_basic_request(si.port, "GET", "/test1");
6760 test_proxy_indirect(si.port);
6761 test_proxy_direct(si.port);
6763 test_basic_request(si.port, "POST", "/test5");
6764 test_basic_request(si.port, "RPC_IN_DATA", "/test5");
6765 test_basic_request(si.port, "RPC_OUT_DATA", "/test5");
6766 test_basic_request(si.port, "GET", "/test6");
6767 test_basic_request(si.port, "GET", "/testF");
6770 test_cookie_header(si.port);
6774 test_HttpQueryInfo(si.port);
6776 test_options(si.port);
6777 test_no_content(si.port);
6778 test_not_modified(si.port);
6779 test_large_header(si.port);
6780 test_conn_close(si.port);
6781 test_no_cache(si.port);
6783 test_http_status(si.port);
6788 test_head_request(si.port);
6796 test_async_read(si.port);
6797 test_http_read(si.port);
6798 test_file_pointer(si.port);
6800 test_long_url(si.port);
6801#ifdef __REACTOS__
6803{
6804 skip("Skipping test_redirect and test_persistent_connection due to hang. See ROSTESTS-294.\n");
6805}
6806else
6807{
6808#endif
6809 test_redirect(si.port);
6811#ifdef __REACTOS__
6812}
6813#endif
6815 test_large_content(si.port);
6816 test_header_length(si.port);
6817 test_pac(si.port);
6818
6819 /* send the basic request again to shutdown the server thread */
6820 test_basic_request(si.port, "GET", "/quit");
6821
6822 r = WaitForSingleObject(hThread, 3000);
6823 ok( r == WAIT_OBJECT_0, "thread wait failed\n");
6825}
6826
6828{
6829 LocalFree(info->lpszSubjectInfo);
6830 LocalFree(info->lpszIssuerInfo);
6831 LocalFree(info->lpszProtocolName);
6832 LocalFree(info->lpszSignatureAlgName);
6833 LocalFree(info->lpszEncryptionAlgName);
6834}
6835
6836typedef struct {
6837 const char *ex_subject;
6838 const char *ex_issuer;
6840
6842 "test.winehq.org",
6843
6844 "US\r\n"
6845 "Let's Encrypt\r\n"
6846};
6847
6849 "US\r\n"
6850 "Minnesota\r\n"
6851 "Saint Paul\r\n"
6852 "WineHQ\r\n"
6853 "IT\r\n"
6854 "test.winehq.com\r\n"
6855 "webmaster@winehq.org",
6856
6857 "US\r\n"
6858 "Minnesota\r\n"
6859 "Saint Paul\r\n"
6860 "WineHQ\r\n"
6861 "IT\r\n"
6862 "test.winehq.com\r\n"
6863 "webmaster@winehq.org"
6864};
6865
6866static const char *cert_string_fmt =
6867 "Subject:\r\n%s\r\n"
6868 "Issuer:\r\n%s\r\n"
6869 "Effective Date:\t%s %s\r\n"
6870 "Expiration Date:\t%s %s\r\n"
6871 "Security Protocol:\t%s\r\n"
6872 "Signature Type:\t%s\r\n"
6873 "Encryption Type:\t%s\r\n"
6874 "Privacy Strength:\t%s (%u bits)";
6875
6877{
6878 SYSTEMTIME start, expiry;
6879 char expiry_date[32];
6880 char expiry_time[32];
6881 char start_date[32];
6882 char start_time[32];
6883 char expect[512];
6884 char actual[512];
6885 DWORD size;
6886 BOOL res;
6887
6888 size = sizeof(actual);
6889 SetLastError(0xdeadbeef);
6890 memset(actual, 0x55, sizeof(actual));
6892 ok(res, "InternetQueryOption failed: %lu\n", GetLastError());
6893
6894 FileTimeToSystemTime(&info->ftStart, &start);
6895 FileTimeToSystemTime(&info->ftExpiry, &expiry);
6896
6897 GetDateFormatA(LOCALE_USER_DEFAULT, 0, &start, NULL, start_date, sizeof(start_date));
6898 GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &start, NULL, start_time, sizeof(start_time));
6899 GetDateFormatA(LOCALE_USER_DEFAULT, 0, &expiry, NULL, expiry_date, sizeof(expiry_date));
6900 GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &expiry, NULL, expiry_time, sizeof(expiry_time));
6901
6902 snprintf(expect, sizeof(expect), cert_string_fmt, info->lpszSubjectInfo, info->lpszIssuerInfo,
6903 start_date, start_time, expiry_date, expiry_time,
6904 info->lpszSignatureAlgName, info->lpszEncryptionAlgName, info->lpszProtocolName,
6905 info->dwKeySize >= 128 ? "High" : "Low", info->dwKeySize);
6906 ok(size == strlen(actual), "size = %lu\n", size);
6907 ok(!strcmp(actual, expect), "expected:\n%s\nactual:\n%s\n", expect, actual);
6908
6909 --size;
6910 SetLastError(0xdeadbeef);
6911 memset(actual, 0x55, sizeof(actual));
6913 ok(!res && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %ld\n", GetLastError());
6914 ok(size == 1, "unexpected size: %lu\n", size);
6915 ok(actual[0] == 0x55, "unexpected byte: %02x\n", actual[0]);
6916}
6917
6919{
6921 DWORD size;
6922 BOOL res;
6923
6924 memset(&info, 0x5, sizeof(info));
6925
6926 size = sizeof(info);
6928 if (!res)
6929 {
6930 win_skip("Querying INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT failed, skipping tests\n");
6931 return;
6932 }
6933
6934 ok(res, "InternetQueryOption failed: %lu\n", GetLastError());
6935 ok(size == sizeof(info), "size = %lu\n", size);
6936
6937 ok(!strcmp(info.lpszSubjectInfo, test->ex_subject), "lpszSubjectInfo = %s\n", info.lpszSubjectInfo);
6938 ok(!strncmp(info.lpszIssuerInfo, test->ex_issuer, strlen(test->ex_issuer)), "lpszIssuerInfo = %s\n", info.lpszIssuerInfo);
6939 ok(!info.lpszSignatureAlgName, "lpszSignatureAlgName = %s\n", info.lpszSignatureAlgName);
6940 ok(!info.lpszEncryptionAlgName, "lpszEncryptionAlgName = %s\n", info.lpszEncryptionAlgName);
6941 ok(!info.lpszProtocolName, "lpszProtocolName = %s\n", info.lpszProtocolName);
6942 ok(info.dwKeySize >= 128 && info.dwKeySize <= 256, "dwKeySize = %lu\n", info.dwKeySize);
6943
6944 if (is_lang_english())
6946 else
6947 skip("Skipping tests that are English-only\n");
6949}
6950
6951#define test_security_info(a,b,c) _test_security_info(__LINE__,a,b,c)
6952static void _test_security_info(unsigned line, const char *urlc, DWORD error, DWORD ex_flags)
6953{
6956 DWORD flags;
6957 BOOL res;
6958
6959 if(!pInternetGetSecurityInfoByURLA) {
6960 win_skip("pInternetGetSecurityInfoByURLA not available\n");
6961 return;
6962 }
6963
6964 strcpy(url, urlc);
6965 chain = (void*)0xdeadbeef;
6966 flags = 0xdeadbeef;
6967 res = pInternetGetSecurityInfoByURLA(url, &chain, &flags);
6968 if(error == ERROR_SUCCESS) {
6969 ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %lu\n", GetLastError());
6970 ok_(__FILE__,line)(chain != NULL, "chain = NULL\n");
6971 ok_(__FILE__,line)(flags == ex_flags, "flags = %lx\n", flags);
6973
6974 SetLastError(0xdeadbeef);
6975 res = pInternetGetSecurityInfoByURLA(url, NULL, NULL);
6976 ok_(__FILE__,line)(!res && GetLastError() == ERROR_INVALID_PARAMETER,
6977 "InternetGetSecurityInfoByURLA returned: %x(%lu)\n", res, GetLastError());
6978
6979 res = pInternetGetSecurityInfoByURLA(url, &chain, NULL);
6980 ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %lu\n", GetLastError());
6982
6983 res = pInternetGetSecurityInfoByURLA(url, NULL, &flags);
6984 ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %lu\n", GetLastError());
6985 }else {
6986 ok_(__FILE__,line)(!res && GetLastError() == error,
6987 "InternetGetSecurityInfoByURLA returned: %x(%lu), expected %lu\n", res, GetLastError(), error);
6988 }
6989}
6990
6991#define test_secflags_option(a,b,c) _test_secflags_option(__LINE__,a,b,c)
6992static void _test_secflags_option(unsigned line, HINTERNET req, DWORD ex_flags, DWORD opt_flags)
6993{
6994 DWORD flags, size;
6995 BOOL res;
6996
6997 flags = 0xdeadbeef;
6998 size = sizeof(flags);
7000 ok_(__FILE__,line)(res, "InternetQueryOptionW(INTERNET_OPTION_SECURITY_FLAGS) failed: %lu\n", GetLastError());
7001 ok_(__FILE__,line)((flags & ~opt_flags) == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS flags = %lx, expected %lx\n",
7002 flags, ex_flags);
7003
7004 /* Option 98 is undocumented and seems to be the same as INTERNET_OPTION_SECURITY_FLAGS */
7005 flags = 0xdeadbeef;
7006 size = sizeof(flags);
7007 res = InternetQueryOptionW(req, 98, &flags, &size);
7008 ok_(__FILE__,line)(res, "InternetQueryOptionW(98) failed: %lu\n", GetLastError());
7009 ok_(__FILE__,line)((flags & ~opt_flags) == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS(98) flags = %lx, expected %lx\n",
7010 flags, ex_flags);
7011}
7012
7013#define set_secflags(a,b,c) _set_secflags(__LINE__,a,b,c)
7014static void _set_secflags(unsigned line, HINTERNET req, BOOL use_undoc, DWORD flags)
7015{
7016 BOOL res;
7017
7018 res = InternetSetOptionW(req, use_undoc ? 99 : INTERNET_OPTION_SECURITY_FLAGS, &flags, sizeof(flags));
7019 ok_(__FILE__,line)(res, "InternetSetOption(INTERNET_OPTION_SECURITY_FLAGS) failed: %lu\n", GetLastError());
7020}
7021
7022static void test_security_flags(void)
7023{
7025 HINTERNET ses, conn, req;
7026 DWORD size, flags;
7027 char buf[512];
7028 BOOL res;
7029
7030 if (!https_support)
7031 {
7032 win_skip("Can't make https connections, skipping security flags test\n");
7033 return;
7034 }
7035
7036 trace("Testing security flags...\n");
7037 reset_events();
7038
7040 ok(ses != NULL, "InternetOpen failed\n");
7041
7042 pInternetSetStatusCallbackA(ses, &callback);
7043
7045 conn = InternetConnectA(ses, "test.winehq.com", INTERNET_DEFAULT_HTTPS_PORT,
7047 ok(conn != NULL, "InternetConnect failed with error %lu\n", GetLastError());
7049
7051 req = HttpOpenRequestA(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
7053 0xdeadbeef);
7054 ok(req != NULL, "HttpOpenRequest failed\n");
7056
7057 flags = 0xdeadbeef;
7058 size = sizeof(flags);
7059 res = InternetQueryOptionW(req, 98, &flags, &size);
7061 win_skip("Incomplete security flags support, skipping\n");
7062
7063 close_async_handle(ses, 2);
7064 return;
7065 }
7066
7067 test_secflags_option(req, 0, 0);
7068 test_security_info("https://test.winehq.com/data/some_file.html?q", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
7069
7072
7075
7078
7080 res = InternetSetOptionW(req, 99, &flags, sizeof(flags));
7081 ok(!res && GetLastError() == ERROR_INTERNET_OPTION_NOT_SETTABLE, "InternetSetOption(99) failed: %lu\n", GetLastError());
7082
7087 SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
7098
7099 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
7100 ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %lu\n", GetLastError());
7101
7103 ok(req_error == ERROR_SUCCESS, "req_error = %ld\n", req_error);
7104
7118
7119 test_request_flags(req, 0);
7122
7123 res = InternetReadFile(req, buf, sizeof(buf), &size);
7124 ok(res, "InternetReadFile failed: %lu\n", GetLastError());
7125 ok(size, "size = 0\n");
7126
7127 /* Collect all existing persistent connections */
7129 ok(res, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %lu\n", GetLastError());
7130
7132 req = HttpOpenRequestA(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
7134 0xdeadbeef);
7135 ok(req != NULL, "HttpOpenRequest failed\n");
7137
7140 ok(res, "InternetQueryOption(INTERNET_OPTION_ERROR_MASK failed: %lu\n", GetLastError());
7141
7144 SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
7153
7154 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
7155 ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %lu\n", GetLastError());
7156
7158 todo_wine
7160 "req_error = %ld\n", req_error);
7161
7162 size = 0;
7164 ok(res || GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %ld\n", GetLastError());
7165 ok(size == sizeof(INTERNET_CERTIFICATE_INFOA), "size = %lu\n", size);
7167 cert->lpszSubjectInfo = NULL;
7168 cert->lpszIssuerInfo = NULL;
7169 cert->lpszSignatureAlgName = (char *)0xdeadbeef;
7170 cert->lpszEncryptionAlgName = (char *)0xdeadbeef;
7171 cert->lpszProtocolName = (char *)0xdeadbeef;
7172 cert->dwKeySize = 0xdeadbeef;
7174 ok(res, "InternetQueryOption failed: %lu\n", GetLastError());
7175 if (res)
7176 {
7177 ok(cert->lpszSubjectInfo && strlen(cert->lpszSubjectInfo) > 1, "expected a non-empty subject name\n");
7178 ok(cert->lpszIssuerInfo && strlen(cert->lpszIssuerInfo) > 1, "expected a non-empty issuer name\n");
7179 ok(!cert->lpszSignatureAlgName, "unexpected signature algorithm name\n");
7180 ok(!cert->lpszEncryptionAlgName, "unexpected encryption algorithm name\n");
7181 ok(!cert->lpszProtocolName, "unexpected protocol name\n");
7182 ok(cert->dwKeySize != 0xdeadbeef, "unexpected key size\n");
7183
7184 LocalFree(cert->lpszSubjectInfo);
7185 LocalFree(cert->lpszIssuerInfo);
7186 }
7188
7189 SetLastError(0xdeadbeef);
7191 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER, "InternetQueryOption failed: %ld\n", GetLastError());
7192
7193 size = 0;
7194 SetLastError(0xdeadbeef);
7196 ok(!res && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %ld\n", GetLastError());
7197 ok(size == 1, "unexpected size: %lu\n", size);
7198
7199 size = 42;
7200 SetLastError(0xdeadbeef);
7201 memset(buf, 0x55, sizeof(buf));
7203 ok(!res && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %ld\n", GetLastError());
7204 ok(size == 1, "unexpected size: %lu\n", size);
7205 ok(buf[0] == 0x55, "unexpected byte: %02x\n", buf[0]);
7206
7207 size = sizeof(buf);
7208 SetLastError(0xdeadbeef);
7210 ok(res && GetLastError() == ERROR_SUCCESS, "InternetQueryOption failed: %ld\n", GetLastError());
7211 ok(size < sizeof(buf), "unexpected size: %lu\n", size);
7212
7221
7223 skip("Unexpected cert errors %lu, skipping security flags tests\n", req_error);
7224
7225 close_async_handle(ses, 3);
7226 return;
7227 }
7228
7229 size = sizeof(buf);
7231 ok(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfoA(HTTP_QUERY_CONTENT_ENCODING) failed: %lu\n", GetLastError());
7232
7233 test_request_flags(req, 8);
7234 /* IE11 finds both rev failure and invalid CA. Previous versions required rev failure
7235 to be ignored before invalid CA was reported. */
7237
7240
7248
7249 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
7250 ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %lu\n", GetLastError());
7251
7254
7262
7265 test_security_info("https://test.winehq.com/data/some_file.html?q", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
7266
7270 test_http_version(req);
7271
7274 SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
7285
7286 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
7287 ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %lu\n", GetLastError());
7288
7290 ok(req_error == ERROR_SUCCESS, "req_error = %ld\n", req_error);
7291
7303
7304 test_request_flags(req, 0);
7307
7309 test_security_info("https://test.winehq.com/data/some_file.html?q", 0,
7311
7312 res = InternetReadFile(req, buf, sizeof(buf), &size);
7313 ok(res, "InternetReadFile failed: %lu\n", GetLastError());
7314 ok(size, "size = 0\n");
7315
7316 close_async_handle(ses, 3);
7317
7318 /* Collect all existing persistent connections */
7320 ok(res, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %lu\n", GetLastError());
7321
7322 /* Make another request, without setting security flags */
7323
7325 ok(ses != NULL, "InternetOpen failed\n");
7326
7327 pInternetSetStatusCallbackA(ses, &callback);
7328
7330 conn = InternetConnectA(ses, "test.winehq.com", INTERNET_DEFAULT_HTTPS_PORT,
7332 ok(conn != NULL, "InternetConnect failed with error %lu\n", GetLastError());
7334
7336 req = HttpOpenRequestA(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
7338 0xdeadbeef);
7339 ok(req != NULL, "HttpOpenRequest failed\n");
7341
7344 test_http_version(req);
7345
7348 SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
7358
7359 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
7360 ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %lu\n", GetLastError());
7361
7363 ok(req_error == ERROR_SUCCESS, "req_error = %ld\n", req_error);
7364
7375
7376 test_request_flags(req, 0);
7379
7380 res = InternetReadFile(req, buf, sizeof(buf), &size);
7381 ok(res, "InternetReadFile failed: %lu\n", GetLastError());
7382 ok(size, "size = 0\n");
7383
7384 close_async_handle(ses, 2);
7385
7386 test_security_info("http://test.winehq.com/data/some_file.html?q", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
7387 test_security_info("file:///c:/dir/file.txt", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
7388 test_security_info("xxx:///c:/dir/file.txt", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
7389}
7390
7391static void test_secure_connection(void)
7392{
7393 static const WCHAR gizmo5[] = {'G','i','z','m','o','5',0};
7394 static const WCHAR testsite[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
7395 static const WCHAR get[] = {'G','E','T',0};
7396 static const WCHAR testpage[] = {'/','t','e','s','t','s','/','h','e','l','l','o','.','h','t','m','l',0};
7397 HINTERNET ses, con, req;
7398 DWORD size, size2, flags, err;
7399 INTERNET_CERTIFICATE_INFOA *certificate_structA = NULL;
7400 INTERNET_CERTIFICATE_INFOW *certificate_structW = NULL;
7401 char certstr1[512], certstr2[512];
7402 BOOL ret;
7404
7406 ok(ses != NULL, "InternetOpen failed\n");
7407
7408 con = InternetConnectA(ses, "test.winehq.org",
7410 INTERNET_SERVICE_HTTP, 0, 0);
7411 ok(con != NULL, "InternetConnect failed\n");
7412
7413 req = HttpOpenRequestA(con, "GET", "/tests/hello.html", NULL, NULL, NULL,
7415 ok(req != NULL, "HttpOpenRequest failed\n");
7416
7417 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
7418 err = GetLastError();
7420 broken(err == ERROR_INTERNET_SECURITY_CHANNEL_ERROR), "HttpSendRequest failed: %lu\n", err);
7421 if (!ret)
7422 {
7423 win_skip("Cannot connect to https.\n");
7425 goto done;
7426 }
7427
7428 size = sizeof(flags);
7430 ok(ret, "InternetQueryOption failed: %ld\n", GetLastError());
7431 ok(flags & SECURITY_FLAG_SECURE, "expected secure flag to be set\n");
7432
7434
7435 size = sizeof(chain);
7436 SetLastError(0xdeadbeef);
7439 "InternetQueryOption failed: %lu\n", GetLastError());
7441
7442 /* Querying the same option through InternetQueryOptionW still results in
7443 * ANSI strings being returned.
7444 */
7445 size = 0;
7447 NULL, &size);
7448 ok(ret || GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %ld\n", GetLastError());
7449 ok(size == sizeof(INTERNET_CERTIFICATE_INFOW), "size = %ld\n", size);
7450 certificate_structW = HeapAlloc(GetProcessHeap(), 0, size);
7452 certificate_structW, &size);
7453 certificate_structA = (INTERNET_CERTIFICATE_INFOA *)certificate_structW;
7454 ok(ret, "InternetQueryOption failed: %ld\n", GetLastError());
7455 if (ret)
7456 {
7457 ok(certificate_structA->lpszSubjectInfo &&
7458 strlen(certificate_structA->lpszSubjectInfo) > 1,
7459 "expected a non-empty subject name\n");
7460 ok(certificate_structA->lpszIssuerInfo &&
7461 strlen(certificate_structA->lpszIssuerInfo) > 1,
7462 "expected a non-empty issuer name\n");
7463 ok(!certificate_structA->lpszSignatureAlgName,
7464 "unexpected signature algorithm name\n");
7465 ok(!certificate_structA->lpszEncryptionAlgName,
7466 "unexpected encryption algorithm name\n");
7467 ok(!certificate_structA->lpszProtocolName,
7468 "unexpected protocol name\n");
7469 ok(certificate_structA->dwKeySize, "expected a non-zero key size\n");
7470 release_cert_info(certificate_structA);
7471 }
7472 HeapFree(GetProcessHeap(), 0, certificate_structW);
7473
7474 SetLastError(0xdeadbeef);
7475 size = sizeof(certstr1);
7477 ok(ret && GetLastError() == ERROR_SUCCESS, "InternetQueryOption failed: %ld\n", GetLastError());
7478
7479 SetLastError(0xdeadbeef);
7480 size2 = sizeof(certstr2);
7482 ok(ret && GetLastError() == ERROR_SUCCESS, "InternetQueryOption failed: %ld\n", GetLastError());
7483
7484 ok(size == size2, "expected same size\n");
7485 ok(!strcmp(certstr1, certstr2), "expected same string\n");
7486
7490
7491 /* Repeating the tests with the W functions has the same result: */
7493 ok(ses != NULL, "InternetOpen failed\n");
7494
7495 con = InternetConnectW(ses, testsite,
7497 INTERNET_SERVICE_HTTP, 0, 0);
7498 ok(con != NULL, "InternetConnect failed\n");
7499
7500 req = HttpOpenRequestW(con, get, testpage, NULL, NULL, NULL,
7502 ok(req != NULL, "HttpOpenRequest failed\n");
7503
7504 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
7505 ok(ret, "HttpSendRequest failed: %ld\n", GetLastError());
7506
7507 size = sizeof(flags);
7509 ok(ret, "InternetQueryOption failed: %ld\n", GetLastError());
7510 ok(flags & SECURITY_FLAG_SECURE, "expected secure flag to be set, got %lx\n", flags);
7511
7513 NULL, &size);
7514 ok(ret || GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %ld\n", GetLastError());
7515 ok(size == sizeof(INTERNET_CERTIFICATE_INFOA), "size = %ld\n", size);
7516 certificate_structA = HeapAlloc(GetProcessHeap(), 0, size);
7518 certificate_structA, &size);
7519 ok(ret, "InternetQueryOption failed: %ld\n", GetLastError());
7520 if (ret)
7521 {
7522 ok(certificate_structA->lpszSubjectInfo &&
7523 strlen(certificate_structA->lpszSubjectInfo) > 1,
7524 "expected a non-empty subject name\n");
7525 ok(certificate_structA->lpszIssuerInfo &&
7526 strlen(certificate_structA->lpszIssuerInfo) > 1,
7527 "expected a non-empty issuer name\n");
7528 ok(!certificate_structA->lpszSignatureAlgName,
7529 "unexpected signature algorithm name\n");
7530 ok(!certificate_structA->lpszEncryptionAlgName,
7531 "unexpected encryption algorithm name\n");
7532 ok(!certificate_structA->lpszProtocolName,
7533 "unexpected protocol name\n");
7534 ok(certificate_structA->dwKeySize, "expected a non-zero key size\n");
7535 release_cert_info(certificate_structA);
7536 }
7537 HeapFree(GetProcessHeap(), 0, certificate_structA);
7538
7539 /* Again, querying the same option through InternetQueryOptionW still
7540 * results in ASCII strings being returned.
7541 */
7542 size = 0;
7544 NULL, &size);
7545 ok(ret || GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %ld\n", GetLastError());
7546 ok(size == sizeof(INTERNET_CERTIFICATE_INFOW), "size = %ld\n", size);
7547 certificate_structW = HeapAlloc(GetProcessHeap(), 0, size);
7549 certificate_structW, &size);
7550 certificate_structA = (INTERNET_CERTIFICATE_INFOA *)certificate_structW;
7551 ok(ret, "InternetQueryOption failed: %ld\n", GetLastError());
7552 if (ret)
7553 {
7554 ok(certificate_structA->lpszSubjectInfo &&
7555 strlen(certificate_structA->lpszSubjectInfo) > 1,
7556 "expected a non-empty subject name\n");
7557 ok(certificate_structA->lpszIssuerInfo &&
7558 strlen(certificate_structA->lpszIssuerInfo) > 1,
7559 "expected a non-empty issuer name\n");
7560 ok(!certificate_structA->lpszSignatureAlgName,
7561 "unexpected signature algorithm name\n");
7562 ok(!certificate_structA->lpszEncryptionAlgName,
7563 "unexpected encryption algorithm name\n");
7564 ok(!certificate_structA->lpszProtocolName,
7565 "unexpected protocol name\n");
7566 ok(certificate_structA->dwKeySize, "expected a non-zero key size\n");
7567 release_cert_info(certificate_structA);
7568 }
7569 HeapFree(GetProcessHeap(), 0, certificate_structW);
7570
7571done:
7575}
7576
7577static void test_user_agent_header(void)
7578{
7579 HINTERNET ses, con, req;
7580 DWORD size, err;
7581 char buffer[64];
7582 BOOL ret;
7583
7585 ok(ses != NULL, "InternetOpen failed\n");
7586
7587 con = InternetConnectA(ses, "test.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
7588 ok(con != NULL, "InternetConnect failed\n");
7589
7590 /* If the user agent string provided by the session handle is empty and none
7591 * is explicitly set for the request handle, then there should be no user
7592 * agent header present in the request when it is sent. */
7593 req = HttpOpenRequestA(con, "GET", "/tests/hello.html", "HTTP/1.0", NULL, NULL, 0, 0);
7594 ok(req != NULL, "HttpOpenRequest failed\n");
7595
7596 size = sizeof(buffer);
7597 SetLastError(0xdeadbeef);
7599 err = GetLastError();
7600 ok(!ret, "HttpQueryInfo succeeded\n");
7601 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %lu\n", err);
7602
7603 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
7604 ok(ret, "HttpSendRequest failed\n");
7605
7606 size = sizeof(buffer);
7607 SetLastError(0xdeadbeef);
7609 err = GetLastError();
7610 ok(!ret, "HttpQueryInfo succeeded\n");
7611 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %lu\n", err);
7612
7614
7615 /* Set the user agent string in the session handle to something non-empty. */
7616 strcpy(buffer, "Gizmo5");
7617 ret = InternetSetOptionA(ses, INTERNET_OPTION_USER_AGENT, buffer, sizeof("Gizmo5") - 1);
7618 ok(ret, "InternetSetOptionA failed to set user agent for session\n");
7619
7620 /* The connection handle still retains the previous user agent string, so
7621 * the change to the user agent string in the session handle will not be
7622 * visible in requests created from the existing connection. */
7623 req = HttpOpenRequestA(con, "GET", "/tests/hello.html", "HTTP/1.0", NULL, NULL, 0, 0);
7624 ok(req != NULL, "HttpOpenRequest failed\n");
7625
7626 size = sizeof(buffer);
7627 SetLastError(0xdeadbeef);
7629 err = GetLastError();
7630 ok(!ret, "HttpQueryInfo succeeded\n");
7631 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %lu\n", err);
7632
7633 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
7634 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
7635
7636 size = sizeof(buffer);
7637 SetLastError(0xdeadbeef);
7639 err = GetLastError();
7640 todo_wine
7641 ok(!ret, "HttpQueryInfo succeeded\n");
7642 todo_wine
7643 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %lu\n", err);
7644
7647
7648 /* Recreate the connection so the updated user agent string from the session
7649 * handle is picked up by new requests for subsequent tests. */
7650 con = InternetConnectA(ses, "test.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
7651 ok(con != NULL, "InternetConnect failed\n");
7652
7653 /* If a user agent string is not explicitly set for the request handle, then
7654 * the user agent string from the session handle will be used for the header
7655 * when the request is sent. */
7656 req = HttpOpenRequestA(con, "GET", "/tests/hello.html", "HTTP/1.0", NULL, NULL, 0, 0);
7657 ok(req != NULL, "HttpOpenRequest failed\n");
7658
7659 size = sizeof(buffer);
7660 SetLastError(0xdeadbeef);
7662 err = GetLastError();
7663 ok(!ret, "HttpQueryInfo succeeded\n");
7664 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %lu\n", err);
7665
7666 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
7667 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
7668
7669
7670 buffer[0] = 0;
7671 size = sizeof(buffer);
7673 ok(ret, "HttpQueryInfo failed\n");
7674 ok(!strcmp(buffer, "Gizmo5"), "got %s\n", buffer);
7675 ok(size == strlen("Gizmo5"), "got %lu\n", size);
7676
7678
7679 /* Adding a User-Agent header with an empty value is not permitted. */
7680 req = HttpOpenRequestA(con, "GET", "/tests/hello.html", "HTTP/1.0", NULL, NULL, 0, 0);
7681 ok(req != NULL, "HttpOpenRequest failed\n");
7682
7683 SetLastError(0xdeadbeef);
7684 ret = HttpAddRequestHeadersA(req, "User-Agent: \r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
7685 err = GetLastError();
7686 todo_wine
7687 ok(!ret, "HttpAddRequestHeaders succeeded\n");
7688 todo_wine
7689 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %lu\n", err);
7690
7692
7693 /* A User-Agent header explicitly added to a request overrides the user
7694 * agent string from the session handle. */
7695 req = HttpOpenRequestA(con, "GET", "/tests/hello.html", "HTTP/1.0", NULL, NULL, 0, 0);
7696 ok(req != NULL, "HttpOpenRequest failed\n");
7697
7698 ret = HttpAddRequestHeadersA(req, "User-Agent: Gizmo Project\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
7699 ok(ret, "HttpAddRequestHeaders failed\n");
7700
7701 buffer[0] = 0;
7702 size = sizeof(buffer);
7704 ok(ret, "HttpQueryInfo failed\n");
7705 ok(!strcmp(buffer, "Gizmo Project"), "got %s\n", buffer);
7706 ok(size == strlen("Gizmo Project"), "got %lu\n", size);
7707
7708 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
7709 ok(ret, "HttpSendRequest failed: %lu\n", GetLastError());
7710
7711 buffer[0] = 0;
7712 size = sizeof(buffer);
7714 ok(ret, "HttpQueryInfo failed\n");
7715 ok(!strcmp(buffer, "Gizmo Project"), "got %s\n", buffer);
7716 ok(size == strlen("Gizmo Project"), "got %lu\n", size);
7717
7719
7720 /* Explicitly adding both Accept and User-Agent headers at once is permitted. */
7721 req = HttpOpenRequestA(con, "GET", "/", "HTTP/1.0", NULL, NULL, 0, 0);
7722 ok(req != NULL, "HttpOpenRequest failed\n");
7723
7724 size = sizeof(buffer);
7725 SetLastError(0xdeadbeef);
7727 err = GetLastError();
7728 ok(!ret, "HttpQueryInfo succeeded\n");
7729 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %lu\n", err);
7730
7731 ret = HttpAddRequestHeadersA(req, "Accept: audio/*, image/*, text/*\r\nUser-Agent: Gizmo Project\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
7732 ok(ret, "HttpAddRequestHeaders failed\n");
7733
7734 buffer[0] = 0;
7735 size = sizeof(buffer);
7737 ok(ret, "HttpQueryInfo failed: %lu\n", GetLastError());
7738 ok(!strcmp(buffer, "audio/*, image/*, text/*"), "got '%s' expected 'audio/*, image/*, text/*'\n", buffer);
7739
7740 buffer[0] = 0;
7741 size = sizeof(buffer);
7743 ok(ret, "HttpQueryInfo failed: %lu\n", GetLastError());
7744 ok(!strcmp(buffer, "Gizmo Project"), "got %s\n", buffer);
7745 ok(size == strlen("Gizmo Project"), "got %lu\n", size);
7746
7750}
7751
7753{
7754 HINTERNET ses, con, req;
7755 static const char *types[] = { (const char *)6240, "*/*", "%p", "", (const char *)0xffffffff, "*/*", NULL };
7756 DWORD size, error;
7757 char buffer[32];
7758 BOOL ret;
7759
7760 ses = InternetOpenA("MERONG(0.9/;p)", INTERNET_OPEN_TYPE_DIRECT, "", "", 0);
7761 con = InternetConnectA(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
7762 req = HttpOpenRequestA(con, "POST", "/post/post_action.php", "HTTP/1.0", "", types, INTERNET_FLAG_FORMS_SUBMIT, 0);
7763
7764 ok(req != NULL, "HttpOpenRequest failed: %lu\n", GetLastError());
7765
7766 buffer[0] = 0;
7767 size = sizeof(buffer);
7768 SetLastError(0xdeadbeef);
7770 error = GetLastError();
7771 ok(!ret || broken(ret), "HttpQueryInfo succeeded\n");
7772 if (!ret) ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %lu\n", error);
7773 ok(broken(!strcmp(buffer, ", */*, %p, , , */*")) /* IE6 */ ||
7774 broken(!strcmp(buffer, "*/*, %p, */*")) /* IE7/8 */ ||
7775 !strcmp(buffer, ""), "got '%s' expected ''\n", buffer);
7776
7780}
7781
7783{
7786};
7787
7789{
7791 struct context *ctx = (struct context *)context;
7792
7793 if(winetest_debug > 1)
7794 trace("%p 0x%08Ix %lu %p 0x%08lx\n", handle, context, status, info, size);
7795
7796 switch(status) {
7798 trace("request handle: 0x%08Ix\n", result->dwResult);
7799 ctx->req = (HINTERNET)result->dwResult;
7800 SetEvent(ctx->event);
7801 break;
7804
7806 ok(type != INTERNET_HANDLE_TYPE_CONNECT_HTTP, "unexpected callback\n");
7807 SetEvent(ctx->event);
7808 break;
7809 }
7813 char *str = info;
7814 ok(str[0] && str[1], "Got string: %s\n", str);
7815 ok(size == strlen(str)+1, "unexpected size %lu\n", size);
7816 }
7817 }
7818}
7819
7820static void test_open_url_async(void)
7821{
7822 BOOL ret;
7823 HINTERNET ses, req;
7824 DWORD size, error;
7825 struct context ctx;
7826 ULONG type;
7827
7828 /* Collect all existing persistent connections */
7830 ok(ret, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %lu\n", GetLastError());
7831
7832 /*
7833 * Some versions of IE6 fail those tests. They pass some notification data as UNICODE string, while
7834 * other versions never do. They also hang of following tests. We disable it for everything older
7835 * than IE7.
7836 */
7837 if(!is_ie7plus)
7838 return;
7839
7840 ctx.req = NULL;
7841 ctx.event = CreateEventA(NULL, TRUE, FALSE, "Z:_home_hans_jaman-installer.exe_ev1");
7842
7843 ses = InternetOpenA("AdvancedInstaller", 0, NULL, NULL, INTERNET_FLAG_ASYNC);
7844 ok(ses != NULL, "InternetOpen failed\n");
7845
7846 SetLastError(0xdeadbeef);
7848 error = GetLastError();
7849 ok(!ret, "InternetSetOptionA succeeded\n");
7850 ok(error == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "got %lu expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE\n", error);
7851
7853 error = GetLastError();
7854 ok(!ret, "InternetSetOptionA failed\n");
7855 ok(error == ERROR_INTERNET_OPTION_NOT_SETTABLE, "got %lu expected ERROR_INTERNET_OPTION_NOT_SETTABLE\n", error);
7856
7857 pInternetSetStatusCallbackW(ses, cb);
7858 ResetEvent(ctx.event);
7859
7860 req = InternetOpenUrlA(ses, "http://test.winehq.org", NULL, 0, 0, (DWORD_PTR)&ctx);
7861 ok(!req && GetLastError() == ERROR_IO_PENDING, "InternetOpenUrl failed\n");
7862
7864
7865 type = 0;
7866 size = sizeof(type);
7868 ok(ret, "InternetQueryOption failed: %lu\n", GetLastError());
7870 "expected INTERNET_HANDLE_TYPE_HTTP_REQUEST, got %lu\n", type);
7871
7872 size = 0;
7874 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "HttpQueryInfo failed\n");
7875 ok(size > 0, "expected size > 0\n");
7876
7877 ResetEvent(ctx.event);
7880
7882 CloseHandle(ctx.event);
7883}
7884
7886{
7894
7895struct notification
7896{
7897 enum api function; /* api responsible for notification */
7898 unsigned int status; /* status received */
7899 BOOL async; /* delivered from another thread? */
7902};
7903
7904struct info
7905{
7906 enum api function;
7907 const struct notification *test;
7908 unsigned int count;
7909 unsigned int index;
7910 HANDLE wait;
7912 unsigned int line;
7915};
7916
7918
7920{
7921 BOOL status_ok, function_ok;
7922 struct info *info = (struct info *)context;
7923 unsigned int i;
7924
7926
7927 if(info->is_aborted) {
7929 return;
7930 }
7931
7933 {
7934 DWORD size = sizeof(struct info *);
7938
7939 ok(buflen == sizeof(*ar), "unexpected buflen = %ld\n", buflen);
7941 ok(ar->dwResult == 1, "ar->dwResult = %Id, expected 1\n", ar->dwResult);
7942 }else {
7943 ok(!ar->dwResult, "ar->dwResult = %Id, expected 1\n", ar->dwResult);
7944 ok(ar->dwError == info->expect_result, "ar->dwError = %ld, expected %ld\n", ar->dwError, info->expect_result);
7945 }
7946 }
7947
7948 i = info->index;
7949 if (i >= info->count)
7950 {
7952 return;
7953 }
7954
7955 while (info->test[i].status != status &&
7956 (info->test[i].optional || info->test[i].todo) &&
7957 i < info->count - 1 &&
7958 info->test[i].function == info->test[i + 1].function)
7959 {
7960 i++;
7961 }
7962
7963 status_ok = (info->test[i].status == status);
7964 function_ok = (info->test[i].function == info->function);
7965
7966 if (!info->test[i].todo)
7967 {
7968 ok( status_ok, "%u: expected status %u got %lu\n", info->line, info->test[i].status, status );
7969 ok( function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function );
7970
7971 if (info->test[i].async)
7972 ok(info->thread != GetCurrentThreadId(), "%u: expected thread %lu got %lu\n",
7974 }
7975 else
7976 {
7977 todo_wine ok( status_ok, "%u: expected status %u got %lu\n", info->line, info->test[i].status, status );
7978 if (status_ok)
7979 todo_wine ok( function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function );
7980 }
7981 if (i == info->count - 1 || info->test[i].function != info->test[i + 1].function) SetEvent( info->wait );
7982 info->index = i+1;
7983
7985}
7986
7987static void setup_test( struct info *info, enum api function, unsigned int line, DWORD expect_result )
7988{
7990 info->line = line;
7992}
7993
7995{
7996 const struct notification *test;
7997 const unsigned int count;
7998 const char *method;
7999 const char *host;
8000 const char *path;
8001 const char *data;
8003};
8004
8006{
8027};
8028
8030{
8049};
8050
8052{
8064};
8065
8067{
8086};
8087
8088static const struct notification_data notification_data[] = {
8089 {
8092 "GET",
8093 "test.winehq.org",
8094 "tests/data.php"
8095 },
8096 {
8099 "POST",
8100 "test.winehq.org",
8101 "tests/post.php",
8102 "Public ID=codeweavers"
8103 },
8104 {
8107 "POST",
8108 "test.winehq.org",
8109 "tests/post.php"
8110 },
8111 {
8114 "GET",
8115 "brokenhost",
8116 "index.html",
8117 NULL,
8118 TRUE
8119 }
8120};
8121
8123{
8124 BOOL ret;
8125 HINTERNET ses, req, con;
8126 struct info info;
8127 DWORD size, written, error;
8129 static const char *accept[2] = {"*/*", NULL};
8130 char buffer[32];
8131
8132 trace("Async HttpSendRequestEx test (%s %s)\n", nd->method, nd->host);
8133
8134 /* Collect all existing persistent connections */
8136 ok(ret, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %lu\n", GetLastError());
8137
8139
8140 info.test = nd->test;
8141 info.count = nd->count;
8142 info.index = 0;
8146
8147 ses = InternetOpenA( "winetest", 0, NULL, NULL, INTERNET_FLAG_ASYNC );
8148 ok( ses != NULL, "InternetOpen failed\n" );
8149
8150 pInternetSetStatusCallbackA( ses, check_notification );
8151
8153 con = InternetConnectA( ses, nd->host, 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD_PTR)&info );
8154 ok( con != NULL, "InternetConnect failed %lu\n", GetLastError() );
8155
8156 WaitForSingleObject( info.wait, 10000 );
8157
8159 req = HttpOpenRequestA( con, nd->method, nd->path, NULL, NULL, accept, 0, (DWORD_PTR)&info );
8160 ok( req != NULL, "HttpOpenRequest failed %lu\n", GetLastError() );
8161
8162 WaitForSingleObject( info.wait, 10000 );
8163
8164 if(nd->data) {
8165 memset( &b, 0, sizeof(INTERNET_BUFFERSA) );
8166 b.dwStructSize = sizeof(INTERNET_BUFFERSA);
8167 b.lpcszHeader = "Content-Type: application/x-www-form-urlencoded";
8168 b.dwHeadersLength = strlen( b.lpcszHeader );
8169 b.dwBufferTotal = nd->data ? strlen( nd->data ) : 0;
8170 }
8171
8174 ret = HttpSendRequestExA( req, nd->data ? &b : NULL, NULL, 0x28, 0 );
8175 ok( !ret && GetLastError() == ERROR_IO_PENDING, "HttpSendRequestExA failed %d %lu\n", ret, GetLastError() );
8176
8177 error = WaitForSingleObject( info.wait, 10000 );
8178 if(error != WAIT_OBJECT_0) {
8179 skip("WaitForSingleObject returned %ld, assuming DNS problem\n", error);
8181 goto abort;
8182 }
8183
8184 size = sizeof(buffer);
8185 SetLastError( 0xdeadbeef );
8187 error = GetLastError();
8188 ok( !ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
8189 if(nd->expect_conn_failure) {
8190 ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND got %lu\n", error );
8191 }else {
8192 todo_wine
8194 "expected ERROR_INTERNET_INCORRECT_HANDLE_STATE got %lu\n", error );
8195 }
8196
8197 if (nd->data)
8198 {
8199 written = 0;
8200 size = strlen( nd->data );
8202 ret = InternetWriteFile( req, nd->data, size, &written );
8203 ok( ret, "InternetWriteFile failed %lu\n", GetLastError() );
8204 ok( written == size, "expected %lu got %lu\n", written, size );
8205
8206 WaitForSingleObject( info.wait, 10000 );
8207
8208 SetLastError( 0xdeadbeef );
8209 ret = HttpEndRequestA( req, (void *)nd->data, 0x28, 0 );
8210 error = GetLastError();
8211 ok( !ret, "HttpEndRequestA succeeded\n" );
8212 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", error );
8213 }
8214
8215 SetLastError( 0xdeadbeef );
8216 setup_test( &info, http_end_request, __LINE__,
8218 ret = HttpEndRequestA( req, NULL, 0x28, 0 );
8219 error = GetLastError();
8220 ok( !ret, "HttpEndRequestA succeeded\n" );
8221 ok( error == ERROR_IO_PENDING, "expected ERROR_IO_PENDING got %lu\n", error );
8222
8223 WaitForSingleObject( info.wait, 10000 );
8224
8226 abort:
8227 InternetCloseHandle( req );
8228 InternetCloseHandle( con );
8229 InternetCloseHandle( ses );
8230
8231 WaitForSingleObject( info.wait, 10000 );
8232 Sleep(100);
8235}
8236
8239
8240static void WINAPI closetest_callback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus,
8241 LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
8242{
8243 DWORD len, type;
8244 BOOL res;
8245
8246 if(winetest_debug > 1)
8247 trace("closetest_callback %p: %ld\n", hInternet, dwInternetStatus);
8248
8249 ok(hInternet == closetest_session || hInternet == closetest_conn || hInternet == closetest_req,
8250 "Unexpected hInternet %p\n", hInternet);
8251 if(!closetest_closed)
8252 return;
8253
8254 len = sizeof(type);
8257 "InternetQueryOptionA(%p INTERNET_OPTION_HANDLE_TYPE) failed: %x %lu, expected TRUE ERROR_INVALID_HANDLE\n",
8259}
8260
8262{
8263 DWORD len, flags;
8264 BOOL res;
8265
8267 ok(closetest_session != NULL,"InternetOpen failed with error %lu\n", GetLastError());
8268
8269 pInternetSetStatusCallbackA(closetest_session, closetest_callback);
8270
8272 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
8273 ok(closetest_conn != NULL,"InternetConnect failed with error %lu\n", GetLastError());
8274
8275 closetest_req = HttpOpenRequestA(closetest_conn, "GET", "winegecko.php", NULL, NULL, NULL,
8277
8280 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
8281
8283
8285 ok(res, "InternetCloseHandle failed: %lu\n", GetLastError());
8287 trace("Closed session handle\n");
8288
8290 ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "InternetCloseConnection(conn) failed: %x %lu\n",
8291 res, GetLastError());
8292
8294 ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "InternetCloseConnection(req) failed: %x %lu\n",
8295 res, GetLastError());
8296
8297 len = sizeof(flags);
8300 "InternetQueryOptionA(%p INTERNET_OPTION_REQUEST_FLAGS) failed: %x %lu, expected TRUE ERROR_INVALID_HANDLE\n",
8302}
8303
8305{
8306 test_request_t req;
8307 DWORD error;
8308 BOOL ret;
8309
8310 open_simple_request(&req, "localhost", 1, NULL, "/");
8311
8312 SetLastError(0xdeadbeef);
8313 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
8314 error = GetLastError();
8315 ok(!ret, "unexpected success\n");
8316 ok(error == ERROR_INTERNET_CANNOT_CONNECT, "wrong error %lu\n", error);
8317
8318 close_request(&req);
8319}
8320
8322{
8324 DWORD size, error;
8325 char buffer[128];
8326 BOOL ret;
8327
8328 if(!is_ie7plus)
8329 return;
8330
8332 ok(session != NULL, "InternetOpen failed\n");
8333
8335 INTERNET_SERVICE_HTTP, 0, 0);
8336 ok(connect != NULL, "InternetConnect failed\n");
8337
8339 ok(request != NULL, "HttpOpenRequest failed\n");
8340
8341 SetLastError(0xdeadbeef);
8343 error = GetLastError();
8344 ok(!ret, "HttpSendRequest succeeded\n");
8346 "got %lu\n", error);
8347
8348 size = sizeof(buffer);
8349 memset(buffer, 0, sizeof(buffer));
8351 ok(ret, "HttpQueryInfo failed with error %lu\n", GetLastError());
8352 ok(!strcmp(buffer, "test.winehq.org:80"), "Expected test.winehg.org:80, got '%s'\n", buffer);
8353
8356
8359 ok(connect != NULL, "InternetConnect failed\n");
8360
8362 ok(request != NULL, "HttpOpenRequest failed\n");
8363
8366 {
8367 win_skip("Can't make https connection\n");
8368 goto done;
8369 }
8370 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
8371
8372 size = sizeof(buffer);
8373 memset(buffer, 0, sizeof(buffer));
8375 ok(ret, "HttpQueryInfo failed with error %lu\n", GetLastError());
8376 ok(!strcmp(buffer, "test.winehq.org"), "Expected test.winehg.org, got '%s'\n", buffer);
8377
8380
8383 ok(connect != NULL, "InternetConnect failed\n");
8384
8385 request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, NULL, 0, 0);
8386 ok(request != NULL, "HttpOpenRequest failed\n");
8387
8389 ok(ret, "HttpSendRequest failed with error %lu\n", GetLastError());
8390
8391 size = sizeof(buffer);
8392 memset(buffer, 0, sizeof(buffer));
8394 ok(ret, "HttpQueryInfo failed with error %lu\n", GetLastError());
8395 ok(!strcmp(buffer, "test.winehq.org:443"), "Expected test.winehg.org:443, got '%s'\n", buffer);
8396
8397done:
8401}
8402
8403static void init_status_tests(void)
8404{
8405 memset(expect, 0, sizeof(expect));
8406 memset(optional, 0, sizeof(optional));
8407 memset(wine_allow, 0, sizeof(wine_allow));
8408 memset(notified, 0, sizeof(notified));
8409 memset(status_string, 0, sizeof(status_string));
8410
8411#define STATUS_STRING(status) status_string[status] = #status
8438#undef STATUS_STRING
8439}
8440
8442{
8443 BOOL ret;
8444 DWORD index, size;
8445 char buf[256];
8446
8448 {
8449 ret = HttpAddRequestHeadersA( handle, "winetest: winetest", ~0u, HTTP_ADDREQ_FLAG_ADD );
8450 ok( ret, "HttpAddRequestHeadersA failed %lu\n", GetLastError() );
8451 SetEvent( (HANDLE)ctx );
8452 }
8454 {
8455 index = 0;
8456 size = sizeof(buf);
8458 buf, &size, &index );
8459 ok( ret, "HttpQueryInfoA failed %lu\n", GetLastError() );
8460 ok( strstr( buf, "winetest: winetest" ) != NULL, "header missing\n" );
8461 SetEvent( (HANDLE)ctx );
8462 }
8463}
8464
8466{
8467 HINTERNET ses, con, req;
8468 DWORD err;
8469 BOOL ret;
8471
8472 ses = InternetOpenA( "winetest", 0, NULL, NULL, INTERNET_FLAG_ASYNC );
8473 ok( ses != NULL, "InternetOpenA failed\n" );
8474
8475 con = InternetConnectA( ses, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
8476 INTERNET_SERVICE_HTTP, 0, 0 );
8477 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
8478
8479 req = HttpOpenRequestA( con, NULL, "/", NULL, NULL, NULL, 0, (DWORD_PTR)wait );
8480 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
8481
8482 pInternetSetStatusCallbackA( req, header_cb );
8483
8484 SetLastError( 0xdeadbeef );
8485 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
8486 err = GetLastError();
8487 ok( !ret, "HttpSendRequestA succeeded\n" );
8488 ok( err == ERROR_IO_PENDING, "got %u\n", ERROR_IO_PENDING );
8489
8490 WaitForSingleObject( wait, 5000 );
8491 WaitForSingleObject( wait, 5000 );
8492
8493 InternetCloseHandle( req );
8494 InternetCloseHandle( con );
8495 InternetCloseHandle( ses );
8496 CloseHandle( wait );
8497}
8498
8499static void test_cert_string(void)
8500{
8501 HINTERNET ses, con, req;
8502 char actual[512];
8503 DWORD size;
8504 BOOL res;
8506
8507 ses = InternetOpenA( "winetest", 0, NULL, NULL, 0 );
8508 ok( ses != NULL, "InternetOpenA failed\n" );
8509
8510 con = InternetConnectA( ses, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
8511 INTERNET_SERVICE_HTTP, 0, 0 );
8512 ok( con != NULL, "InternetConnectA failed %lu\n", GetLastError() );
8513
8514 req = HttpOpenRequestA( con, NULL, "/", NULL, NULL, NULL, 0, 0 );
8515 ok( req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError() );
8516
8517 size = sizeof(actual);
8518 SetLastError( 0xdeadbeef );
8519 memset( actual, 0x55, sizeof(actual) );
8522 "InternetQueryOption failed: %lu\n", GetLastError() );
8523 ok( size == 0, "unexpected size: %lu\n", size );
8524 ok( actual[0] == 0x55, "unexpected byte: %02x\n", actual[0] );
8525
8526 size = sizeof(chain);
8527 SetLastError(0xdeadbeef);
8530 "InternetQueryOption failed: %lu\n", GetLastError());
8531
8532 InternetCloseHandle( req );
8533 InternetCloseHandle( con );
8534 InternetCloseHandle( ses );
8535}
8536
8538{
8539 HMODULE hdll;
8540 hdll = GetModuleHandleA("wininet.dll");
8541
8542 if(!GetProcAddress(hdll, "InternetGetCookieExW")) {
8543 win_skip("Too old IE (older than 6.0)\n");
8544 return;
8545 }
8546
8547 pInternetSetStatusCallbackA = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackA");
8548 pInternetSetStatusCallbackW = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackW");
8549 pInternetGetSecurityInfoByURLA = (void*)GetProcAddress(hdll, "InternetGetSecurityInfoByURLA");
8550
8551 if(!pInternetGetSecurityInfoByURLA) {
8552 is_ie7plus = FALSE;
8553 win_skip("IE6 found. It's too old for some tests.\n");
8554 }
8555
8556 init_events();
8583 InternetSetFilePointer_test("test.winehq.org", "/tests/hello.html");
8588 free_events();
8589}
#define read
Definition: acwin.h:97
static int avail
Definition: adh-main.c:39
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
#define InterlockedDecrement
Definition: armddk.h:52
#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 ok_(x1, x2)
Definition: atltest.h:61
#define msg(x)
Definition: auth_time.c:54
#define index(s, c)
Definition: various.h:29
void get(int argc, const char *argv[])
Definition: cmds.c:480
#define ARRAY_SIZE(A)
Definition: main.h:20
static UCHAR password[]
Definition: bcrypt.c:494
#define RegCloseKey(hKey)
Definition: registry.h:49
static const WCHAR proxy_enable[]
Definition: connections.c:39
static const WCHAR internet_settings[]
Definition: connections.c:35
#define NO_ERROR
Definition: dderror.h:5
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_IO_PENDING
Definition: dderror.h:15
HRESULT hr
Definition: delayimp.cpp:582
#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 RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
content
Definition: atl_ax.c:990
static const WCHAR empty[1]
Definition: string.c:47
VOID WINAPI CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT pChainContext)
Definition: chain.c:2956
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define FILE_BEGIN
Definition: compat.h:761
#define INVALID_SET_FILE_POINTER
Definition: compat.h:732
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#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 FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define CALLBACK
Definition: compat.h:35
#define MultiByteToWideChar
Definition: compat.h:110
#define FILE_SHARE_READ
Definition: compat.h:136
#define lstrlenW
Definition: compat.h:750
HINTERNET connection
Definition: port.c:65
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
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:139
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:183
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
LANGID WINAPI GetUserDefaultLangID(void)
Definition: locale.c:1182
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
#define INT_MAX
Definition: limits.h:26
#define UINT_MAX
Definition: limits.h:27
_ACRTIMP int __cdecl atoi(const char *)
Definition: string.c:1720
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3420
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Definition: string.c:3335
USHORT port
Definition: uri.c:210
BOOL WINAPI HttpEndRequestW(HINTERNET hRequest, LPINTERNET_BUFFERSW lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5498
BOOL WINAPI HttpEndRequestA(HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5458
BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest, LPCSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1312
HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession, LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion, LPCSTR lpszReferrer, LPCSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:1393
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5710
BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:4115
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3967
BOOL WINAPI HttpSendRequestExW(HINTERNET hRequest, LPINTERNET_BUFFERSW lpBuffersIn, LPINTERNET_BUFFERSW lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5615
BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5792
BOOL WINAPI HttpSendRequestExA(HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffersIn, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5554
HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession, LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion, LPCWSTR lpszReferrer, LPCWSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:3569
BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength)
Definition: internet.c:3253
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2569
BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength)
Definition: internet.c:3286
BOOL WINAPI InternetLockRequestFile(HINTERNET hInternet, HANDLE *lphLockReqHandle)
Definition: internet.c:4651
BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:2710
BOOL WINAPI InternetUnlockRequestFile(HANDLE hLockHandle)
Definition: internet.c:4680
BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:2411
DWORD WINAPI InternetSetFilePointer(HINTERNET hFile, LONG lDistanceToMove, PVOID pReserved, DWORD dwMoveContext, DWORD_PTR dwContext)
Definition: internet.c:2534
BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer, DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
Definition: internet.c:2609
HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:1411
BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:3727
HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl, LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:4398
BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:2672
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1841
BOOL WINAPI InternetQueryDataAvailable(HINTERNET hFile, LPDWORD lpdwNumberOfBytesAvailable, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:4578
HINTERNET WINAPI InternetConnectA(HINTERNET hInternet, LPCSTR lpszServerName, INTERNET_PORT nServerPort, LPCSTR lpszUserName, LPCSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1748
HINTERNET WINAPI InternetConnectW(HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1685
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:1334
BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:3457
BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
Definition: urlcache.c:3291
BOOL WINAPI CreateUrlCacheEntryA(LPCSTR lpszUrlName, DWORD dwExpectedFileSize, LPCSTR lpszFileExtension, LPSTR lpszFileName, DWORD dwReserved)
Definition: urlcache.c:2789
BOOL WINAPI CommitUrlCacheEntryA(LPCSTR lpszUrlName, LPCSTR lpszLocalFileName, FILETIME ExpireTime, FILETIME LastModifiedTime, DWORD CacheEntryType, LPBYTE lpHeaderInfo, DWORD dwHeaderSize, LPCSTR lpszFileExtension, LPCSTR lpszOriginalUrl)
Definition: urlcache.c:3056
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
Definition: recv.c:87
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
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
time_t now
Definition: finger.c:65
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
GLuint start
Definition: gl.h:1545
const GLdouble * v
Definition: gl.h:2040
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 buffer
Definition: glext.h:5915
GLuint res
Definition: glext.h:9613
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLuint index
Definition: glext.h:6031
GLbitfield flags
Definition: glext.h:7161
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
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 IUnknown testsite
Definition: httpreq.c:1208
#define abort()
Definition: i386-dis.c:34
#define c
Definition: ke_i.h:80
#define b
Definition: ke_i.h:79
INT WINAPI GetTimeFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1052
INT WINAPI GetDateFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpDateStr, INT cchOut)
Definition: lcformat.c:944
USHORT LANGID
Definition: mui.h:9
int winetest_debug
#define ros_skip_flaky
Definition: minitest.h:84
#define win_skip
Definition: minitest.h:67
int winetest_interactive
#define todo_wine_if(is_todo)
Definition: minitest.h:81
#define todo_wine
Definition: minitest.h:80
#define ZeroMemory
Definition: minwinbase.h:31
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define htons(x)
Definition: module.h:215
#define CREATE_ALWAYS
Definition: disk.h:72
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static struct test_info tests[]
#define sprintf
Definition: sprintf.c:45
static IPrintDialogCallback callback
Definition: printdlg.c:325
static const WCHAR url[]
Definition: encode.c:1384
static BYTE cert[]
Definition: msg.c:1374
BOOL expected
Definition: store.c:2000
static HINSTANCE hkernel32
Definition: process.c:68
static SYSTEM_INFO si
Definition: virtual.c:39
static void ULONG ULONG * ret_size
Definition: time.c:40
static const CHAR post_data[]
Definition: protocol.c:222
static LPCWSTR file_name
Definition: protocol.c:152
static BOOL test_redirect
Definition: protocol.c:154
static WCHAR http[]
Definition: url.c:30
static WCHAR username[]
Definition: url.c:32
static void test_http_connection(void)
Definition: http.c:6739
#define CHECK_EXPECT(status)
Definition: http.c:69
static void test_basic_auth_credentials_different(int port)
Definition: http.c:5180
static const struct notification async_send_request_ex_test[]
Definition: http.c:8005
static const char okmsg2[]
Definition: http.c:2409
#define _SECURITY_FLAG_CERT_REV_FAILED
Definition: http.c:37
static void test_pac(int port)
Definition: http.c:6693
static int optional[MAX_INTERNET_STATUS]
Definition: http.c:110
static void _test_status_code(unsigned line, HINTERNET req, DWORD excode, BOOL is_todo)
Definition: http.c:249
static void _readex_expect_sync_data(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, DWORD buf_size, const char *exdata, DWORD expect_receive)
Definition: http.c:5774
static void _read_expect_sync_data_len(unsigned line, HINTERNET req, void *buf, DWORD buf_size, const char *exdata, DWORD len)
Definition: http.c:5781
static const char ok_with_length2[]
Definition: http.c:2462
static HINTERNET closetest_session
Definition: http.c:8237
static void test_connection_header(int port)
Definition: http.c:3443
static void test_request_content_length(int port)
Definition: http.c:4947
static void server_send_string(const char *msg)
Definition: http.c:5615
static LONG close_handle_cnt
Definition: http.c:366
#define async_query_data_available(a, b)
Definition: http.c:5940
static int notified[MAX_INTERNET_STATUS]
Definition: http.c:111
static void test_proxy_direct(int port)
Definition: http.c:2984
static HANDLE conn_wait_event
Definition: http.c:114
static const char expandcontmsg[]
Definition: http.c:2394
static DWORD _expect_data_available(unsigned line, HINTERNET req, int exsize)
Definition: http.c:5927
static void _readex_expect_async(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, DWORD buf_size, const char *exdata)
Definition: http.c:5876
static DWORD CALLBACK server_thread(LPVOID param)
Definition: http.c:2482
static void WINAPI header_cb(HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID info, DWORD len)
Definition: http.c:8441
static void HttpSendRequestEx_test(void)
Definition: http.c:1618
#define test_http_version(a)
Definition: http.c:352
static HANDLE complete_event
Definition: http.c:114
static void _open_simple_request(unsigned line, test_request_t *req, const char *host, int port, const char *verb, const char *url, BOOL use_proxy)
Definition: http.c:535
#define test_secflags_option(a, b, c)
Definition: http.c:6991
static const char okmsg[]
Definition: http.c:2399
#define TESTF_COMPRESSED
Definition: http.c:119
static const char largemsg[]
Definition: http.c:2420
static void _send_response_ex_and_wait(unsigned line, const char *response, BOOL close_connection, INTERNET_BUFFERSW *buf, const char *exdata, DWORD expected_req_error, DWORD expected_receive_size)
Definition: http.c:5855
static void _test_security_info(unsigned line, const char *urlc, DWORD error, DWORD ex_flags)
Definition: http.c:6952
static void test_basic_auth_credentials_end_session(int port)
Definition: http.c:5094
static BOOL https_support
Definition: http.c:45
static CRITICAL_SECTION notification_cs
Definition: http.c:7917
#define test_request_flags_todo(a, b)
Definition: http.c:322
static void setup_test(struct info *info, enum api function, unsigned int line, DWORD expect_result)
Definition: http.c:7987
static void test_no_cache(int port)
Definition: http.c:4084
static void test_basic_auth_credentials_reuse(int port)
Definition: http.c:5012
static void test_no_content(int port)
Definition: http.c:3802
#define SET_WINE_ALLOW(status)
Definition: http.c:66
static DWORD req_error
Definition: http.c:115
static const struct notification async_send_request_ex_resolve_failure_test[]
Definition: http.c:8051
#define receive_simple_request(a, b, c)
Definition: http.c:562
static const char noauthmsg2[]
Definition: http.c:2437
static void release_cert_info(INTERNET_CERTIFICATE_INFOA *info)
Definition: http.c:6827
static void test_large_header(int port)
Definition: http.c:3964
static void test_cookie_header(int port)
Definition: http.c:4369
static HANDLE conn_close_event
Definition: http.c:114
#define test_request_flags(a, b)
Definition: http.c:321
static const char noauthmsg[]
Definition: http.c:2430
#define send_response_and_wait(a, b, c, d, e, f, g, h)
Definition: http.c:5820
static void open_read_test_request(int port, test_request_t *req, const char *response)
Definition: http.c:5720
static void test_remove_dot_segments(int port)
Definition: http.c:6540
static void read_expect_async(HINTERNET req, void *buf, DWORD buf_size, DWORD *ret_size, const char *exdata)
Definition: http.c:5901
static void _send_response_and_wait(unsigned line, const char *response, BOOL do_close_connection, void *buf, DWORD *ret_size, const char *exdata, DWORD expected_size, DWORD expected_req_error, DWORD expected_receive_size)
Definition: http.c:5821
static void test_connection_break(int port)
Definition: http.c:6251
#define open_simple_request_proxy(a, b, c, d, e)
Definition: http.c:534
#define MAX_INTERNET_STATUS
Definition: http.c:109
static void _server_read_request(unsigned line, const char *expected_request)
Definition: http.c:5626
static const http_status_test_t http_status_tests[]
Definition: http.c:4835
#define STATUS_STRING(status)
static void test_secure_connection(void)
Definition: http.c:7391
static void test_proxy_indirect(int port)
Definition: http.c:2936
static void test_connection_closing(int port)
Definition: http.c:3598
static const char notokmsg[]
Definition: http.c:2425
static const char proxy_pac[]
Definition: http.c:2468
#define CHECK_NOTIFIED(status)
Definition: http.c:103
static const char page1[]
Definition: http.c:2450
static void test_response_without_headers(int port)
Definition: http.c:4493
static void test_concurrent_header_access(void)
Definition: http.c:8465
@ http_send_request_ex
Definition: http.c:7889
@ internet_close_handle
Definition: http.c:7892
@ http_end_request
Definition: http.c:7891
@ internet_writefile
Definition: http.c:7890
@ http_open_request
Definition: http.c:7888
@ internet_connect
Definition: http.c:7887
static void test_basic_authentication(int port)
Definition: http.c:4420
#define send_response_ex_and_wait(a, b, c, d, e, f)
Definition: http.c:5854
static int strcmp_wa(LPCWSTR strw, const char *stra)
Definition: http.c:194
static HINTERNET closetest_req
Definition: http.c:8237
static const char garbagemsg[]
Definition: http.c:2388
#define CLEAR_NOTIFIED(status)
Definition: http.c:91
static void WINAPI closetest_callback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
Definition: http.c:8240
static void _close_request(unsigned line, test_request_t *req)
Definition: http.c:550
static const char ok_with_length[]
Definition: http.c:2456
static BOOL closetest_closed
Definition: http.c:8238
static int test_cache_gzip
Definition: http.c:2478
static void test_header_override(int port)
Definition: http.c:3497
static void init_status_tests(void)
Definition: http.c:8403
static void test_cert_struct(HINTERNET req, const cert_struct_test_t *test)
Definition: http.c:6918
static INTERNET_STATUS_CALLBACK
Definition: http.c:170
#define set_secflags(a, b, c)
Definition: http.c:7013
#define close_request(a)
Definition: http.c:549
static void init_events(void)
Definition: http.c:220
static void _test_http_version(unsigned line, HINTERNET req)
Definition: http.c:353
static void test_http_cache(void)
Definition: http.c:1841
static void test_cache_control_verb(int port)
Definition: http.c:4900
static void test_open_url_async(void)
Definition: http.c:7820
static void test_large_content(int port)
Definition: http.c:6560
#define SET_OPTIONAL(status)
Definition: http.c:58
static BOOL first_connection_to_test_url
Definition: http.c:44
#define expect_data_available(a, b)
Definition: http.c:5926
static int server_socket
Definition: http.c:2480
#define CHECK_NOTIFIED2(status, num)
Definition: http.c:94
#define read_expect_sync_data(a, b, c, d)
Definition: http.c:5806
static void InternetReadFile_chunked_test(void)
Definition: http.c:1243
static void test_basic_auth_credentials_cached_manual(int port)
Definition: http.c:5356
static void send_socket_request(test_request_t *req, BOOL new_connection)
Definition: http.c:5662
#define test_request_url(a, b)
Definition: http.c:339
static void test_user_agent_header(void)
Definition: http.c:7577
static const char * status_string[MAX_INTERNET_STATUS]
Definition: http.c:112
#define server_read_request(a)
Definition: http.c:5625
static void _async_query_data_available(unsigned line, HINTERNET req, DWORD *size)
Definition: http.c:5941
static void InternetOpenUrlA_test(void)
Definition: http.c:1581
static void test_head_request(int port)
Definition: http.c:4539
static void test_header_handling_order(int port)
Definition: http.c:3352
#define open_simple_request(a, b, c, d, e)
Definition: http.c:533
static void test_async_read(int port)
Definition: http.c:5417
#define CHECK_NOT_NOTIFIED(status)
Definition: http.c:106
static const cert_struct_test_t test_winehq_org_cert
Definition: http.c:6841
static void test_basic_request(int port, const char *verb, const char *url)
Definition: http.c:2909
static DWORD received_response_size
Definition: http.c:5639
static void reset_events(void)
Definition: http.c:238
static void test_not_modified(int port)
Definition: http.c:3864
static void InternetOpenRequest_test(void)
Definition: http.c:1693
static void test_async_HttpSendRequestEx(const struct notification_data *nd)
Definition: http.c:8122
static void HttpHeaders_test(void)
Definition: http.c:2031
static void CALLBACK check_notification(HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID buffer, DWORD buflen)
Definition: http.c:7919
static void test_InternetCloseHandle(void)
Definition: http.c:8261
static void test_persistent_connection(int port)
Definition: http.c:6316
static const struct notification async_send_request_ex_chunked_test[]
Definition: http.c:8066
static void test_successive_HttpSendRequest(int port)
Definition: http.c:3718
static DWORD _receive_simple_request(unsigned line, HINTERNET req, char *buf, size_t buf_size)
Definition: http.c:563
static void InternetSetFilePointer_test(const char *host, const char *path)
Definition: http.c:587
static void close_connection(void)
Definition: http.c:5813
#define TESTF_REDIRECT
Definition: http.c:118
static void test_HttpSendRequestW(int port)
Definition: http.c:4339
#define test_security_info(a, b, c)
Definition: http.c:6951
static const char * send_buffer
Definition: http.c:2479
static void test_basic_auth_credentials_manual(int port)
Definition: http.c:5265
static void test_default_service_port(void)
Definition: http.c:8321
static void test_cache_read_gzipped(int port)
Definition: http.c:4150
static void test_cert_struct_string(HINTERNET req, const INTERNET_CERTIFICATE_INFOA *info)
Definition: http.c:6876
static void _test_request_flags(unsigned line, HINTERNET req, DWORD exflags, BOOL is_todo)
Definition: http.c:323
static void close_async_handle(HINTERNET handle, int handle_cnt)
Definition: http.c:574
static int wine_allow[MAX_INTERNET_STATUS]
Definition: http.c:111
#define TEST_URL
Definition: http.c:42
static void _test_secflags_option(unsigned line, HINTERNET req, DWORD ex_flags, DWORD opt_flags)
Definition: http.c:6992
static void test_premature_disconnect(int port)
Definition: http.c:4445
static void _test_request_url(unsigned line, HINTERNET req, const char *expected_url)
Definition: http.c:340
#define TESTF_CHUNKED
Definition: http.c:120
static const char okmsg201[]
Definition: http.c:2404
static void test_cache_read(void)
Definition: http.c:1742
static const char * cert_string_fmt
Definition: http.c:6866
static void test_HttpQueryInfo(int port)
Definition: http.c:4569
static void InternetLockRequestFile_test(void)
Definition: http.c:1978
static void test_connection_failure(void)
Definition: http.c:8304
#define test_status_code(a, b)
Definition: http.c:247
#define SET_OPTIONAL2(status, num)
Definition: http.c:55
static HANDLE request_sent_event
Definition: http.c:114
static BOOL is_ie7plus
Definition: http.c:116
#define readex_expect_sync_data(a, b, c, d, e, f)
Definition: http.c:5773
static void test_http_status(int port)
Definition: http.c:4873
static const struct notification async_send_request_ex_test2[]
Definition: http.c:8029
static HANDLE server_req_rec_event
Definition: http.c:114
static void open_socket_request(int port, test_request_t *req, const char *verb)
Definition: http.c:5696
static void test_header_length(int port)
Definition: http.c:6642
static const char contmsg[]
Definition: http.c:2391
static void test_bogus_accept_types_array(void)
Definition: http.c:7752
static void test_file_pointer(int port)
Definition: http.c:6177
static HINTERNET closetest_conn
Definition: http.c:8237
static void WINAPI readex_callback(HINTERNET handle, DWORD_PTR context, DWORD status, void *info, DWORD info_size)
Definition: http.c:5641
static void InternetReadFileExA_test(int flags)
Definition: http.c:1358
static const cert_struct_test_t test_winehq_com_cert
Definition: http.c:6848
static void _read_expect_sync_data(unsigned line, HINTERNET req, void *buf, DWORD buf_size, const char *exdata)
Definition: http.c:5807
#define SET_EXPECT2(status, num)
Definition: http.c:49
static void test_http_read(int port)
Definition: http.c:5958
static int expect[MAX_INTERNET_STATUS]
Definition: http.c:110
static void test_cert_string(void)
Definition: http.c:8499
#define readex_expect_async(a, b, c, d, e)
Definition: http.c:5875
static void test_accept_encoding(int port)
Definition: http.c:4970
static void InternetReadFile_test(int flags, const test_data_t *test)
Definition: http.c:858
static BOOL skip_receive_notification_tests
Definition: http.c:5638
static const char proxymsg[]
Definition: http.c:2443
static BOOL proxy_active(void)
Definition: http.c:201
static void test_invalid_response_headers(int port)
Definition: http.c:4462
static void test_conn_close(int port)
Definition: http.c:3999
static DWORD64 content_length
Definition: http.c:2419
static void test_options(int port)
Definition: http.c:4688
static void _readex_expect_sync_data_len(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, DWORD buf_size, const char *exdata, DWORD len, DWORD expect_receive)
Definition: http.c:5747
#define _SECURITY_FLAG_CERT_INVALID_CA
Definition: http.c:38
static void free_events(void)
Definition: http.c:229
static void _set_secflags(unsigned line, HINTERNET req, BOOL use_undoc, DWORD flags)
Definition: http.c:7014
static void test_security_flags(void)
Definition: http.c:7022
#define SET_EXPECT(status)
Definition: http.c:52
static PCCERT_CHAIN_CONTEXT DWORD *static BOOL is_lang_english(void)
Definition: http.c:174
static void send_response_len_and_wait(unsigned len, BOOL close_connection, INTERNET_BUFFERSW *buf)
Definition: http.c:5864
static void test_long_url(void)
Definition: url.c:481
#define min(a, b)
Definition: monoChain.cc:55
script
Definition: msipriv.h:396
#define closesocket
Definition: ncftp.h:477
HANDLE hThread
Definition: wizard.c:28
api
Definition: notification.c:39
#define server_read_data(a)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
#define LOCALE_USER_DEFAULT
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
char CHAR
Definition: pedump.c:57
#define err(...)
static unsigned int file_size
Definition: regtests2xml.c:47
#define test
Definition: rosglue.h:37
const WCHAR * str
#define LANG_ENGLISH
Definition: nls.h:52
#define PRIMARYLANGID(l)
Definition: nls.h:16
strcpy
Definition: string.h:131
#define memset(x, y, z)
Definition: compat.h:39
static PVOID hdll
Definition: shimdbg.c:126
TCHAR file_path[MAX_PATH]
Definition: sndrec32.cpp:57
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
DWORD_PTR dwResult
Definition: wininet.h:155
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
DWORD dwOffsetHigh
Definition: wininet.h:268
DWORD dwHeadersLength
Definition: wininet.h:262
DWORD dwStructSize
Definition: wininet.h:259
LPCSTR lpcszHeader
Definition: wininet.h:261
DWORD dwBufferLength
Definition: wininet.h:265
DWORD dwBufferTotal
Definition: wininet.h:266
struct _INTERNET_BUFFERSA * Next
Definition: wininet.h:260
LPVOID lpvBuffer
Definition: wininet.h:264
DWORD dwHeadersTotal
Definition: wininet.h:263
LPCWSTR lpcszHeader
Definition: wininet.h:274
LPVOID lpvBuffer
Definition: wininet.h:277
DWORD dwStructSize
Definition: wininet.h:272
LPINTERNET_PER_CONN_OPTIONW pOptions
Definition: wininet.h:372
const char * ex_issuer
Definition: http.c:6838
const char * ex_subject
Definition: http.c:6837
Definition: inflate.c:139
Definition: http.c:7783
HINTERNET req
Definition: http.c:7785
HANDLE event
Definition: http.c:7784
Definition: fci.c:123
Definition: txthost.c:37
const char * status_text
Definition: http.c:4831
const char * raw_headers
Definition: http.c:4832
const char * response_text
Definition: http.c:4829
unsigned int line
Definition: notification.c:76
enum api function
Definition: notification.c:71
unsigned int index
Definition: notification.c:74
BOOL is_aborted
Definition: http.c:7914
DWORD expect_result
Definition: http.c:7913
const struct notification * test
Definition: notification.c:72
DWORD thread
Definition: http.c:7911
HANDLE wait
Definition: notification.c:75
unsigned int buflen
Definition: notification.c:81
unsigned int count
Definition: notification.c:73
BOOL ret
Definition: http.c:6557
DWORD64 content_length
Definition: http.c:6556
Definition: parser.c:49
const struct notification * test
Definition: http.c:7996
const char * path
Definition: http.c:8000
const char * data
Definition: http.c:8001
const char * host
Definition: http.c:7999
const char * method
Definition: http.c:7998
const unsigned int count
Definition: http.c:7997
BOOL expect_conn_failure
Definition: http.c:8002
enum api function
Definition: notification.c:57
unsigned int status
Definition: notification.c:58
BOOL optional
Definition: http.c:7901
BOOL todo
Definition: http.c:7900
BOOL async
Definition: http.c:7899
Definition: tftpd.h:86
HANDLE hEvent
Definition: http.c:2474
Definition: ps.c:97
const char * post_data
Definition: http.c:129
const char * headers
Definition: http.c:127
const char * url
Definition: http.c:123
const char * path
Definition: http.c:126
DWORD flags
Definition: http.c:128
const char * host
Definition: http.c:125
const char * content
Definition: http.c:130
const char * redirected_url
Definition: http.c:124
HINTERNET connection
Definition: http.c:529
HINTERNET session
Definition: http.c:528
HINTERNET request
Definition: http.c:530
Definition: cmds.c:130
#define max(a, b)
Definition: svc.c:63
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:687
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:573
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
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:650
rwlock_t lock
Definition: tcpcore.h:0
struct sock * chain
Definition: tcpcore.h:1
const char * LPCSTR
Definition: typedefs.h:52
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define MAKEWORD(a, b)
Definition: typedefs.h:248
unsigned char * LPBYTE
Definition: typedefs.h:53
int64_t LONGLONG
Definition: typedefs.h:68
uint64_t DWORD64
Definition: typedefs.h:67
char * LPSTR
Definition: typedefs.h:51
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2753 u
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
#define FILE_END
Definition: winbase.h:117
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:462
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define FILE_CURRENT
Definition: winbase.h:116
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define WINAPI
Definition: msvc.h:6
u_long WINAPI inet_addr(const char *str)
Definition: wine.c:35
#define swprintf
Definition: winemm.h:209
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:257
#define ERROR_NEGATIVE_SEEK
Definition: winerror.h:325
static const char headmsg[]
Definition: winhttp.c:2251
static const char nocontentmsg[]
Definition: winhttp.c:2225
#define HTTP_STATUS_OK
Definition: winhttp.h:301
#define HTTP_STATUS_BAD_REQUEST
Definition: winhttp.h:317
LPVOID HINTERNET
Definition: winhttp.h:37
#define SECURITY_FLAG_SECURE
Definition: winhttp.h:347
#define ICU_BROWSER_MODE
Definition: winhttp.h:356
#define INTERNET_DEFAULT_HTTP_PORT
Definition: winhttp.h:41
#define SECURITY_FLAG_STRENGTH_STRONG
Definition: winhttp.h:350
#define SECURITY_FLAG_IGNORE_UNKNOWN_CA
Definition: winhttp.h:343
#define SECURITY_FLAG_IGNORE_CERT_CN_INVALID
Definition: winhttp.h:345
#define INTERNET_DEFAULT_HTTPS_PORT
Definition: winhttp.h:42
BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName, LPCSTR lpCookieData)
Definition: cookie.c:1139
#define HTTP_ADDREQ_FLAG_REPLACE
Definition: wininet.h:1711
#define INTERNET_FLAG_FROM_CACHE
Definition: wininet.h:69
#define IRF_NO_WAIT
Definition: wininet.h:625
#define INTERNET_STATUS_RECEIVING_RESPONSE
Definition: wininet.h:889
#define INTERNET_ERROR_MASK_COMBINED_SEC_CERT
Definition: wininet.h:125
#define INTERNET_OPTION_SECURITY_FLAGS
Definition: wininet.h:725
#define INTERNET_FLAG_DONT_CACHE
Definition: wininet.h:67
#define INTERNET_OPTION_PROXY_PASSWORD
Definition: wininet.h:738
#define HTTP_QUERY_SET_COOKIE
Definition: wininet.h:1566
#define PROXY_TYPE_AUTO_PROXY_URL
Definition: wininet.h:348
#define HTTP_QUERY_LAST_MODIFIED
Definition: wininet.h:1534
#define INTERNET_HANDLE_TYPE_HTTP_REQUEST
Definition: wininet.h:814
#define INTERNET_STATUS_CONNECTION_CLOSED
Definition: wininet.h:894
#define HTTP_QUERY_PROXY_AUTHENTICATE
Definition: wininet.h:1564
#define INTERNET_FLAG_RELOAD
Definition: wininet.h:61
#define ERROR_INTERNET_INVALID_URL
Definition: wininet.h:1994
#define INTERNET_STATUS_STATE_CHANGE
Definition: wininet.h:902
#define INTERNET_FLAG_RESYNCHRONIZE
Definition: wininet.h:82
#define INTERNET_PER_CONN_FLAGS
Definition: wininet.h:334
#define INTERNET_OPTION_PROXY_USERNAME
Definition: wininet.h:737
#define INTERNET_MAX_URL_LENGTH
Definition: wininet.h:51
#define ERROR_INTERNET_OPERATION_CANCELLED
Definition: wininet.h:2006
#define HTTP_QUERY_FLAG_SYSTEMTIME
Definition: wininet.h:1605
#define HTTP_QUERY_ACCEPT
Definition: wininet.h:1547
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
#define HTTP_QUERY_RAW_HEADERS_CRLF
Definition: wininet.h:1545
#define INTERNET_STATUS_REQUEST_SENT
Definition: wininet.h:888
#define INTERNET_FLAG_KEEP_CONNECTION
Definition: wininet.h:72
#define INTERNET_STATUS_COOKIE_RECEIVED
Definition: wininet.h:904
#define HTTP_QUERY_DATE
Definition: wininet.h:1532
#define INTERNET_STATUS_USER_INPUT_REQUIRED
Definition: wininet.h:901
#define HTTP_QUERY_STATUS_TEXT
Definition: wininet.h:1543
#define INTERNET_OPTION_USER_AGENT
Definition: wininet.h:735
#define HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
Definition: wininet.h:1709
#define HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Definition: wininet.h:1708
#define ERROR_INTERNET_ITEM_NOT_FOUND
Definition: wininet.h:2017
#define INTERNET_OPTION_PASSWORD
Definition: wininet.h:723
#define ERROR_INTERNET_SECURITY_CHANNEL_ERROR
Definition: wininet.h:2069
#define HTTP_QUERY_USER_AGENT
Definition: wininet.h:1562
#define INTERNET_STATUS_SENDING_REQUEST
Definition: wininet.h:887
#define INTERNET_OPTION_DATAFILE_NAME
Definition: wininet.h:727
#define INTERNET_STATUS_PREFETCH
Definition: wininet.h:892
#define INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY
Definition: wininet.h:127
#define HTTP_QUERY_VERSION
Definition: wininet.h:1541
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
#define INTERNET_STATUS_HANDLE_CLOSING
Definition: wininet.h:896
#define ERROR_INTERNET_INVALID_CA
Definition: wininet.h:2033
#define ERROR_INTERNET_OPTION_NOT_SETTABLE
Definition: wininet.h:2000
#define HTTP_QUERY_FORWARDED
Definition: wininet.h:1553
#define INTERNET_FLAG_NEED_FILE
Definition: wininet.h:88
#define INTERNET_STATUS_RESOLVING_NAME
Definition: wininet.h:883
#define INTERNET_PER_CONN_AUTOCONFIG_URL
Definition: wininet.h:337
#define INTERNET_FLAG_NO_CACHE_WRITE
Definition: wininet.h:66
#define INTERNET_FLAG_TRANSFER_BINARY
Definition: wininet.h:91
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2087
#define INTERNET_STATUS_INTERMEDIATE_RESPONSE
Definition: wininet.h:900
#define INTERNET_FLAG_SECURE
Definition: wininet.h:71
#define HTTP_ADDREQ_FLAG_ADD
Definition: wininet.h:1707
#define IRF_USE_CONTEXT
Definition: wininet.h:624
#define INTERNET_OPTION_URL
Definition: wininet.h:728
#define HTTP_QUERY_ACCEPT_RANGES
Definition: wininet.h:1565
#define HTTP_QUERY_CONTENT_TYPE
Definition: wininet.h:1524
#define INTERNET_REQFLAG_NO_HEADERS
Definition: wininet.h:58
struct _INTERNET_BUFFERSA INTERNET_BUFFERSA
#define INTERNET_OPTION_SERVER_CERT_CHAIN_CONTEXT
Definition: wininet.h:795
#define INTERNET_STATUS_RESPONSE_RECEIVED
Definition: wininet.h:890
#define INTERNET_OPEN_TYPE_DIRECT
Definition: wininet.h:522
#define INTERNET_STATUS_REDIRECT
Definition: wininet.h:899
#define HTTP_QUERY_COOKIE
Definition: wininet.h:1567
#define INTERNET_OPTION_PROXY
Definition: wininet.h:732
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define INTERNET_STATUS_CONNECTING_TO_SERVER
Definition: wininet.h:885
#define HTTP_QUERY_AUTHORIZATION
Definition: wininet.h:1551
#define ERROR_INTERNET_INCORRECT_HANDLE_STATE
Definition: wininet.h:2008
#define INTERNET_MAX_PATH_LENGTH
Definition: wininet.h:49
#define ERROR_INTERNET_INVALID_OPERATION
Definition: wininet.h:2005
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define HTTP_QUERY_TRANSFER_ENCODING
Definition: wininet.h:1586
#define INTERNET_OPTION_PER_CONNECTION_OPTION
Definition: wininet.h:765
#define HTTP_QUERY_HOST
Definition: wininet.h:1578
#define INTERNET_INVALID_PORT_NUMBER
Definition: wininet.h:36
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
#define INTERNET_STATUS_COOKIE_HISTORY
Definition: wininet.h:908
#define HTTP_ADDREQ_FLAG_COALESCE
Definition: wininet.h:1710
#define HTTP_QUERY_STATUS_CODE
Definition: wininet.h:1542
#define INTERNET_OPEN_TYPE_PRECONFIG
Definition: wininet.h:521
#define INTERNET_STATUS_COOKIE_SENT
Definition: wininet.h:903
#define HTTP_QUERY_RAW_HEADERS
Definition: wininet.h:1544
#define SECURITY_FLAG_IGNORE_REVOCATION
Definition: wininet.h:829
#define HTTP_QUERY_CONTENT_ENCODING
Definition: wininet.h:1552
#define INTERNET_OPTION_ERROR_MASK
Definition: wininet.h:755
#define HTTP_QUERY_CUSTOM
Definition: wininet.h:1603
#define ERROR_INTERNET_INVALID_OPTION
Definition: wininet.h:1998
#define ERROR_HTTP_INVALID_SERVER_RESPONSE
Definition: wininet.h:2060
#define INTERNET_HANDLE_TYPE_CONNECT_HTTP
Definition: wininet.h:805
#define ERROR_INTERNET_CANNOT_CONNECT
Definition: wininet.h:2018
#define HTTP_QUERY_SERVER
Definition: wininet.h:1560
#define INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT
Definition: wininet.h:726
#define INTERNET_OPTION_HTTP_VERSION
Definition: wininet.h:753
#define ERROR_HTTP_INVALID_QUERY_REQUEST
Definition: wininet.h:2062
#define HTTP_ADDREQ_FLAG_ADD_IF_NEW
Definition: wininet.h:1706
#define ERROR_INTERNET_NAME_NOT_RESOLVED
Definition: wininet.h:1996
#define ERROR_HTTP_INVALID_HEADER
Definition: wininet.h:2061
#define INTERNET_STATUS_CONNECTED_TO_SERVER
Definition: wininet.h:886
#define INTERNET_OPTION_CONTEXT_VALUE
Definition: wininet.h:739
#define INTERNET_STATUS_NAME_RESOLVED
Definition: wininet.h:884
#define INTERNET_OPTION_HANDLE_TYPE
Definition: wininet.h:710
#define INTERNET_FLAG_FORMS_SUBMIT
Definition: wininet.h:87
#define INTERNET_OPTION_SECURITY_CERTIFICATE
Definition: wininet.h:729
#define INTERNET_STATUS_CTL_RESPONSE_RECEIVED
Definition: wininet.h:891
#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE
Definition: wininet.h:2007
#define HTTP_QUERY_FLAG_REQUEST_HEADERS
Definition: wininet.h:1604
#define INTERNET_STATUS_P3P_HEADER
Definition: wininet.h:906
#define ERROR_INTERNET_SEC_CERT_ERRORS
Definition: wininet.h:2042
#define INTERNET_STATUS_CLOSING_CONNECTION
Definition: wininet.h:893
#define INTERNET_OPTION_USERNAME
Definition: wininet.h:722
#define INTERNET_OPTION_HTTP_DECODING
Definition: wininet.h:758
#define INTERNET_STATUS_PRIVACY_IMPACTED
Definition: wininet.h:905
#define INTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO
Definition: wininet.h:759
#define INTERNET_OPTION_SETTINGS_CHANGED
Definition: wininet.h:733
#define ERROR_HTTP_HEADER_NOT_FOUND
Definition: wininet.h:2058
#define INTERNET_OPTION_END_BROWSER_SESSION
Definition: wininet.h:736
#define INTERNET_STATUS_DETECTING_PROXY
Definition: wininet.h:897
#define HTTP_QUERY_CONTENT_LENGTH
Definition: wininet.h:1528
#define INTERNET_OPTION_CALLBACK
Definition: wininet.h:700
#define INTERNET_SERVICE_HTTP
Definition: wininet.h:562
#define INTERNET_OPTION_REQUEST_FLAGS
Definition: wininet.h:718
#define IRF_ASYNC
Definition: wininet.h:622
#define INTERNET_STATUS_P3P_POLICYREF
Definition: wininet.h:907
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#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 snprintf
Definition: wintirpc.h:48
unsigned char BYTE
Definition: xxhash.c:193