ReactOS 0.4.15-dev-7788-g1ad9096
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 %d (%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 %d (%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: %u\n", GetLastError());
260 todo_wine_if (is_todo)
261 ok_(__FILE__,line)(code == excode, "code = %d, expected %d\n", code, excode);
262 ok_(__FILE__,line)(size == sizeof(code), "size = %u\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: %u\n", GetLastError());
269 ok_(__FILE__,line)(!index, "index = %d, expected 0\n", index);
270 ok_(__FILE__,line)(size == sizeof(code), "size = %u\n", size);
271
272 sprintf(exbuf, "%u", excode);
273
274 size = sizeof(bufa);
276 ok_(__FILE__,line)(res, "[3] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE) failed: %u\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 %d for \"%s\"\n", size, exbuf);
280
281 size = 0;
284 "[4] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE) failed: %u\n", GetLastError());
285 ok_(__FILE__,line)(size == strlen(exbuf)+1, "unexpected size %d for \"%s\"\n", size, exbuf);
286
287 size = sizeof(bufw);
289 ok_(__FILE__,line)(res, "[5] HttpQueryInfoW(HTTP_QUERY_STATUS_CODE) failed: %u\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 %d for \"%s\"\n", size, exbuf);
293
294 size = 0;
297 "[6] HttpQueryInfoW(HTTP_QUERY_STATUS_CODE) failed: %u\n", GetLastError());
298 ok_(__FILE__,line)(size == (strlen(exbuf)+1)*sizeof(WCHAR), "unexpected size %d 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: %u\n", GetLastError());
304 ok(size == sizeof(bufw), "unexpected size %d\n", size);
305 }
306
307 code = 0xdeadbeef;
308 index = 1;
309 size = sizeof(code);
312 "[7] HttpQueryInfoA failed: %x(%d)\n", res, GetLastError());
313
314 code = 0xdeadbeef;
315 size = sizeof(code);
318 "[8] HttpQueryInfoA failed: %x(%d)\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: %u\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 = %x, expected %x\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: %u\n", GetLastError());
348 ok_(__FILE__,line)(size == strlen(expected_url), "size = %u\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: %u\n", GetLastError());
362 ok_(__FILE__,line)(v.dwMajorVersion == 1, "dwMajorVersion = %d\n", v.dwMajorVersion);
363 ok_(__FILE__,line)(v.dwMinorVersion == 1, "dwMinorVersion = %d\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("%04x:Callback %p 0x%lx INTERNET_STATUS_RESOLVING_NAME \"%s\" %d\n",
383 GetCurrentThreadId(), hInternet, dwContext,
384 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
385 *(LPSTR)lpvStatusInformation = '\0';
386 break;
388 if(winetest_debug > 1)
389 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_NAME_RESOLVED \"%s\" %d\n",
390 GetCurrentThreadId(), hInternet, dwContext,
391 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
392 *(LPSTR)lpvStatusInformation = '\0';
393 break;
395 if(winetest_debug > 1)
396 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %d\n",
397 GetCurrentThreadId(), hInternet, dwContext,
398 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
399 ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %u\n",
400 dwStatusInformationLength);
401 *(LPSTR)lpvStatusInformation = '\0';
402 break;
404 if(winetest_debug > 1)
405 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %d\n",
406 GetCurrentThreadId(), hInternet, dwContext,
407 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
408 ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %u\n",
409 dwStatusInformationLength);
410 *(LPSTR)lpvStatusInformation = '\0';
411 break;
413 if(winetest_debug > 1)
414 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_SENDING_REQUEST %p %d\n",
415 GetCurrentThreadId(), hInternet, dwContext,
416 lpvStatusInformation,dwStatusInformationLength);
417 break;
419 ok(dwStatusInformationLength == sizeof(DWORD),
420 "info length should be sizeof(DWORD) instead of %d\n",
421 dwStatusInformationLength);
422 if(winetest_debug > 1)
423 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_SENT 0x%x %d\n",
424 GetCurrentThreadId(), hInternet, dwContext,
425 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
426 break;
428 if(winetest_debug > 1)
429 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RECEIVING_RESPONSE %p %d\n",
430 GetCurrentThreadId(), hInternet, dwContext,
431 lpvStatusInformation,dwStatusInformationLength);
432 break;
434 ok(dwStatusInformationLength == sizeof(DWORD),
435 "info length should be sizeof(DWORD) instead of %d\n",
436 dwStatusInformationLength);
437 if(winetest_debug > 1)
438 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RESPONSE_RECEIVED 0x%x %d\n",
439 GetCurrentThreadId(), hInternet, dwContext,
440 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
441 break;
443 if(winetest_debug > 1)
444 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CTL_RESPONSE_RECEIVED %p %d\n",
445 GetCurrentThreadId(), hInternet,dwContext,
446 lpvStatusInformation,dwStatusInformationLength);
447 break;
449 if(winetest_debug > 1)
450 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_PREFETCH %p %d\n",
451 GetCurrentThreadId(), hInternet, dwContext,
452 lpvStatusInformation,dwStatusInformationLength);
453 break;
455 if(winetest_debug > 1)
456 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CLOSING_CONNECTION %p %d\n",
457 GetCurrentThreadId(), hInternet, dwContext,
458 lpvStatusInformation,dwStatusInformationLength);
459 break;
461 if(winetest_debug > 1)
462 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTION_CLOSED %p %d\n",
463 GetCurrentThreadId(), hInternet, dwContext,
464 lpvStatusInformation,dwStatusInformationLength);
465 break;
467 ok(dwStatusInformationLength == sizeof(HINTERNET),
468 "info length should be sizeof(HINTERNET) instead of %d\n",
469 dwStatusInformationLength);
470 if(winetest_debug > 1)
471 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CREATED %p %d\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 %d\n",
480 dwStatusInformationLength);
481 if(winetest_debug > 1)
482 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CLOSING %p %d\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 %d\n",
493 dwStatusInformationLength);
494 ok(iar->dwResult == 1 || iar->dwResult == 0, "iar->dwResult = %ld\n", iar->dwResult);
495 if(winetest_debug > 1)
496 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_COMPLETE {%ld,%d} %d\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("%04x:Callback %p 0x%lx INTERNET_STATUS_REDIRECT \"%s\" %d\n",
507 GetCurrentThreadId(), hInternet, dwContext,
508 (LPCSTR)lpvStatusInformation, dwStatusInformationLength);
509 *(LPSTR)lpvStatusInformation = '\0';
512 break;
514 if(winetest_debug > 1)
515 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_INTERMEDIATE_RESPONSE %p %d\n",
516 GetCurrentThreadId(), hInternet, dwContext,
517 lpvStatusInformation, dwStatusInformationLength);
518 break;
519 default:
520 if(winetest_debug > 1)
521 trace("%04x:Callback %p 0x%lx %d %p %d\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)
534static void _open_simple_request(unsigned line, test_request_t *req, const char *host,
535 int port, const char *verb, const char *url)
536{
538 ok_(__FILE__,line)(req->session != NULL, "InternetOpenA failed: %u\n", GetLastError());
539
541 ok_(__FILE__,line)(req->connection != NULL, "InternetConnectA failed: %u\n", GetLastError());
542
543 req->request = HttpOpenRequestA(req->connection, verb, url, NULL, NULL, NULL, 0, 0);
544 ok_(__FILE__,line)(req->request != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
545}
546
547#define close_request(a) _close_request(__LINE__,a)
548static void _close_request(unsigned line, test_request_t *req)
549{
550 BOOL ret;
551
553 ok_(__FILE__,line)(ret, "InternetCloseHandle(request) failed: %u\n", GetLastError());
555 ok_(__FILE__,line)(ret, "InternetCloseHandle(connection) failed: %u\n", GetLastError());
557 ok_(__FILE__,line)(ret, "InternetCloseHandle(session) failed: %u\n", GetLastError());
558}
559
560#define receive_simple_request(a,b,c) _receive_simple_request(__LINE__,a,b,c)
561static DWORD _receive_simple_request(unsigned line, HINTERNET req, char *buf, size_t buf_size)
562{
563 DWORD read = 0;
564 BOOL ret;
565
566 ret = InternetReadFile(req, buf, buf_size, &read);
567 ok_(__FILE__,line)(ret, "InternetReadFile failed: %u\n", GetLastError());
568
569 return read;
570}
571
572static void close_async_handle(HINTERNET handle, int handle_cnt)
573{
574 BOOL res;
575
576 close_handle_cnt = handle_cnt;
577
580 ok(res, "InternetCloseHandle failed: %u\n", GetLastError());
583}
584
586{
587 char *post_data = NULL;
588 BOOL res, on_async = TRUE;
589 CHAR buffer[4000];
590 WCHAR wbuffer[4000];
591 DWORD length, length2, index, exlen = 0, post_len = 0;
592 const char *types[2] = { "*", NULL };
593 HINTERNET hi, hic = 0, hor = 0;
594 DWORD contents_length, accepts_ranges;
595 BOOL not_supported;
596
597 trace("Starting InternetReadFile test with flags 0x%x on url %s\n",flags,test->url);
598 reset_events();
599
600 trace("InternetOpenA <--\n");
601 hi = InternetOpenA((test->flags & TESTF_COMPRESSED) ? "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" : "",
603 ok((hi != 0x0),"InternetOpen failed with error %u\n", GetLastError());
604 trace("InternetOpenA -->\n");
605
606 if (hi == 0x0) goto abort;
607
608 pInternetSetStatusCallbackA(hi,&callback);
609
611
612 trace("InternetConnectA <--\n");
614 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
615 ok((hic != 0x0),"InternetConnect failed with error %u\n", GetLastError());
616 trace("InternetConnectA -->\n");
617
618 if (hic == 0x0) goto abort;
619
622
623 trace("HttpOpenRequestA <--\n");
624 hor = HttpOpenRequestA(hic, test->post_data ? "POST" : "GET", test->path, NULL, NULL, types,
626 0xdeadbead);
627 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
628 /*
629 * If the internet name can't be resolved we are probably behind
630 * a firewall or in some other way not directly connected to the
631 * Internet. Not enough reason to fail the test. Just ignore and
632 * abort.
633 */
634 } else {
635 ok((hor != 0x0),"HttpOpenRequest failed with error %u\n", GetLastError());
636 }
637 trace("HttpOpenRequestA -->\n");
638
639 if (hor == 0x0) goto abort;
640
642 test_request_url(hor, test->url);
643
644 length = sizeof(buffer);
646 ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
647 ok(length == 0 || (length == 1 && !*buffer) /* win10 */, "HTTP_QUERY_RAW_HEADERS: expected length 0, but got %d\n", length);
648 ok(!strcmp(buffer, ""), "HTTP_QUERY_RAW_HEADERS: expected string \"\", but got \"%s\"\n", buffer);
649
656 {
659 }
666 if(test->flags & TESTF_REDIRECT) {
669 }
675
676 if(test->flags & TESTF_COMPRESSED) {
677 BOOL b = TRUE;
678
681 "InternetSetOption failed: %u\n", GetLastError());
682 if(!res)
683 goto abort;
684 }
685
686 test_status_code(hor, 0);
687
688 trace("HttpSendRequestA -->\n");
689 if(test->post_data) {
690 post_len = strlen(test->post_data);
691 post_data = HeapAlloc(GetProcessHeap(), 0, post_len);
692 memcpy(post_data, test->post_data, post_len);
693 }
694 SetLastError(0xdeadbeef);
695 res = HttpSendRequestA(hor, test->headers, -1, post_data, post_len);
698 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
699 else
701 "Synchronous HttpSendRequest returning 0, error %u\n", GetLastError());
702 trace("HttpSendRequestA <--\n");
703
706 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
707 }
709
713 {
714 if (! proxy_active())
715 {
718 }
719 else
720 {
723 }
724 }
725 else
726 {
729 }
734 if(test->flags & TESTF_REDIRECT)
738 /* Sent on WinXP only if first_connection_to_test_url is TRUE, on Win98 always sent */
741
742 test_request_flags(hor, 0);
743
744 length = 100;
746 ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed with error %d\n", GetLastError());
747
748 length = sizeof(buffer)-2;
749 memset(buffer, 0x77, sizeof(buffer));
750 SetLastError(0xdeadbeef);
752 ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
753 ok(GetLastError() == 0 ||
754 broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %u\n", GetLastError());
755 /* show that the function writes data past the length returned */
756 ok(buffer[length-2], "Expected any header character, got 0x00\n");
757 ok(!buffer[length-1], "Expected 0x00, got %02X\n", buffer[length-1]);
758 ok(!buffer[length], "Expected 0x00, got %02X\n", buffer[length]);
759 ok(buffer[length+1] == 0x77, "Expected 0x77, got %02X\n", buffer[length+1]);
760
761 length2 = length;
763 ok(!res, "Expected 0x00, got %d\n", res);
764 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
765 ok(length2 == length+1, "Expected %d, got %d\n", length+1, length2);
766 /* the in length of the buffer must be +1 but the length returned does not count this */
767 length2 = length+1;
768 memset(buffer, 0x77, sizeof(buffer));
770 ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
771 ok(buffer[length2] == 0x00, "Expected 0x00, got %02X\n", buffer[length2]);
772 ok(buffer[length2+1] == 0x77, "Expected 0x77, got %02X\n", buffer[length2+1]);
773 ok(length2 == length, "Value should not have changed: %d != %d\n", length2, length);
774
775 length = sizeof(wbuffer)-2*sizeof(WCHAR);
776 memset(wbuffer, 0x77, sizeof(wbuffer));
777 res = HttpQueryInfoW(hor, HTTP_QUERY_RAW_HEADERS, wbuffer, &length, 0x0);
778 ok(res, "HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
779 ok(length % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length);
780 length /= sizeof(WCHAR);
781 /* show that the function writes data past the length returned */
782 ok(wbuffer[length-2], "Expected any header character, got 0x0000\n");
783 ok(!wbuffer[length-1], "Expected 0x0000, got %04X\n", wbuffer[length-1]);
784 ok(!wbuffer[length], "Expected 0x0000, got %04X\n", wbuffer[length]);
785 ok(wbuffer[length+1] == 0x7777 || broken(wbuffer[length+1] != 0x7777),
786 "Expected 0x7777, got %04X\n", wbuffer[length+1]);
787
788 length2 = length*sizeof(WCHAR);
789 res = HttpQueryInfoW(hor,HTTP_QUERY_RAW_HEADERS,wbuffer,&length2,0x0);
790 ok(!res, "Expected 0x00, got %d\n", res);
791 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
792 ok(length2 % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length2);
793 length2 /= sizeof(WCHAR);
794 ok(length2 == length+1, "Expected %d, got %d\n", length+1, length2);
795 /* the in length of the buffer must be +1 but the length returned does not count this */
796 length2 = (length+1)*sizeof(WCHAR);
797 memset(wbuffer, 0x77, sizeof(wbuffer));
798 res = HttpQueryInfoW(hor,HTTP_QUERY_RAW_HEADERS,wbuffer,&length2,0x0);
799 ok(res, "HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
800 ok(length2 % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length2);
801 length2 /= sizeof(WCHAR);
802 ok(!wbuffer[length2], "Expected 0x0000, got %04X\n", wbuffer[length2]);
803 ok(wbuffer[length2+1] == 0x7777, "Expected 0x7777, got %04X\n", wbuffer[length2+1]);
804 ok(length2 == length, "Value should not have changed: %d != %d\n", length2, length);
805
806 test_request_url(hor, test->redirected_url);
807
808 index = 0;
809 length = 0;
810 SetLastError(0xdeadbeef);
812 if(test->flags & TESTF_COMPRESSED)
814 "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", GetLastError());
815 ok(index == 0, "Index was incremented\n");
816
817 index = 0;
818 length = 16;
820 trace("Option HTTP_QUERY_CONTENT_LENGTH -> %i %s (%u)\n",res,buffer,GetLastError());
821 if(test->flags & TESTF_COMPRESSED)
822 {
824 "expected ERROR_HTTP_HEADER_NOT_FOUND, got %x (%u)\n", res, GetLastError());
825 contents_length = 0;
826 }
827 else
828 {
829 contents_length = atoi(buffer);
830 }
831 ok(!res || index == 1, "Index was not incremented although result is %x (index = %u)\n", res, index);
832
833 length = 64;
834 *buffer = 0;
836 trace("Option HTTP_QUERY_ACCEPT_RANGES -> %i %s (%u)\n",res,buffer,GetLastError());
837 accepts_ranges = res && !strcmp(buffer, "bytes");
838
839 length = 100;
841 buffer[length]=0;
842 trace("Option HTTP_QUERY_CONTENT_TYPE -> %i %s\n",res,buffer);
843
844 length = 100;
846 buffer[length]=0;
847 trace("Option HTTP_QUERY_CONTENT_ENCODING -> %i %s\n",res,buffer);
848
849 SetLastError(0xdeadbeef);
851 not_supported = length == INVALID_SET_FILE_POINTER
853 if (accepts_ranges)
854 todo_wine ok((length == contents_length && (GetLastError() == ERROR_SUCCESS
855 || broken(GetLastError() == 0xdeadbeef))) || broken(not_supported),
856 "Got unexpected length %#x, GetLastError() %u, contents_length %u, accepts_ranges %#x.\n",
857 length, GetLastError(), contents_length, accepts_ranges);
858 else
859 ok(not_supported, "Got unexpected length %#x, GetLastError() %u.\n", length, GetLastError());
860
862 {
863 SetLastError(0xdeadbeef);
865 ok(!length && (GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef)),
866 "Got unexpected length %#x, GetLastError() %u.\n", length, GetLastError());
867 }
868
869 SetLastError(0xdeadbeef);
871 ok(!res, "InternetReadFile should have failed\n");
873 "InternetReadFile should have set last error to ERROR_INVALID_HANDLE instead of %u\n",
874 GetLastError());
875
876 length = 100;
877 if(winetest_debug > 1)
878 trace("Entering Query loop\n");
879
880 while (TRUE)
881 {
884
885 /* IE11 calls those in InternetQueryDataAvailable call. */
888
889 length = 0;
890 res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
891
893
895 {
896 if (res)
897 {
899 if(exlen) {
900 ok(length >= exlen, "length %u < exlen %u\n", length, exlen);
901 exlen = 0;
902 }
903 }
904 else if (GetLastError() == ERROR_IO_PENDING)
905 {
906 if(winetest_debug > 1)
907 trace("pending\n");
908 /* on some tests, InternetQueryDataAvailable returns non-zero length and ERROR_IO_PENDING */
909 if(!(test->flags & TESTF_CHUNKED))
910 ok(!length, "InternetQueryDataAvailable returned ERROR_IO_PENDING and %u length\n", length);
912 exlen = length;
913 ok(exlen, "length = 0\n");
916 ok(req_error, "req_error = 0\n");
917 continue;
918 }else {
919 ok(0, "InternetQueryDataAvailable failed: %u\n", GetLastError());
920 }
921 }else {
922 ok(res, "InternetQueryDataAvailable failed: %u\n", GetLastError());
923 }
925
926 if(winetest_debug > 1)
927 trace("length %u\n", length);
928 if(test->flags & TESTF_CHUNKED)
929 ok(length <= 8192, "length = %d, expected <= 8192\n", length);
930 if (length)
931 {
932 char *buffer;
934
936
937 buffer[length]=0;
938
939 if(winetest_debug > 1)
940 trace("ReadFile -> %s %i\n", res ? "TRUE" : "FALSE", length);
941
942 if(test->content)
943 ok(!strcmp(buffer, test->content), "buffer = '%s', expected '%s'\n", buffer, test->content);
945 }else {
946 ok(!on_async, "Returned zero size in response to request complete\n");
947 break;
948 }
949 on_async = FALSE;
950 }
951 if(test->flags & TESTF_REDIRECT) {
954 }
955abort:
956 if(winetest_debug > 1)
957 trace("aborting\n");
958 close_async_handle(hi, 2);
960}
961
963{
964 BOOL res;
965 CHAR buffer[4000];
966 DWORD length, got;
967 const char *types[2] = { "*", NULL };
968 HINTERNET hi, hic = 0, hor = 0;
969
970 trace("Starting InternetReadFile chunked test\n");
971
972 trace("InternetOpenA <--\n");
974 ok((hi != 0x0),"InternetOpen failed with error %u\n", GetLastError());
975 trace("InternetOpenA -->\n");
976
977 if (hi == 0x0) goto abort;
978
979 trace("InternetConnectA <--\n");
980 hic=InternetConnectA(hi, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER,
981 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
982 ok((hic != 0x0),"InternetConnect failed with error %u\n", GetLastError());
983 trace("InternetConnectA -->\n");
984
985 if (hic == 0x0) goto abort;
986
987 trace("HttpOpenRequestA <--\n");
988 hor = HttpOpenRequestA(hic, "GET", "/tests/chunked", NULL, NULL, types,
990 0xdeadbead);
991 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
992 /*
993 * If the internet name can't be resolved we are probably behind
994 * a firewall or in some other way not directly connected to the
995 * Internet. Not enough reason to fail the test. Just ignore and
996 * abort.
997 */
998 } else {
999 ok((hor != 0x0),"HttpOpenRequest failed with error %u\n", GetLastError());
1000 }
1001 trace("HttpOpenRequestA -->\n");
1002
1003 if (hor == 0x0) goto abort;
1004
1005 trace("HttpSendRequestA -->\n");
1006 SetLastError(0xdeadbeef);
1007 res = HttpSendRequestA(hor, "", -1, NULL, 0);
1009 "Synchronous HttpSendRequest returning 0, error %u\n", GetLastError());
1010 trace("HttpSendRequestA <--\n");
1011
1012 test_request_flags(hor, 0);
1013
1014 length = 100;
1016 buffer[length]=0;
1017 trace("Option CONTENT_TYPE -> %i %s\n",res,buffer);
1018
1019 SetLastError( 0xdeadbeef );
1020 length = 100;
1022 buffer[length]=0;
1023 trace("Option TRANSFER_ENCODING -> %i %s\n",res,buffer);
1025 "Failed to get TRANSFER_ENCODING option, error %u\n", GetLastError() );
1026 ok( !strcmp( buffer, "chunked" ) || ( ! res && proxy_active() && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND ),
1027 "Wrong transfer encoding '%s'\n", buffer );
1028
1029 SetLastError( 0xdeadbeef );
1030 length = 16;
1032 ok( !res, "Found CONTENT_LENGTH option '%s'\n", buffer );
1033 ok( GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "Wrong error %u\n", GetLastError() );
1034
1035 length = 100;
1036 trace("Entering Query loop\n");
1037
1038 while (TRUE)
1039 {
1040 res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
1041 ok(!(!res && length != 0),"InternetQueryDataAvailable failed with non-zero length\n");
1042 ok(res, "InternetQueryDataAvailable failed, error %d\n", GetLastError());
1043 trace("got %u available\n",length);
1044 if (length)
1045 {
1046 char *buffer = HeapAlloc(GetProcessHeap(),0,length+1);
1047
1048 SetLastError(0xdeadbeef);
1049 res = InternetReadFile(hor,buffer,length,&got);
1050 ok(GetLastError() == 0 ||
1051 broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %u\n", GetLastError());
1052
1053 buffer[got]=0;
1054 trace("ReadFile -> %i %i\n",res,got);
1055 ok( length == got, "only got %u of %u available\n", got, length );
1056 ok( buffer[got-1] == '\n', "received partial line '%s'\n", buffer );
1057
1059 if (!got) break;
1060 }
1061 if (length == 0)
1062 {
1063 got = 0xdeadbeef;
1064 SetLastError(0xdeadbeef);
1065 res = InternetReadFile( hor, buffer, 1, &got );
1066 ok( res, "InternetReadFile failed: %u\n", GetLastError() );
1067 ok(GetLastError() == 0 ||
1068 broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %u\n", GetLastError());
1069 ok( !got, "got %u\n", got );
1070 break;
1071 }
1072 }
1073abort:
1074 trace("aborting\n");
1075 if (hor != 0x0) {
1076 res = InternetCloseHandle(hor);
1077 ok (res, "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
1078 }
1079 if (hi != 0x0) {
1081 ok (res, "InternetCloseHandle of handle opened by InternetOpenA failed\n");
1082 }
1083}
1084
1086{
1087 DWORD rc;
1088 DWORD length;
1089 const char *types[2] = { "*", NULL };
1090 HINTERNET hi, hic = 0, hor = 0;
1091 INTERNET_BUFFERSA inetbuffers;
1092
1093 trace("Starting InternetReadFileExA test with flags 0x%x\n",flags);
1094 reset_events();
1095
1096 trace("InternetOpenA <--\n");
1098 ok((hi != 0x0),"InternetOpen failed with error %u\n", GetLastError());
1099 trace("InternetOpenA -->\n");
1100
1101 if (hi == 0x0) goto abort;
1102
1103 pInternetSetStatusCallbackA(hi,&callback);
1104
1106
1107 trace("InternetConnectA <--\n");
1108 hic=InternetConnectA(hi, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER,
1109 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
1110 ok((hic != 0x0),"InternetConnect failed with error %u\n", GetLastError());
1111 trace("InternetConnectA -->\n");
1112
1113 if (hic == 0x0) goto abort;
1114
1117
1118 trace("HttpOpenRequestA <--\n");
1119 hor = HttpOpenRequestA(hic, "GET", "/tests/redirect", NULL, NULL, types,
1121 0xdeadbead);
1122 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
1123 /*
1124 * If the internet name can't be resolved we are probably behind
1125 * a firewall or in some other way not directly connected to the
1126 * Internet. Not enough reason to fail the test. Just ignore and
1127 * abort.
1128 */
1129 } else {
1130 ok((hor != 0x0),"HttpOpenRequest failed with error %u\n", GetLastError());
1131 }
1132 trace("HttpOpenRequestA -->\n");
1133
1134 if (hor == 0x0) goto abort;
1135
1140 {
1143 }
1158 else
1160
1161 trace("HttpSendRequestA -->\n");
1162 SetLastError(0xdeadbeef);
1163 rc = HttpSendRequestA(hor, "", -1, NULL, 0);
1165 ok(((rc == 0)&&(GetLastError() == ERROR_IO_PENDING)),
1166 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
1167 else
1169 "Synchronous HttpSendRequest returning 0, error %u\n", GetLastError());
1170 trace("HttpSendRequestA <--\n");
1171
1172 if (!rc && (GetLastError() == ERROR_IO_PENDING)) {
1174 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
1175 }
1176
1178 {
1181 }
1182 else
1183 {
1186 }
1196 else
1199 /* Sent on WinXP only if first_connection_to_test_url is TRUE, on Win98 always sent */
1202
1203 if(is_ie7plus) {
1204 rc = InternetReadFileExW(hor, NULL, 0, 0xdeadcafe);
1206 "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %u\n",
1207 rc ? "TRUE" : "FALSE", GetLastError());
1208 }
1209
1210 /* tests invalid dwStructSize */
1211 inetbuffers.dwStructSize = sizeof(inetbuffers)+1;
1212 inetbuffers.lpcszHeader = NULL;
1213 inetbuffers.dwHeadersLength = 0;
1214 inetbuffers.dwBufferLength = 10;
1215 inetbuffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, 10);
1216 inetbuffers.dwOffsetHigh = 1234;
1217 inetbuffers.dwOffsetLow = 5678;
1218 rc = InternetReadFileExA(hor, &inetbuffers, 0, 0xdeadcafe);
1220 "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %u\n",
1221 rc ? "TRUE" : "FALSE", GetLastError());
1222 HeapFree(GetProcessHeap(), 0, inetbuffers.lpvBuffer);
1223
1224 test_request_flags(hor, 0);
1225
1226 /* tests to see whether lpcszHeader is used - it isn't */
1227 inetbuffers.dwStructSize = sizeof(inetbuffers);
1228 inetbuffers.lpcszHeader = (LPCSTR)0xdeadbeef;
1229 inetbuffers.dwHeadersLength = 255;
1230 inetbuffers.dwBufferLength = 0;
1231 inetbuffers.lpvBuffer = NULL;
1232 inetbuffers.dwOffsetHigh = 1234;
1233 inetbuffers.dwOffsetLow = 5678;
1234 rc = InternetReadFileExA(hor, &inetbuffers, 0, 0xdeadcafe);
1235 ok(rc, "InternetReadFileEx failed with error %u\n", GetLastError());
1236 trace("read %i bytes\n", inetbuffers.dwBufferLength);
1237
1238 rc = InternetReadFileExA(NULL, &inetbuffers, 0, 0xdeadcafe);
1239 ok(!rc && (GetLastError() == ERROR_INVALID_HANDLE),
1240 "InternetReadFileEx should have failed with ERROR_INVALID_HANDLE instead of %s, %u\n",
1241 rc ? "TRUE" : "FALSE", GetLastError());
1242
1243 length = 0;
1244 trace("Entering Query loop\n");
1245
1246 while (TRUE)
1247 {
1248 inetbuffers.dwStructSize = sizeof(inetbuffers);
1249 inetbuffers.dwBufferLength = 1024;
1250 inetbuffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, inetbuffers.dwBufferLength+1);
1251 inetbuffers.dwOffsetHigh = 1234;
1252 inetbuffers.dwOffsetLow = 5678;
1253
1257 rc = InternetReadFileExA(hor, &inetbuffers, IRF_ASYNC | IRF_USE_CONTEXT, 0xcafebabe);
1258 if (!rc)
1259 {
1261 {
1262 trace("InternetReadFileEx -> PENDING\n");
1264 "Should not get ERROR_IO_PENDING without INTERNET_FLAG_ASYNC\n");
1269 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
1270 }
1271 else
1272 {
1273 trace("InternetReadFileEx -> FAILED %u\n", GetLastError());
1274 break;
1275 }
1276 }
1277 else
1278 {
1279 trace("InternetReadFileEx -> SUCCEEDED\n");
1281 if (inetbuffers.dwBufferLength)
1282 {
1285 }
1286 else
1287 {
1288 /* Win98 still sends these when 0 bytes are read, WinXP does not */
1291 }
1292 }
1293
1294 trace("read %i bytes\n", inetbuffers.dwBufferLength);
1295 ((char *)inetbuffers.lpvBuffer)[inetbuffers.dwBufferLength] = '\0';
1296
1297 ok(inetbuffers.dwOffsetHigh == 1234 && inetbuffers.dwOffsetLow == 5678,
1298 "InternetReadFileEx sets offsets to 0x%x%08x\n",
1299 inetbuffers.dwOffsetHigh, inetbuffers.dwOffsetLow);
1300
1301 HeapFree(GetProcessHeap(), 0, inetbuffers.lpvBuffer);
1302
1303 if (!inetbuffers.dwBufferLength)
1304 break;
1305
1306 length += inetbuffers.dwBufferLength;
1307 }
1308 ok(length > 0, "failed to read any of the document\n");
1309 trace("Finished. Read %d bytes\n", length);
1310
1311abort:
1312 close_async_handle(hi, 2);
1314}
1315
1316static void InternetOpenUrlA_test(void)
1317{
1318 HINTERNET myhinternet, myhttp;
1319 char buffer[0x400];
1320 DWORD size, readbytes, totalbytes=0;
1321 BOOL ret;
1322
1325 "DeleteUrlCacheEntry returned %x, GetLastError() = %d\n", ret, GetLastError());
1326
1327 myhinternet = InternetOpenA("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
1328 ok((myhinternet != 0), "InternetOpen failed, error %u\n",GetLastError());
1329 size = 0x400;
1331 ok( ret, "InternetCanonicalizeUrl failed, error %u\n",GetLastError());
1332
1333 SetLastError(0);
1334 myhttp = InternetOpenUrlA(myhinternet, TEST_URL, 0, 0,
1337 return; /* WinXP returns this when not connected to the net */
1338 ok((myhttp != 0),"InternetOpenUrl failed, error %u\n",GetLastError());
1339 ret = InternetReadFile(myhttp, buffer,0x400,&readbytes);
1340 ok( ret, "InternetReadFile failed, error %u\n",GetLastError());
1341 totalbytes += readbytes;
1342 while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
1343 totalbytes += readbytes;
1344 trace("read 0x%08x bytes\n",totalbytes);
1345
1346 InternetCloseHandle(myhttp);
1347 InternetCloseHandle(myhinternet);
1348
1350 ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "INTERNET_FLAG_NO_CACHE_WRITE flag doesn't work\n");
1351}
1352
1353static void HttpSendRequestEx_test(void)
1354{
1355 HINTERNET hSession;
1356 HINTERNET hConnect;
1357 HINTERNET hRequest;
1358
1359 INTERNET_BUFFERSA BufferIn;
1360 DWORD dwBytesWritten, dwBytesRead, error;
1361 CHAR szBuffer[256];
1362 int i;
1363 BOOL ret;
1364
1365 static char szPostData[] = "mode=Test";
1366 static const char szContentType[] = "Content-Type: application/x-www-form-urlencoded";
1367
1368 hSession = InternetOpenA("Wine Regression Test",
1370 ok( hSession != NULL ,"Unable to open Internet session\n");
1371 hConnect = InternetConnectA(hSession, "test.winehq.org",
1373 0);
1374 ok( hConnect != NULL, "Unable to connect to http://test.winehq.org\n");
1375 hRequest = HttpOpenRequestA(hConnect, "POST", "/tests/post.php",
1377 if (!hRequest && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)
1378 {
1379 skip( "Network unreachable, skipping test\n" );
1380 goto done;
1381 }
1382 ok( hRequest != NULL, "Failed to open request handle err %u\n", GetLastError());
1383
1385
1386 BufferIn.dwStructSize = sizeof(BufferIn);
1387 BufferIn.Next = (INTERNET_BUFFERSA*)0xdeadcab;
1388 BufferIn.lpcszHeader = szContentType;
1389 BufferIn.dwHeadersLength = sizeof(szContentType)-1;
1390 BufferIn.dwHeadersTotal = sizeof(szContentType)-1;
1391 BufferIn.lpvBuffer = szPostData;
1392 BufferIn.dwBufferLength = 3;
1393 BufferIn.dwBufferTotal = sizeof(szPostData)-1;
1394 BufferIn.dwOffsetLow = 0;
1395 BufferIn.dwOffsetHigh = 0;
1396
1397 SetLastError(0xdeadbeef);
1398 ret = HttpSendRequestExA(hRequest, &BufferIn, NULL, 0 ,0);
1399 error = GetLastError();
1400 ok(ret, "HttpSendRequestEx Failed with error %u\n", error);
1401 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1402
1404
1405 for (i = 3; szPostData[i]; i++)
1406 ok(InternetWriteFile(hRequest, &szPostData[i], 1, &dwBytesWritten),
1407 "InternetWriteFile failed\n");
1408
1410
1411 ok(HttpEndRequestA(hRequest, NULL, 0, 0), "HttpEndRequest Failed\n");
1412
1413 test_request_flags(hRequest, 0);
1414
1415 ok(InternetReadFile(hRequest, szBuffer, 255, &dwBytesRead),
1416 "Unable to read response\n");
1417 szBuffer[dwBytesRead] = 0;
1418
1419 ok(dwBytesRead == 13,"Read %u bytes instead of 13\n",dwBytesRead);
1420 ok(strncmp(szBuffer,"mode => Test\n",dwBytesRead)==0 || broken(proxy_active()),"Got string %s\n",szBuffer);
1421
1422 ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
1423done:
1424 ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
1425 ok(InternetCloseHandle(hSession), "Close session handle failed\n");
1426}
1427
1429{
1431 static const char *types[] = { "*", "", NULL };
1432 static const WCHAR slash[] = {'/', 0}, any[] = {'*', 0}, empty[] = {0};
1433 static const WCHAR *typesW[] = { any, empty, NULL };
1434 BOOL ret;
1435
1436 session = InternetOpenA("Wine Regression Test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
1437 ok(session != NULL ,"Unable to open Internet session\n");
1438
1440 INTERNET_SERVICE_HTTP, 0, 0);
1441 ok(connect == NULL, "InternetConnectA should have failed\n");
1442 ok(GetLastError() == ERROR_INVALID_PARAMETER, "InternetConnectA with NULL server named should have failed with ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
1443
1445 INTERNET_SERVICE_HTTP, 0, 0);
1446 ok(connect == NULL, "InternetConnectA should have failed\n");
1447 ok(GetLastError() == ERROR_INVALID_PARAMETER, "InternetConnectA with blank server named should have failed with ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
1448
1450 INTERNET_SERVICE_HTTP, 0, 0);
1451 ok(connect != NULL, "Unable to connect to http://test.winehq.org with error %d\n", GetLastError());
1452
1455 {
1456 skip( "Network unreachable, skipping test\n" );
1457 goto done;
1458 }
1459 ok(request != NULL, "Failed to open request handle err %u\n", GetLastError());
1460
1462 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
1463 ok(InternetCloseHandle(request), "Close request handle failed\n");
1464
1466 ok(request != NULL, "Failed to open request handle err %u\n", GetLastError());
1467
1469 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
1470 ok(InternetCloseHandle(request), "Close request handle failed\n");
1471
1472done:
1473 ok(InternetCloseHandle(connect), "Close connect handle failed\n");
1474 ok(InternetCloseHandle(session), "Close session handle failed\n");
1475}
1476
1477static void test_cache_read(void)
1478{
1479 HINTERNET session, connection, req;
1480 FILETIME now, tomorrow, yesterday;
1481 BYTE content[1000], buf[2000];
1482 char file_path[MAX_PATH];
1484 HANDLE file;
1485 DWORD size;
1486 unsigned i;
1487 BOOL res;
1488
1489 static const char cache_only_url[] = "http://test.winehq.org/tests/cache-only";
1490 BYTE cache_headers[] = "HTTP/1.1 200 OK\r\n\r\n";
1491
1492 trace("Testing cache read...\n");
1493 reset_events();
1494
1495 for(i = 0; i < sizeof(content); i++)
1496 content[i] = '0' + (i%10);
1497
1499 li.u.HighPart = now.dwHighDateTime;
1500 li.u.LowPart = now.dwLowDateTime;
1501 li.QuadPart += (LONGLONG)10000000 * 3600 * 24;
1502 tomorrow.dwHighDateTime = li.u.HighPart;
1503 tomorrow.dwLowDateTime = li.u.LowPart;
1504 li.QuadPart -= (LONGLONG)10000000 * 3600 * 24 * 2;
1505 yesterday.dwHighDateTime = li.u.HighPart;
1506 yesterday.dwLowDateTime = li.u.LowPart;
1507
1508 res = CreateUrlCacheEntryA(cache_only_url, sizeof(content), "", file_path, 0);
1509 ok(res, "CreateUrlCacheEntryA failed: %u\n", GetLastError());
1510
1512 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
1513
1514 WriteFile(file, content, sizeof(content), &size, NULL);
1516
1517 res = CommitUrlCacheEntryA(cache_only_url, file_path, tomorrow, yesterday, NORMAL_CACHE_ENTRY,
1518 cache_headers, sizeof(cache_headers)-1, "", 0);
1519 ok(res, "CommitUrlCacheEntryA failed: %u\n", GetLastError());
1520
1522 ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError());
1523
1524 pInternetSetStatusCallbackA(session, callback);
1525
1527 connection = InternetConnectA(session, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT,
1528 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
1529 ok(connection != NULL,"InternetConnect failed with error %u\n", GetLastError());
1531
1533 req = HttpOpenRequestA(connection, "GET", "/tests/cache-only", NULL, NULL, NULL, 0, 0xdeadbead);
1534 ok(req != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
1536
1544
1545 res = HttpSendRequestA(req, NULL, -1, NULL, 0);
1546 todo_wine
1547 ok(res, "HttpSendRequest failed: %u\n", GetLastError());
1548
1549 if(res) {
1550 size = 0;
1551 res = InternetQueryDataAvailable(req, &size, 0, 0);
1552 ok(res, "InternetQueryDataAvailable failed: %u\n", GetLastError());
1553 ok(size == sizeof(content), "size = %u\n", size);
1554
1555 size = sizeof(buf);
1556 res = InternetReadFile(req, buf, sizeof(buf), &size);
1557 ok(res, "InternetReadFile failed: %u\n", GetLastError());
1558 ok(size == sizeof(content), "size = %u\n", size);
1559 ok(!memcmp(content, buf, sizeof(content)), "unexpected content\n");
1560 }
1561
1563
1571
1572 res = DeleteUrlCacheEntryA(cache_only_url);
1573 ok(res, "DeleteUrlCacheEntryA failed: %u\n", GetLastError());
1574}
1575
1576static void test_http_cache(void)
1577{
1581 BYTE buf[100];
1582 HANDLE file;
1583 BOOL ret;
1584 FILETIME filetime_zero = {0};
1585
1586 static const char cached_content[] = "data read from cache";
1587 static const char *types[] = { "*", "", NULL };
1588
1589 session = InternetOpenA("Wine Regression Test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
1590 ok(session != NULL ,"Unable to open Internet session\n");
1591
1593 INTERNET_SERVICE_HTTP, 0, 0);
1594 ok(connect != NULL, "Unable to connect to http://test.winehq.org with error %d\n", GetLastError());
1595
1598 {
1599 skip( "Network unreachable, skipping test\n" );
1600
1601 ok(InternetCloseHandle(connect), "Close connect handle failed\n");
1602 ok(InternetCloseHandle(session), "Close session handle failed\n");
1603
1604 return;
1605 }
1606 ok(request != NULL, "Failed to open request handle err %u\n", GetLastError());
1607
1608 size = sizeof(url);
1610 ok(ret, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
1611 ok(!strcmp(url, "http://test.winehq.org/tests/hello.html"), "Wrong URL %s\n", url);
1612
1613 size = sizeof(file_name);
1615 ok(!ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
1616 ok(GetLastError() == ERROR_INTERNET_ITEM_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
1617 ok(!size, "size = %d\n", size);
1618
1620 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
1621
1622 size = sizeof(file_name);
1624 ok(ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed: %u\n", GetLastError());
1625
1628 ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
1630 ok(file_size == 106, "file size = %u\n", file_size);
1631
1632 size = sizeof(buf);
1633 ret = InternetReadFile(request, buf, sizeof(buf), &size);
1634 ok(ret, "InternetReadFile failed: %u\n", GetLastError());
1635 ok(size == 100, "size = %u\n", size);
1636
1638 ok(file_size == 106, "file size = %u\n", file_size);
1640
1642 ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%u)\n", ret, GetLastError());
1643
1644 ok(InternetCloseHandle(request), "Close request handle failed\n");
1645
1648 ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
1649 ret = WriteFile(file, cached_content, sizeof(cached_content), &size, NULL);
1650 ok(ret && size, "WriteFile failed: %d, %d\n", ret, size);
1651 ret = CommitUrlCacheEntryA(url, file_name, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, NULL, 0);
1652 ok(ret, "CommitUrlCacheEntry failed: %d\n", GetLastError());
1654
1655 /* Send the same request, requiring it to be retrieved from the cache */
1656 request = HttpOpenRequestA(connect, "GET", "/tests/hello.html", NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
1657
1659 ok(ret, "HttpSendRequest failed\n");
1660
1661 size = sizeof(buf);
1662 ret = InternetReadFile(request, buf, sizeof(buf), &size);
1663 ok(ret, "InternetReadFile failed: %u\n", GetLastError());
1664 ok(size == 100, "size = %u\n", size);
1665 buf[99] = 0;
1666 todo_wine ok(!strcmp((char*)buf, cached_content), "incorrect page data: %s\n", (char*)buf);
1667
1668 ok(InternetCloseHandle(request), "Close request handle failed\n");
1669
1671 request = HttpOpenRequestA(connect, "GET", "/tests/hello.html", NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
1673 todo_wine ok(!ret, "HttpSendRequest succeeded\n");
1674 if(!ret)
1675 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() = %d\n", GetLastError());
1676 ok(InternetCloseHandle(request), "Close request handle failed\n");
1677
1679 ok(request != NULL, "Failed to open request handle err %u\n", GetLastError());
1680
1681 size = sizeof(file_name);
1683 ok(!ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
1684 ok(GetLastError() == ERROR_INTERNET_ITEM_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
1685 ok(!size, "size = %d\n", size);
1686
1688 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
1689
1690 size = sizeof(file_name);
1691 file_name[0] = 0;
1693 if (ret)
1694 {
1697 ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
1699 }
1700 else
1701 {
1702 /* < IE8 */
1703 ok(file_name[0] == 0, "Didn't expect a file name\n");
1704 }
1705
1706 ok(InternetCloseHandle(request), "Close request handle failed\n");
1707 ok(InternetCloseHandle(connect), "Close connect handle failed\n");
1708 ok(InternetCloseHandle(session), "Close session handle failed\n");
1709
1711}
1712
1714{
1715 char file_name[MAX_PATH];
1716 test_request_t req;
1717 HANDLE lock, lock2;
1718 DWORD size;
1719 BOOL ret;
1720
1721 open_simple_request(&req, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, "/tests/hello.html");
1722
1723 size = sizeof(file_name);
1725 ok(!ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
1726 ok(GetLastError() == ERROR_INTERNET_ITEM_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
1727 ok(!size, "size = %d\n", size);
1728
1729 lock = NULL;
1731 ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "InternetLockRequestFile returned: %x(%u)\n", ret, GetLastError());
1732
1733 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
1734 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
1735
1736 size = sizeof(file_name);
1738 ok(ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed: %u\n", GetLastError());
1739
1741 ok(ret, "InternetLockRequestFile returned: %x(%u)\n", ret, GetLastError());
1742 ok(lock != NULL, "lock == NULL\n");
1743
1744 ret = InternetLockRequestFile(req.request, &lock2);
1745 ok(ret, "InternetLockRequestFile returned: %x(%u)\n", ret, GetLastError());
1746 ok(lock == lock2, "lock != lock2\n");
1747
1749 ok(ret, "InternetUnlockRequestFile failed: %u\n", GetLastError());
1750
1752 ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%u)\n", ret, GetLastError());
1753
1754 ok(InternetCloseHandle(req.request), "Close request handle failed\n");
1755
1757 ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%u)\n", ret, GetLastError());
1758
1760 ok(ret, "InternetUnlockRequestFile failed: %u\n", GetLastError());
1761
1763 ok(ret, "Deleting file returned %x(%u)\n", ret, GetLastError());
1764}
1765
1766static void HttpHeaders_test(void)
1767{
1768 HINTERNET hSession;
1769 HINTERNET hConnect;
1770 HINTERNET hRequest;
1771 CHAR buffer[256];
1772 WCHAR wbuffer[256];
1773 DWORD len = 256;
1774 DWORD oldlen;
1775 DWORD index = 0;
1776 BOOL ret;
1777
1778 hSession = InternetOpenA("Wine Regression Test",
1780 ok( hSession != NULL ,"Unable to open Internet session\n");
1781 hConnect = InternetConnectA(hSession, "test.winehq.org",
1783 0);
1784 ok( hConnect != NULL, "Unable to connect to http://test.winehq.org\n");
1785 hRequest = HttpOpenRequestA(hConnect, "POST", "/tests/post.php",
1787 if (!hRequest && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)
1788 {
1789 skip( "Network unreachable, skipping test\n" );
1790 goto done;
1791 }
1792 ok( hRequest != NULL, "Failed to open request handle\n");
1793
1794 index = 0;
1795 len = sizeof(buffer);
1796 strcpy(buffer,"Warning");
1798 buffer,&len,&index)==0,"Warning hearder reported as Existing\n");
1799
1800 ok(HttpAddRequestHeadersA(hRequest,"Warning:test1",-1,HTTP_ADDREQ_FLAG_ADD),
1801 "Failed to add new header\n");
1802
1803 index = 0;
1804 len = sizeof(buffer);
1805 strcpy(buffer,"Warning");
1807 buffer,&len,&index),"Unable to query header\n");
1808 ok(index == 1, "Index was not incremented\n");
1809 ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
1810 ok(len == 5, "Invalid length (exp. 5, got %d)\n", len);
1811 ok((len < sizeof(buffer)) && (buffer[len] == 0), "Buffer not NULL-terminated\n"); /* len show only 5 characters but the buffer is NULL-terminated*/
1812 len = sizeof(buffer);
1813 strcpy(buffer,"Warning");
1815 buffer,&len,&index)==0,"Second Index Should Not Exist\n");
1816
1817 index = 0;
1818 len = 5; /* could store the string but not the NULL terminator */
1819 strcpy(buffer,"Warning");
1821 buffer,&len,&index) == FALSE,"Query succeeded on a too small buffer\n");
1822 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
1823 ok(index == 0, "Index was incremented\n");
1824 ok(strcmp(buffer,"Warning")==0, "incorrect string was returned(%s)\n",buffer); /* string not touched */
1825 ok(len == 6, "Invalid length (exp. 6, got %d)\n", len); /* unlike success, the length includes the NULL-terminator */
1826
1827 /* a call with NULL will fail but will return the length */
1828 index = 0;
1829 len = sizeof(buffer);
1830 SetLastError(0xdeadbeef);
1832 NULL,&len,&index) == FALSE,"Query worked\n");
1833 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
1834 ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
1835 ok(index == 0, "Index was incremented\n");
1836
1837 /* even for a len that is too small */
1838 index = 0;
1839 len = 15;
1840 SetLastError(0xdeadbeef);
1842 NULL,&len,&index) == FALSE,"Query worked\n");
1843 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
1844 ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
1845 ok(index == 0, "Index was incremented\n");
1846
1847 index = 0;
1848 len = 0;
1849 SetLastError(0xdeadbeef);
1851 NULL,&len,&index) == FALSE,"Query worked\n");
1852 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
1853 ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
1854 ok(index == 0, "Index was incremented\n");
1855 oldlen = len; /* bytes; at least long enough to hold buffer & nul */
1856
1857
1858 /* a working query */
1859 index = 0;
1860 len = sizeof(buffer);
1861 memset(buffer, 'x', sizeof(buffer));
1863 buffer,&len,&index),"Unable to query header\n");
1864 ok(len + sizeof(CHAR) <= oldlen, "Result longer than advertised\n");
1865 ok((len < sizeof(buffer)-sizeof(CHAR)) && (buffer[len/sizeof(CHAR)] == 0),"No NUL at end\n");
1866 ok(len == strlen(buffer) * sizeof(CHAR), "Length wrong\n");
1867 /* what's in the middle differs between Wine and Windows so currently we check only the beginning and the end */
1868 ok(strncmp(buffer, "POST /tests/post.php HTTP/1", 25)==0, "Invalid beginning of headers string\n");
1869 ok(strcmp(buffer + strlen(buffer) - 4, "\r\n\r\n")==0, "Invalid end of headers string\n");
1870 ok(index == 0, "Index was incremented\n");
1871
1872 /* Like above two tests, but for W version */
1873
1874 index = 0;
1875 len = 0;
1876 SetLastError(0xdeadbeef);
1878 NULL,&len,&index) == FALSE,"Query worked\n");
1879 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
1880 ok(len > 80, "Invalid length (exp. more than 80, got %d)\n", len);
1881 ok(index == 0, "Index was incremented\n");
1882 oldlen = len; /* bytes; at least long enough to hold buffer & nul */
1883
1884 /* a working query */
1885 index = 0;
1886 len = sizeof(wbuffer);
1887 memset(wbuffer, 'x', sizeof(wbuffer));
1889 wbuffer,&len,&index),"Unable to query header\n");
1890 ok(len + sizeof(WCHAR) <= oldlen, "Result longer than advertised\n");
1891 ok(len == lstrlenW(wbuffer) * sizeof(WCHAR), "Length wrong\n");
1892 ok((len < sizeof(wbuffer)-sizeof(WCHAR)) && (wbuffer[len/sizeof(WCHAR)] == 0),"No NUL at end\n");
1893 ok(index == 0, "Index was incremented\n");
1894
1895 /* end of W version tests */
1896
1897 /* Without HTTP_QUERY_FLAG_REQUEST_HEADERS */
1898 index = 0;
1899 len = sizeof(buffer);
1900 memset(buffer, 'x', sizeof(buffer));
1902 buffer,&len,&index) == TRUE,"Query failed\n");
1903 ok(len == 2 || len == 4 /* win10 */, "Expected 2 or 4, got %d\n", len);
1904 ok(memcmp(buffer, "\r\n\r\n", len) == 0, "Expected CRLF, got '%s'\n", buffer);
1905 ok(index == 0, "Index was incremented\n");
1906
1907 ok(HttpAddRequestHeadersA(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
1908 "Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
1909
1910 index = 0;
1911 len = sizeof(buffer);
1912 strcpy(buffer,"Warning");
1914 buffer,&len,&index),"Unable to query header\n");
1915 ok(index == 1, "Index was not incremented\n");
1916 ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
1917 len = sizeof(buffer);
1918 strcpy(buffer,"Warning");
1920 buffer,&len,&index),"Failed to get second header\n");
1921 ok(index == 2, "Index was not incremented\n");
1922 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
1923 len = sizeof(buffer);
1924 strcpy(buffer,"Warning");
1926 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1927
1928 ok(HttpAddRequestHeadersA(hRequest,"Warning:test3",-1,HTTP_ADDREQ_FLAG_REPLACE), "Failed to replace header using HTTP_ADDREQ_FLAG_REPLACE\n");
1929
1930 index = 0;
1931 len = sizeof(buffer);
1932 strcpy(buffer,"Warning");
1934 buffer,&len,&index),"Unable to query header\n");
1935 ok(index == 1, "Index was not incremented\n");
1936 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
1937 len = sizeof(buffer);
1938 strcpy(buffer,"Warning");
1940 buffer,&len,&index),"Failed to get second header\n");
1941 ok(index == 2, "Index was not incremented\n");
1942 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1943 len = sizeof(buffer);
1944 strcpy(buffer,"Warning");
1946 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1947
1948 ok(HttpAddRequestHeadersA(hRequest,"Warning:test4",-1,HTTP_ADDREQ_FLAG_ADD_IF_NEW)==0, "HTTP_ADDREQ_FLAG_ADD_IF_NEW replaced existing header\n");
1949
1950 index = 0;
1951 len = sizeof(buffer);
1952 strcpy(buffer,"Warning");
1954 buffer,&len,&index),"Unable to query header\n");
1955 ok(index == 1, "Index was not incremented\n");
1956 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
1957 len = sizeof(buffer);
1958 strcpy(buffer,"Warning");
1960 buffer,&len,&index),"Failed to get second header\n");
1961 ok(index == 2, "Index was not incremented\n");
1962 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1963 len = sizeof(buffer);
1964 strcpy(buffer,"Warning");
1966 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1967
1968 ok(HttpAddRequestHeadersA(hRequest,"Warning:test4",-1, HTTP_ADDREQ_FLAG_COALESCE), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
1969
1970 index = 0;
1971 len = sizeof(buffer);
1972 strcpy(buffer,"Warning");
1974 buffer,&len,&index),"Unable to query header\n");
1975 ok(index == 1, "Index was not incremented\n");
1976 ok(strcmp(buffer,"test2, test4")==0, "incorrect string was returned(%s)\n", buffer);
1977 len = sizeof(buffer);
1978 strcpy(buffer,"Warning");
1979 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
1980 ok(index == 2, "Index was not incremented\n");
1981 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1982 len = sizeof(buffer);
1983 strcpy(buffer,"Warning");
1984 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1985
1986 ok(HttpAddRequestHeadersA(hRequest,"Warning:test5",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
1987
1988 index = 0;
1989 len = sizeof(buffer);
1990 strcpy(buffer,"Warning");
1991 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
1992 ok(index == 1, "Index was not incremented\n");
1993 ok(strcmp(buffer,"test2, test4, test5")==0, "incorrect string was returned(%s)\n",buffer);
1994 len = sizeof(buffer);
1995 strcpy(buffer,"Warning");
1996 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
1997 ok(index == 2, "Index was not incremented\n");
1998 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1999 len = sizeof(buffer);
2000 strcpy(buffer,"Warning");
2001 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2002
2003 ok(HttpAddRequestHeadersA(hRequest,"Warning:test6",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
2004
2005 index = 0;
2006 len = sizeof(buffer);
2007 strcpy(buffer,"Warning");
2008 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2009 ok(index == 1, "Index was not incremented\n");
2010 ok(strcmp(buffer,"test2, test4, test5; test6")==0, "incorrect string was returned(%s)\n",buffer);
2011 len = sizeof(buffer);
2012 strcpy(buffer,"Warning");
2013 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
2014 ok(index == 2, "Index was not incremented\n");
2015 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
2016 len = sizeof(buffer);
2017 strcpy(buffer,"Warning");
2018 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2019
2020 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");
2021
2022 index = 0;
2023 len = sizeof(buffer);
2024 strcpy(buffer,"Warning");
2025 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2026 ok(index == 1, "Index was not incremented\n");
2027 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
2028 len = sizeof(buffer);
2029 strcpy(buffer,"Warning");
2030 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
2031 ok(index == 2, "Index was not incremented\n");
2032 ok(strcmp(buffer,"test7")==0, "incorrect string was returned(%s)\n",buffer);
2033 len = sizeof(buffer);
2034 strcpy(buffer,"Warning");
2035 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2036
2037 /* Ensure that blank headers are ignored and don't cause a failure */
2038 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");
2039
2040 index = 0;
2041 len = sizeof(buffer);
2042 strcpy(buffer,"BlankTest");
2043 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2044 ok(index == 1, "Index was not incremented\n");
2045 ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
2046
2047 /* Ensure that malformed header separators are ignored and don't cause a failure */
2048 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),
2049 "Failed to add header with malformed entries in list\n");
2050
2051 index = 0;
2052 len = sizeof(buffer);
2053 strcpy(buffer,"MalformedTest");
2054 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2055 ok(index == 1, "Index was not incremented\n");
2056 ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
2057 index = 0;
2058 len = sizeof(buffer);
2059 strcpy(buffer,"MalformedTestTwo");
2060 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2061 ok(index == 1, "Index was not incremented\n");
2062 ok(strcmp(buffer,"value2")==0, "incorrect string was returned(%s)\n",buffer);
2063 index = 0;
2064 len = sizeof(buffer);
2065 strcpy(buffer,"MalformedTestThree");
2066 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2067 ok(index == 1, "Index was not incremented\n");
2068 ok(strcmp(buffer,"value3")==0, "incorrect string was returned(%s)\n",buffer);
2069
2070 ret = HttpAddRequestHeadersA(hRequest, "Authorization: Basic\r\n", -1, HTTP_ADDREQ_FLAG_ADD);
2071 ok(ret, "unable to add header %u\n", GetLastError());
2072
2073 index = 0;
2074 buffer[0] = 0;
2075 len = sizeof(buffer);
2077 ok(ret, "unable to query header %u\n", GetLastError());
2078 ok(index == 1, "index was not incremented\n");
2079 ok(!strcmp(buffer, "Basic"), "incorrect string was returned (%s)\n", buffer);
2080
2081 ret = HttpAddRequestHeadersA(hRequest, "Authorization:\r\n", -1, HTTP_ADDREQ_FLAG_REPLACE);
2082 ok(ret, "unable to remove header %u\n", GetLastError());
2083
2084 index = 0;
2085 len = sizeof(buffer);
2086 SetLastError(0xdeadbeef);
2088 "header still present\n");
2090
2091 ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
2092done:
2093 ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
2094 ok(InternetCloseHandle(hSession), "Close session handle failed\n");
2095}
2096
2097static const char garbagemsg[] =
2098"Garbage: Header\r\n";
2099
2100static const char contmsg[] =
2101"HTTP/1.1 100 Continue\r\n";
2102
2103static const char expandcontmsg[] =
2104"HTTP/1.1 100 Continue\r\n"
2105"Server: winecontinue\r\n"
2106"Tag: something witty\r\n";
2107
2108static const char okmsg[] =
2109"HTTP/1.1 200 OK\r\n"
2110"Server: winetest\r\n"
2111"\r\n";
2112
2113static const char okmsg201[] =
2114"HTTP/1.1 201 OK\r\n"
2115"Server: winetest\r\n"
2116"\r\n";
2117
2118static const char okmsg2[] =
2119"HTTP/1.1 200 OK\r\n"
2120"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n"
2121"Server: winetest\r\n"
2122"Content-Length: 0\r\n"
2123"Set-Cookie: one\r\n"
2124"Set-Cookie: two\r\n"
2125"\r\n";
2126
2128static const char largemsg[] =
2129"HTTP/1.1 200 OK\r\n"
2130"Content-Length: %I64u\r\n"
2131"\r\n";
2132
2133static const char okmsg_cookie_path[] =
2134"HTTP/1.1 200 OK\r\n"
2135"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n"
2136"Server: winetest\r\n"
2137"Content-Length: 0\r\n"
2138"Set-Cookie: subcookie2=data; path=/test_cookie_set_path\r\n"
2139"\r\n";
2140
2141static const char okmsg_cookie[] =
2142"HTTP/1.1 200 OK\r\n"
2143"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n"
2144"Server: winetest\r\n"
2145"Content-Length: 0\r\n"
2146"Set-Cookie: testcookie=testvalue\r\n"
2147"\r\n";
2148
2149static const char notokmsg[] =
2150"HTTP/1.1 400 Bad Request\r\n"
2151"Server: winetest\r\n"
2152"\r\n";
2153
2154static const char noauthmsg[] =
2155"HTTP/1.1 401 Unauthorized\r\n"
2156"Server: winetest\r\n"
2157"Connection: close\r\n"
2158"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
2159"\r\n";
2160
2161static const char noauthmsg2[] =
2162"HTTP/1.0 401 Anonymous requests or requests on unsecure channel are not allowed\r\n"
2163"HTTP/1.0 401 Anonymous requests or requests on unsecure channel are not allowed"
2164"\0d`0|6\n"
2165"Server: winetest\r\n";
2166
2167static const char proxymsg[] =
2168"HTTP/1.1 407 Proxy Authentication Required\r\n"
2169"Server: winetest\r\n"
2170"Proxy-Connection: close\r\n"
2171"Proxy-Authenticate: Basic realm=\"placebo\"\r\n"
2172"\r\n";
2173
2174static const char page1[] =
2175"<HTML>\r\n"
2176"<HEAD><TITLE>wininet test page</TITLE></HEAD>\r\n"
2177"<BODY>The quick brown fox jumped over the lazy dog<P></BODY>\r\n"
2178"</HTML>\r\n\r\n";
2179
2180static const char ok_with_length[] =
2181"HTTP/1.1 200 OK\r\n"
2182"Connection: Keep-Alive\r\n"
2183"Content-Length: 18\r\n\r\n"
2184"HTTP/1.1 211 OK\r\n\r\n";
2185
2186static const char ok_with_length2[] =
2187"HTTP/1.1 210 OK\r\n"
2188"Connection: Keep-Alive\r\n"
2189"Content-Length: 19\r\n\r\n"
2190"HTTP/1.1 211 OK\r\n\r\n";
2191
2192struct server_info {
2194 int port;
2195};
2196
2198static const char *send_buffer;
2199static int server_socket;
2200
2202{
2203 struct server_info *si = param;
2204 int r, c = -1, i, on, count = 0;
2205 SOCKET s;
2206 struct sockaddr_in sa;
2207 char *buffer;
2208 size_t buffer_size;
2209 WSADATA wsaData;
2210 int last_request = 0;
2211 char host_header[22];
2212 char host_header_override[30];
2213 static int test_no_cache = 0;
2214
2215 WSAStartup(MAKEWORD(1,1), &wsaData);
2216
2217 s = socket(AF_INET, SOCK_STREAM, 0);
2218 if (s == INVALID_SOCKET)
2219 return 1;
2220
2221 on = 1;
2222 setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof on);
2223
2224 memset(&sa, 0, sizeof sa);
2225 sa.sin_family = AF_INET;
2226 sa.sin_port = htons(si->port);
2227 sa.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
2228
2229 r = bind(s, (struct sockaddr*) &sa, sizeof sa);
2230 if (r<0)
2231 return 1;
2232
2233 listen(s, 0);
2234
2235 SetEvent(si->hEvent);
2236
2237 sprintf(host_header, "Host: localhost:%d", si->port);
2238 sprintf(host_header_override, "Host: test.local:%d\r\n", si->port);
2240
2241 do
2242 {
2243 if(c == -1)
2244 c = accept(s, NULL, NULL);
2245
2247 for(i=0;; i++)
2248 {
2249 if(i == buffer_size)
2251
2252 r = recv(c, buffer+i, 1, 0);
2253 if (r != 1)
2254 break;
2255 if (i<4) continue;
2256 if (buffer[i-2] == '\n' && buffer[i] == '\n' &&
2257 buffer[i-3] == '\r' && buffer[i-1] == '\r')
2258 break;
2259 }
2260 if (strstr(buffer, "GET /test1"))
2261 {
2262 if (!strstr(buffer, "Content-Length: 0"))
2263 {
2264 send(c, okmsg, sizeof okmsg-1, 0);
2265 send(c, page1, sizeof page1-1, 0);
2266 }
2267 else
2268 send(c, notokmsg, sizeof notokmsg-1, 0);
2269 }
2270 if (strstr(buffer, "CONNECT "))
2271 {
2272 if (!strstr(buffer, "Content-Length: 0"))
2273 send(c, notokmsg, sizeof notokmsg-1, 0);
2274 else
2275 send(c, proxymsg, sizeof proxymsg-1, 0);
2276 }
2277 if (strstr(buffer, "/test2"))
2278 {
2279 if (strstr(buffer, "Proxy-Authorization: Basic bWlrZToxMTAx"))
2280 {
2281 send(c, okmsg, sizeof okmsg-1, 0);
2282 send(c, page1, sizeof page1-1, 0);
2283 }
2284 else
2285 send(c, proxymsg, sizeof proxymsg-1, 0);
2286 }
2287 if (strstr(buffer, "/test3"))
2288 {
2289 if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2290 send(c, okmsg, sizeof okmsg-1, 0);
2291 else
2292 send(c, noauthmsg, sizeof noauthmsg-1, 0);
2293 }
2294 if (strstr(buffer, "/test4"))
2295 {
2296 if (strstr(buffer, "Connection: Close"))
2297 send(c, okmsg, sizeof okmsg-1, 0);
2298 else
2299 send(c, notokmsg, sizeof notokmsg-1, 0);
2300 }
2301 if (strstr(buffer, "POST /test5") ||
2302 strstr(buffer, "RPC_IN_DATA /test5") ||
2303 strstr(buffer, "RPC_OUT_DATA /test5"))
2304 {
2305 if (strstr(buffer, "Content-Length: 0"))
2306 {
2307 send(c, okmsg, sizeof okmsg-1, 0);
2308 send(c, page1, sizeof page1-1, 0);
2309 }
2310 else
2311 send(c, notokmsg, sizeof notokmsg-1, 0);
2312 }
2313 if (strstr(buffer, "GET /test6"))
2314 {
2315 send(c, contmsg, sizeof contmsg-1, 0);
2316 send(c, contmsg, sizeof contmsg-1, 0);
2317 send(c, okmsg, sizeof okmsg-1, 0);
2318 send(c, page1, sizeof page1-1, 0);
2319 }
2320 if (strstr(buffer, "POST /test7"))
2321 {
2322 if (strstr(buffer, "Content-Length: 100"))
2323 {
2324 if (strstr(buffer, "POST /test7b"))
2326 send(c, okmsg, sizeof okmsg-1, 0);
2327 send(c, page1, sizeof page1-1, 0);
2328 }
2329 else
2330 send(c, notokmsg, sizeof notokmsg-1, 0);
2331 }
2332 if (strstr(buffer, "/test8"))
2333 {
2334 if (!strstr(buffer, "Connection: Close") &&
2335 strstr(buffer, "Connection: Keep-Alive") &&
2336 !strstr(buffer, "Cache-Control: no-cache") &&
2337 !strstr(buffer, "Pragma: no-cache") &&
2338 strstr(buffer, host_header))
2339 send(c, okmsg, sizeof okmsg-1, 0);
2340 else
2341 send(c, notokmsg, sizeof notokmsg-1, 0);
2342 }
2343 if (strstr(buffer, "/test9"))
2344 {
2345 if (!strstr(buffer, "Connection: Close") &&
2346 !strstr(buffer, "Connection: Keep-Alive") &&
2347 !strstr(buffer, "Cache-Control: no-cache") &&
2348 !strstr(buffer, "Pragma: no-cache") &&
2349 strstr(buffer, host_header))
2350 send(c, okmsg, sizeof okmsg-1, 0);
2351 else
2352 send(c, notokmsg, sizeof notokmsg-1, 0);
2353 }
2354 if (strstr(buffer, "/testA"))
2355 {
2356 if (!strstr(buffer, "Connection: Close") &&
2357 !strstr(buffer, "Connection: Keep-Alive") &&
2358 (strstr(buffer, "Cache-Control: no-cache") ||
2359 strstr(buffer, "Pragma: no-cache")) &&
2360 strstr(buffer, host_header))
2361 send(c, okmsg, sizeof okmsg-1, 0);
2362 else
2363 send(c, notokmsg, sizeof notokmsg-1, 0);
2364 }
2365 if (strstr(buffer, "/testC"))
2366 {
2367 if (strstr(buffer, "cookie=biscuit"))
2368 send(c, okmsg, sizeof okmsg-1, 0);
2369 else
2370 send(c, notokmsg, sizeof notokmsg-1, 0);
2371 }
2372 if (strstr(buffer, "/testD"))
2373 {
2374 send(c, okmsg2, sizeof okmsg2-1, 0);
2375 }
2376 if (strstr(buffer, "/testE"))
2377 {
2378 send(c, noauthmsg2, sizeof noauthmsg2-1, 0);
2379 }
2380 if (strstr(buffer, "GET /quit"))
2381 {
2382 send(c, okmsg, sizeof okmsg-1, 0);
2383 send(c, page1, sizeof page1-1, 0);
2384 last_request = 1;
2385 }
2386 if (strstr(buffer, "GET /testF"))
2387 {
2388 send(c, expandcontmsg, sizeof expandcontmsg-1, 0);
2389 send(c, garbagemsg, sizeof garbagemsg-1, 0);
2390 send(c, contmsg, sizeof contmsg-1, 0);
2391 send(c, garbagemsg, sizeof garbagemsg-1, 0);
2392 send(c, okmsg, sizeof okmsg-1, 0);
2393 send(c, page1, sizeof page1-1, 0);
2394 }
2395 if (strstr(buffer, "GET /testG"))
2396 {
2397 send(c, page1, sizeof page1-1, 0);
2398 }
2399
2400 if (strstr(buffer, "GET /testJ"))
2401 {
2402 if (count == 0)
2403 {
2404 count++;
2405 send(c, ok_with_length, sizeof(ok_with_length)-1, 0);
2406 }
2407 else
2408 {
2409 send(c, ok_with_length2, sizeof(ok_with_length2)-1, 0);
2410 count = 0;
2411 }
2412 }
2413 if (strstr(buffer, "GET /testH"))
2414 {
2415 send(c, ok_with_length2, sizeof(ok_with_length2)-1, 0);
2417 send(c, ok_with_length, sizeof(ok_with_length)-1, 0);
2418 }
2419
2420 if (strstr(buffer, "GET /test_no_content"))
2421 {
2422 static const char nocontentmsg[] = "HTTP/1.1 204 No Content\r\nConnection: close\r\n\r\n";
2423 send(c, nocontentmsg, sizeof(nocontentmsg)-1, 0);
2424 }
2425 if (strstr(buffer, "GET /test_conn_close"))
2426 {
2427 static const char conn_close_response[] = "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\nsome content";
2428 send(c, conn_close_response, sizeof(conn_close_response)-1, 0);
2430 trace("closing connection\n");
2431 }
2432 if (strstr(buffer, "GET /test_cache_control_no_cache"))
2433 {
2434 static const char no_cache_response[] = "HTTP/1.1 200 OK\r\nCache-Control: no-cache\r\n\r\nsome content";
2435 if(!test_no_cache++)
2436 send(c, no_cache_response, sizeof(no_cache_response)-1, 0);
2437 else
2438 send(c, okmsg, sizeof(okmsg)-1, 0);
2439 }
2440 if (strstr(buffer, "GET /test_cache_control_no_store"))
2441 {
2442 static const char no_cache_response[] = "HTTP/1.1 200 OK\r\nCache-Control: junk, \t No-StOrE\r\n\r\nsome content";
2443 send(c, no_cache_response, sizeof(no_cache_response)-1, 0);
2444 }
2445 if (strstr(buffer, "GET /test_cache_gzip"))
2446 {
2447 static const char gzip_response[] = "HTTP/1.1 200 OK\r\nContent-Encoding: gzip\r\nContent-Type: text/html\r\n\r\n"
2448 "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x4b\xaf\xca\x2c\x50\x28"
2449 "\x49\x2d\x2e\xe1\x02\x00\x62\x92\xc7\x6c\x0a\x00\x00\x00";
2450 if(!test_cache_gzip++)
2451 send(c, gzip_response, sizeof(gzip_response), 0);
2452 else
2453 send(c, notokmsg, sizeof(notokmsg)-1, 0);
2454 }
2455 if (strstr(buffer, "HEAD /test_head")) {
2456 static const char head_response[] =
2457 "HTTP/1.1 200 OK\r\n"
2458 "Connection: Keep-Alive\r\n"
2459 "Content-Length: 100\r\n"
2460 "\r\n";
2461
2462 send(c, head_response, sizeof(head_response), 0);
2463 continue;
2464 }
2465 if (strstr(buffer, "GET /send_from_buffer"))
2467 if (strstr(buffer, "/test_cache_control_verb"))
2468 {
2469 if (!memcmp(buffer, "GET ", sizeof("GET ")-1) &&
2470 !strstr(buffer, "Cache-Control: no-cache\r\n")) send(c, okmsg, sizeof(okmsg)-1, 0);
2471 else if (strstr(buffer, "Cache-Control: no-cache\r\n")) send(c, okmsg, sizeof(okmsg)-1, 0);
2472 else send(c, notokmsg, sizeof(notokmsg)-1, 0);
2473 }
2474 if (strstr(buffer, "/test_request_content_length"))
2475 {
2476 static char msg[] = "HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\n\r\n";
2477 static int seen_content_length;
2478
2479 if (!seen_content_length)
2480 {
2481 if (strstr(buffer, "Content-Length: 0"))
2482 {
2483 seen_content_length = 1;
2484 send(c, msg, sizeof msg-1, 0);
2485 }
2486 else send(c, notokmsg, sizeof notokmsg-1, 0);
2488 }
2489 else
2490 {
2491 if (strstr(buffer, "Content-Length: 0")) send(c, msg, sizeof msg-1, 0);
2492 else send(c, notokmsg, sizeof notokmsg-1, 0);
2494 }
2495 }
2496 if (strstr(buffer, "GET /test_premature_disconnect"))
2497 trace("closing connection\n");
2498 if (strstr(buffer, "HEAD /upload.txt"))
2499 {
2500 if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2501 send(c, okmsg, sizeof okmsg-1, 0);
2502 else
2503 send(c, noauthmsg, sizeof noauthmsg-1, 0);
2504 }
2505 if (strstr(buffer, "PUT /upload2.txt"))
2506 {
2507 if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2508 send(c, okmsg, sizeof okmsg-1, 0);
2509 else
2510 send(c, notokmsg, sizeof notokmsg-1, 0);
2511 }
2512 if (strstr(buffer, "HEAD /upload3.txt"))
2513 {
2514 if (strstr(buffer, "Authorization: Basic dXNlcjE6cHdkMQ=="))
2515 send(c, okmsg, sizeof okmsg-1, 0);
2516 else
2517 send(c, noauthmsg, sizeof noauthmsg-1, 0);
2518 }
2519 if (strstr(buffer, "HEAD /upload4.txt"))
2520 {
2521 if (strstr(buffer, "Authorization: Bearer dXNlcjE6cHdkMQ=="))
2522 send(c, okmsg, sizeof okmsg-1, 0);
2523 else if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2524 send(c, okmsg201, sizeof okmsg-1, 0);
2525 else
2526 send(c, noauthmsg, sizeof noauthmsg-1, 0);
2527 }
2528 if (strstr(buffer, "/test_cookie_path1"))
2529 {
2530 if (strstr(buffer, "subcookie=data"))
2531 send(c, okmsg, sizeof okmsg-1, 0);
2532 else
2533 send(c, notokmsg, sizeof notokmsg-1, 0);
2534 }
2535 if (strstr(buffer, "/test_cookie_path2"))
2536 {
2537 if (strstr(buffer, "subcookie2=data"))
2538 send(c, okmsg, sizeof okmsg-1, 0);
2539 else
2540 send(c, notokmsg, sizeof notokmsg-1, 0);
2541 }
2542 if (strstr(buffer, "/test_cookie_set_path"))
2543 {
2545 }
2546 if (strstr(buffer, "/test_cookie_merge"))
2547 {
2548 if (strstr(buffer, "subcookie=data") &&
2549 !strstr(buffer, "manual_cookie=test"))
2550 send(c, okmsg, sizeof okmsg-1, 0);
2551 else
2552 send(c, notokmsg, sizeof notokmsg-1, 0);
2553 }
2554 if (strstr(buffer, "/test_cookie_set_host_override"))
2555 {
2556 send(c, okmsg_cookie, sizeof okmsg_cookie-1, 0);
2557 }
2558 if (strstr(buffer, "/test_cookie_check_host_override"))
2559 {
2560 if (strstr(buffer, "Cookie:") && strstr(buffer, "testcookie=testvalue"))
2561 send(c, okmsg, sizeof okmsg-1, 0);
2562 else
2563 send(c, notokmsg, sizeof notokmsg-1, 0);
2564 }
2565 if (strstr(buffer, "/test_cookie_check_different_host"))
2566 {
2567 if (!strstr(buffer, "foo") &&
2568 strstr(buffer, "cookie=biscuit"))
2569 send(c, okmsg, sizeof okmsg-1, 0);
2570 else
2571 send(c, notokmsg, sizeof notokmsg-1, 0);
2572 }
2573 if (strstr(buffer, "/test_host_override"))
2574 {
2575 if (strstr(buffer, host_header_override))
2576 send(c, okmsg, sizeof okmsg-1, 0);
2577 else
2578 send(c, notokmsg, sizeof notokmsg-1, 0);
2579 }
2580 if (strstr(buffer, "/async_read"))
2581 {
2582 const char *page1_mid = page1 + (sizeof page1 - 1)/2;
2583 const char *page1_end = page1 + sizeof page1 - 1;
2584 send(c, okmsg, sizeof okmsg-1, 0);
2585 send(c, page1, page1_mid - page1, 0);
2587 send(c, page1_mid, page1_end - page1_mid, 0);
2588 }
2589 if (strstr(buffer, "/socket"))
2590 {
2591 server_socket = c;
2594 }
2595 if (strstr(buffer, "/echo_request"))
2596 {
2597 send(c, okmsg, sizeof(okmsg)-1, 0);
2598 send(c, buffer, strlen(buffer), 0);
2599 }
2600 if (strstr(buffer, "GET /test_remove_dot_segments"))
2601 {
2602 send(c, okmsg, sizeof(okmsg)-1, 0);
2603 }
2604
2605 if (strstr(buffer, "HEAD /test_large_content"))
2606 {
2607 char msg[sizeof(largemsg) + 16];
2609 send(c, msg, strlen(msg), 0);
2610 }
2611 if (strstr(buffer, "HEAD /test_auth_host1"))
2612 {
2613 if (strstr(buffer, "Authorization: Basic dGVzdDE6cGFzcw=="))
2614 send(c, okmsg, sizeof okmsg-1, 0);
2615 else
2616 send(c, noauthmsg, sizeof noauthmsg-1, 0);
2617 }
2618 if (strstr(buffer, "HEAD /test_auth_host2"))
2619 {
2620 if (strstr(buffer, "Authorization: Basic dGVzdDE6cGFzczI="))
2621 send(c, okmsg, sizeof okmsg-1, 0);
2622 else
2623 send(c, noauthmsg, sizeof noauthmsg-1, 0);
2624 }
2625 shutdown(c, 2);
2626 closesocket(c);
2627 c = -1;
2628 } while (!last_request);
2629
2630 closesocket(s);
2632
2633 return 0;
2634}
2635
2636static void test_basic_request(int port, const char *verb, const char *url)
2637{
2638 test_request_t req;
2639 DWORD r, count, error;
2640 char buffer[0x100];
2641
2642 trace("basic request %s %s\n", verb, url);
2643
2644 open_simple_request(&req, "localhost", port, verb, url);
2645
2646 SetLastError(0xdeadbeef);
2647 r = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
2648 error = GetLastError();
2649 ok(error == ERROR_SUCCESS || broken(error != ERROR_SUCCESS), "expected ERROR_SUCCESS, got %u\n", error);
2650 ok(r, "HttpSendRequest failed: %u\n", GetLastError());
2651
2652 count = 0;
2653 memset(buffer, 0, sizeof buffer);
2654 SetLastError(0xdeadbeef);
2655 r = InternetReadFile(req.request, buffer, sizeof buffer, &count);
2656 ok(r, "InternetReadFile failed %u\n", GetLastError());
2657 ok(count == sizeof page1 - 1, "count was wrong\n");
2658 ok(!memcmp(buffer, page1, sizeof page1), "http data wrong, got: %s\n", buffer);
2659
2660 close_request(&req);
2661}
2662
2664{
2665 test_request_t req;
2666 DWORD r, sz;
2667 char buffer[0x40];
2668
2669 open_simple_request(&req, "localhost", port, NULL, "/test2");
2670
2671 r = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
2672 ok(r, "HttpSendRequest failed %u\n", GetLastError());
2673
2674 sz = sizeof buffer;
2676 ok(r || GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo failed: %d\n", GetLastError());
2677 if (!r)
2678 {
2679 skip("missing proxy header, not testing remaining proxy headers\n");
2680 goto out;
2681 }
2682 ok(!strcmp(buffer, "Basic realm=\"placebo\""), "proxy auth info wrong\n");
2683
2684 test_status_code(req.request, 407);
2686
2687 sz = sizeof buffer;
2689 ok(r, "HttpQueryInfo failed\n");
2690 ok(!strcmp(buffer, "Proxy Authentication Required"), "proxy text wrong\n");
2691
2692 sz = sizeof buffer;
2694 ok(r, "HttpQueryInfo failed\n");
2695 ok(!strcmp(buffer, "HTTP/1.1"), "http version wrong\n");
2696
2697 sz = sizeof buffer;
2699 ok(r, "HttpQueryInfo failed\n");
2700 ok(!strcmp(buffer, "winetest"), "http server wrong\n");
2701
2702 sz = sizeof buffer;
2704 ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo should fail\n");
2705 ok(r == FALSE, "HttpQueryInfo failed\n");
2706
2707out:
2708 close_request(&req);
2709}
2710
2711static void test_proxy_direct(int port)
2712{
2713 HINTERNET hi, hc, hr;
2714 DWORD r, sz, error;
2715 char buffer[0x40], *url;
2716 WCHAR bufferW[0x40];
2717 static const char url_fmt[] = "http://test.winehq.org:%u/test2";
2718 static CHAR username[] = "mike",
2719 password[] = "1101",
2720 useragent[] = "winetest";
2721 static const WCHAR usernameW[] = {'m','i','k','e',0},
2722 passwordW[] = {'1','1','0','1',0},
2723 useragentW[] = {'w','i','n','e','t','e','s','t',0};
2724
2725 /* specify proxy type without the proxy and bypass */
2726 SetLastError(0xdeadbeef);
2728 error = GetLastError();
2730 broken(error == ERROR_SUCCESS) /* WinXPProSP2 */, "got %u\n", error);
2731 ok(hi == NULL || broken(!!hi) /* WinXPProSP2 */, "open should have failed\n");
2732
2733 sprintf(buffer, "localhost:%d\n", port);
2735 ok(hi != NULL, "open failed\n");
2736
2737 /* try connect without authorization */
2738 hc = InternetConnectA(hi, "test.winehq.org", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
2739 ok(hc != NULL, "connect failed\n");
2740
2741 hr = HttpOpenRequestA(hc, NULL, "/test2", NULL, NULL, NULL, 0, 0);
2742 ok(hr != NULL, "HttpOpenRequest failed\n");
2743
2744 sz = 0;
2745 SetLastError(0xdeadbeef);
2748 ok(!r, "unexpected success\n");
2749 ok(sz == 1, "got %u\n", sz);
2750
2751 sz = 0;
2752 SetLastError(0xdeadbeef);
2755 ok(!r, "unexpected success\n");
2756 ok(sz == 1, "got %u\n", sz);
2757
2758 sz = sizeof(buffer);
2759 SetLastError(0xdeadbeef);
2761 ok(r, "unexpected failure %u\n", GetLastError());
2762 ok(!sz, "got %u\n", sz);
2763
2764 sz = sizeof(buffer);
2765 SetLastError(0xdeadbeef);
2767 ok(r, "unexpected failure %u\n", GetLastError());
2768 ok(!sz, "got %u\n", sz);
2769
2770 sz = 0;
2771 SetLastError(0xdeadbeef);
2774 ok(!r, "unexpected success\n");
2775 ok(sz == 1, "got %u\n", sz);
2776
2777 sz = 0;
2778 SetLastError(0xdeadbeef);
2781 ok(!r, "unexpected success\n");
2782 ok(sz == 1, "got %u\n", sz);
2783
2784 sz = sizeof(buffer);
2785 SetLastError(0xdeadbeef);
2787 ok(r, "unexpected failure %u\n", GetLastError());
2788 ok(!sz, "got %u\n", sz);
2789
2790 sz = sizeof(buffer);
2791 SetLastError(0xdeadbeef);
2793 ok(r, "unexpected failure %u\n", GetLastError());
2794 ok(!sz, "got %u\n", sz);
2795
2796 sz = 0;
2797 SetLastError(0xdeadbeef);
2800 ok(!r, "unexpected success\n");
2801 ok(sz == 34, "got %u\n", sz);
2802
2803 sz = sizeof(buffer);
2804 SetLastError(0xdeadbeef);
2806 ok(r, "unexpected failure %u\n", GetLastError());
2807 ok(sz == 33, "got %u\n", sz);
2808
2809 r = HttpSendRequestW(hr, NULL, 0, NULL, 0);
2810 ok(r || broken(!r), "HttpSendRequest failed %u\n", GetLastError());
2811 if (!r)
2812 {
2813 win_skip("skipping proxy tests on broken wininet\n");
2814 goto done;
2815 }
2816
2817 test_status_code(hr, 407);
2818
2819 /* set the user + password then try again */
2821 ok(!r, "unexpected success\n");
2822
2824 ok(r, "failed to set user\n");
2825
2827 ok(r, "failed to set user\n");
2828
2829 buffer[0] = 0;
2830 sz = 3;
2831 SetLastError(0xdeadbeef);
2833 ok(!r, "unexpected failure %u\n", GetLastError());
2834 ok(!buffer[0], "got %s\n", buffer);
2835 ok(sz == strlen(username) + 1, "got %u\n", sz);
2836
2837 buffer[0] = 0;
2838 sz = 0;
2839 SetLastError(0xdeadbeef);
2842 ok(!r, "unexpected success\n");
2843 ok(sz == strlen(username) + 1, "got %u\n", sz);
2844
2845 bufferW[0] = 0;
2846 sz = 0;
2847 SetLastError(0xdeadbeef);
2850 ok(!r, "unexpected success\n");
2851 ok(sz == (lstrlenW(usernameW) + 1) * sizeof(WCHAR), "got %u\n", sz);
2852
2853 buffer[0] = 0;
2854 sz = sizeof(buffer);
2856 ok(r, "failed to get username\n");
2857 ok(!strcmp(buffer, username), "got %s\n", buffer);
2858 ok(sz == strlen(username), "got %u\n", sz);
2859
2860 buffer[0] = 0;
2861 sz = sizeof(bufferW);
2863 ok(r, "failed to get username\n");
2864 ok(!lstrcmpW(bufferW, usernameW), "wrong username\n");
2865 ok(sz == lstrlenW(usernameW), "got %u\n", sz);
2866
2868 ok(r, "failed to set user\n");
2869
2870 buffer[0] = 0;
2871 sz = sizeof(buffer);
2873 ok(r, "failed to get username\n");
2874 ok(!strcmp(buffer, username), "got %s\n", buffer);
2875 ok(sz == strlen(username), "got %u\n", sz);
2876
2877 r = InternetSetOptionA(hi, INTERNET_OPTION_USER_AGENT, useragent, 1);
2878 ok(r, "failed to set useragent\n");
2879
2880 buffer[0] = 0;
2881 sz = 0;
2882 SetLastError(0xdeadbeef);
2885 ok(!r, "unexpected success\n");
2886 ok(sz == strlen(useragent) + 1, "got %u\n", sz);
2887
2888 buffer[0] = 0;
2889 sz = sizeof(buffer);
2891 ok(r, "failed to get user agent\n");
2892 ok(!strcmp(buffer, useragent), "got %s\n", buffer);
2893 ok(sz == strlen(useragent), "got %u\n", sz);
2894
2895 bufferW[0] = 0;
2896 sz = 0;
2897 SetLastError(0xdeadbeef);
2900 ok(!r, "unexpected success\n");
2901 ok(sz == (lstrlenW(useragentW) + 1) * sizeof(WCHAR), "got %u\n", sz);
2902
2903 bufferW[0] = 0;
2904 sz = sizeof(bufferW);
2906 ok(r, "failed to get user agent\n");
2907 ok(!lstrcmpW(bufferW, useragentW), "wrong user agent\n");
2908 ok(sz == lstrlenW(useragentW), "got %u\n", sz);
2909
2911 ok(r, "failed to set user\n");
2912
2913 buffer[0] = 0;
2914 sz = 0;
2915 SetLastError(0xdeadbeef);
2918 ok(!r, "unexpected success\n");
2919 ok(sz == strlen(username) + 1, "got %u\n", sz);
2920
2921 buffer[0] = 0;
2922 sz = sizeof(buffer);
2924 ok(r, "failed to get user\n");
2925 ok(!strcmp(buffer, username), "got %s\n", buffer);
2926 ok(sz == strlen(username), "got %u\n", sz);
2927
2928 bufferW[0] = 0;
2929 sz = 0;
2930 SetLastError(0xdeadbeef);
2933 ok(!r, "unexpected success\n");
2934 ok(sz == (lstrlenW(usernameW) + 1) * sizeof(WCHAR), "got %u\n", sz);
2935
2936 bufferW[0] = 0;
2937 sz = sizeof(bufferW);
2939 ok(r, "failed to get user\n");
2940 ok(!lstrcmpW(bufferW, usernameW), "wrong user\n");
2941 ok(sz == lstrlenW(usernameW), "got %u\n", sz);
2942
2944 ok(r, "failed to set password\n");
2945
2946 buffer[0] = 0;
2947 sz = 0;
2948 SetLastError(0xdeadbeef);
2951 ok(!r, "unexpected success\n");
2952 ok(sz == strlen(password) + 1, "got %u\n", sz);
2953
2954 buffer[0] = 0;
2955 sz = sizeof(buffer);
2957 ok(r, "failed to get password\n");
2958 ok(!strcmp(buffer, password), "got %s\n", buffer);
2959 ok(sz == strlen(password), "got %u\n", sz);
2960
2961 bufferW[0] = 0;
2962 sz = 0;
2963 SetLastError(0xdeadbeef);
2966 ok(!r, "unexpected success\n");
2967 ok(sz == (lstrlenW(passwordW) + 1) * sizeof(WCHAR), "got %u\n", sz);
2968
2969 bufferW[0] = 0;
2970 sz = sizeof(bufferW);
2972 ok(r, "failed to get password\n");
2973 ok(!lstrcmpW(bufferW, passwordW), "wrong password\n");
2974 ok(sz == lstrlenW(passwordW), "got %u\n", sz);
2975
2976 url = HeapAlloc(GetProcessHeap(), 0, strlen(url_fmt) + 11);
2977 sprintf(url, url_fmt, port);
2978 buffer[0] = 0;
2979 sz = 0;
2980 SetLastError(0xdeadbeef);
2983 ok(!r, "unexpected success\n");
2984 ok(sz == strlen(url) + 1, "got %u\n", sz);
2985
2986 buffer[0] = 0;
2987 sz = sizeof(buffer);
2989 ok(r, "failed to get url\n");
2990 ok(!strcmp(buffer, url), "got %s\n", buffer);
2991 ok(sz == strlen(url), "got %u\n", sz);
2992
2993 bufferW[0] = 0;
2994 sz = 0;
2995 SetLastError(0xdeadbeef);
2996 r = InternetQueryOptionW(hr, INTERNET_OPTION_URL, bufferW, &sz);
2998 ok(!r, "unexpected success\n");
2999 ok(sz == (strlen(url) + 1) * sizeof(WCHAR), "got %u\n", sz);
3000
3001 bufferW[0] = 0;
3002 sz = sizeof(bufferW);
3003 r = InternetQueryOptionW(hr, INTERNET_OPTION_URL, bufferW, &sz);
3004 ok(r, "failed to get url\n");
3005 ok(!strcmp_wa(bufferW, url), "wrong url\n");
3006 ok(sz == strlen(url), "got %u\n", sz);
3008
3010 ok(r, "failed to set password\n");
3011
3012 buffer[0] = 0;
3013 sz = 0;
3014 SetLastError(0xdeadbeef);
3017 ok(!r, "unexpected success\n");
3018 ok(sz == strlen(password) + 1, "got %u\n", sz);
3019
3020 buffer[0] = 0;
3021 sz = sizeof(buffer);
3023 ok(r, "failed to get password\n");
3024 ok(!strcmp(buffer, password), "got %s\n", buffer);
3025 ok(sz == strlen(password), "got %u\n", sz);
3026
3027 bufferW[0] = 0;
3028 sz = 0;
3029 SetLastError(0xdeadbeef);
3032 ok(!r, "unexpected success\n");
3033 ok(sz == (lstrlenW(passwordW) + 1) * sizeof(WCHAR), "got %u\n", sz);
3034
3035 bufferW[0] = 0;
3036 sz = sizeof(bufferW);
3038 ok(r, "failed to get password\n");
3039 ok(!lstrcmpW(bufferW, passwordW), "wrong password\n");
3040 ok(sz == lstrlenW(passwordW), "got %u\n", sz);
3041
3042 r = HttpSendRequestW(hr, NULL, 0, NULL, 0);
3043 if (!r)
3044 {
3045 win_skip("skipping proxy tests on broken wininet\n");
3046 goto done;
3047 }
3048 ok(r, "HttpSendRequest failed %u\n", GetLastError());
3049 sz = sizeof buffer;
3051 ok(r, "HttpQueryInfo failed\n");
3052 ok(!strcmp(buffer, "200"), "proxy code wrong\n");
3053
3057
3058 sprintf(buffer, "localhost:%d\n", port);
3059 hi = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PROXY, buffer, NULL, 0);
3060 ok(hi != NULL, "InternetOpen failed\n");
3061
3062 hc = InternetConnectA(hi, "test.winehq.org", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3063 ok(hc != NULL, "InternetConnect failed\n");
3064
3065 hr = HttpOpenRequestA(hc, "POST", "/test2", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0);
3066 ok(hr != NULL, "HttpOpenRequest failed\n");
3067
3068 r = HttpSendRequestA(hr, NULL, 0, (char *)"data", sizeof("data"));
3069 ok(r, "HttpSendRequest failed %u\n", GetLastError());
3070
3071 test_status_code(hr, 407);
3072
3073done:
3077}
3078
3080{
3081 static const char authorization[] = "Authorization: Basic dXNlcjpwd2Q=";
3082 static const char connection[] = "Connection: Close";
3083 static const char *types[2] = { "*", NULL };
3084 char data[32];
3086 DWORD size, status, data_len;
3087 BOOL ret;
3088
3090 ok(session != NULL, "InternetOpen failed\n");
3091
3093 ok(connect != NULL, "InternetConnect failed\n");
3094
3096 ok(request != NULL, "HttpOpenRequest failed\n");
3097
3099 ok(ret, "HttpAddRequestHeaders failed\n");
3100
3102 ok(ret, "HttpSendRequest failed\n");
3103
3106
3108
3110 ok(request != NULL, "HttpOpenRequest failed\n");
3111
3112 ret = HttpSendRequestA(request, connection, ~0u, NULL, 0);
3113 ok(ret, "HttpSendRequest failed\n");
3114
3115 status = 0;
3116 size = sizeof(status);
3118 ok(ret, "HttpQueryInfo failed\n");
3119 ok(status == 200 || status == 400 /* IE6 */, "got status %u, expected 200 or 400\n", status);
3120
3123
3125 ok(connect != NULL, "InternetConnect failed\n");
3126
3128 ok(request != NULL, "HttpOpenRequest failed\n");
3129
3130 ret = HttpAddRequestHeadersA(request, "Content-Length: 100\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
3131 ok(ret, "HttpAddRequestHeaders failed\n");
3132
3133 ret = HttpSendRequestA(request, connection, ~0u, NULL, 0);
3134 ok(ret, "HttpSendRequest failed\n");
3135
3136 status = 0;
3137 size = sizeof(status);
3139 ok(ret, "HttpQueryInfo failed\n");
3140 ok(status == 200, "got status %u, expected 200\n", status);
3141
3144
3146 ok(connect != NULL, "InternetConnect failed\n");
3147
3149 ok(request != NULL, "HttpOpenRequest failed\n");
3150
3151 ret = HttpAddRequestHeadersA(request, "Content-Length: 100\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
3152 ok(ret, "HttpAddRequestHeaders failed\n");
3153
3154 data_len = sizeof(data);
3155 memset(data, 'a', sizeof(data));
3156 ret = HttpSendRequestA(request, NULL, 0, data, data_len);
3157 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
3158
3159 status = 0;
3160 size = sizeof(status);
3162 ok(ret, "HttpQueryInfo failed\n");
3163 ok(status == 200, "got status %u, expected 200\n", status);
3164
3168}
3169
3171{
3172 HINTERNET ses, con, req;
3173 BOOL ret;
3174
3175 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3176 ok(ses != NULL, "InternetOpen failed\n");
3177
3178 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3179 ok(con != NULL, "InternetConnect failed\n");
3180
3181 req = HttpOpenRequestA(con, NULL, "/test8", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3182 ok(req != NULL, "HttpOpenRequest failed\n");
3183
3184 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3185 ok(ret, "HttpSendRequest failed\n");
3186
3187 test_status_code(req, 200);
3188
3190
3191 req = HttpOpenRequestA(con, NULL, "/test9", NULL, NULL, NULL, 0, 0);
3192 ok(req != NULL, "HttpOpenRequest failed\n");
3193
3194 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3195 ok(ret, "HttpSendRequest failed\n");
3196
3197 test_status_code(req, 200);
3198
3200
3201 req = HttpOpenRequestA(con, NULL, "/test9", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
3202 ok(req != NULL, "HttpOpenRequest failed\n");
3203
3204 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3205 ok(ret, "HttpSendRequest failed\n");
3206
3207 test_status_code(req, 200);
3208
3210
3211 req = HttpOpenRequestA(con, "POST", "/testA", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
3212 ok(req != NULL, "HttpOpenRequest failed\n");
3213
3214 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3215 ok(ret, "HttpSendRequest failed\n");
3216
3217 test_status_code(req, 200);
3218
3222}
3223
3225{
3226 char buffer[128], host_header_override[30], full_url[128];
3227 HINTERNET ses, con, req;
3228 DWORD size, count, err;
3229 BOOL ret;
3230
3231 sprintf(host_header_override, "Host: test.local:%d\r\n", port);
3232 sprintf(full_url, "http://localhost:%d/test_host_override", port);
3233
3234 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3235 ok(ses != NULL, "InternetOpen failed\n");
3236
3237 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3238 ok(con != NULL, "InternetConnect failed\n");
3239
3240 req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3241 ok(req != NULL, "HttpOpenRequest failed\n");
3242
3243 size = sizeof(buffer) - 1;
3244 count = 0;
3245 memset(buffer, 0, sizeof(buffer));
3247 err = GetLastError();
3248 ok(!ret, "HttpQueryInfo succeeded\n");
3249 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "Expected error ERROR_HTTP_HEADER_NOT_FOUND, got %d\n", err);
3250
3251 test_request_url(req, full_url);
3252
3253 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_COALESCE);
3254 ok(ret, "HttpAddRequestHeaders failed\n");
3255
3256 size = sizeof(buffer) - 1;
3257 count = 0;
3258 memset(buffer, 0, sizeof(buffer));
3260 ok(ret, "HttpQueryInfo failed\n");
3261
3262 test_request_url(req, full_url);
3263
3264 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3265 ok(ret, "HttpSendRequest failed\n");
3266
3267 test_status_code(req, 200);
3268
3270 req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3271 ok(req != NULL, "HttpOpenRequest failed\n");
3272
3273 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_COALESCE);
3274 ok(ret, "HttpAddRequestHeaders failed\n");
3275
3276 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_COALESCE);
3277 ok(ret, "HttpAddRequestHeaders failed\n");
3278
3279 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3280 ok(ret, "HttpSendRequest failed\n");
3281
3282 test_status_code(req, 400);
3283
3285 req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3286 ok(req != NULL, "HttpOpenRequest failed\n");
3287
3288 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
3289 ok(ret, "HttpAddRequestHeaders failed\n");
3290
3291 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3292 ok(ret, "HttpSendRequest failed\n");
3293
3294 test_status_code(req, 200);
3295
3297 req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3298 ok(req != NULL, "HttpOpenRequest failed\n");
3299
3300 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_REPLACE);
3301 if(ret) { /* win10 returns success */
3302 trace("replacing host header is supported.\n");
3303
3304 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3305 ok(ret, "HttpSendRequest failed\n");
3306
3307 test_status_code(req, 200);
3308 }else {
3309 trace("replacing host header is not supported.\n");
3310
3311 err = GetLastError();
3312 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "Expected error ERROR_HTTP_HEADER_NOT_FOUND, got %d\n", err);
3313
3314 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3315 ok(ret, "HttpSendRequest failed\n");
3316
3317 test_status_code(req, 400);
3318 }
3319
3321 InternetSetCookieA("http://localhost", "cookie", "biscuit");
3322 req = HttpOpenRequestA(con, NULL, "/testC", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3323 ok(req != NULL, "HttpOpenRequest failed\n");
3324
3325 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
3326 ok(ret, "HttpAddRequestHeaders failed\n");
3327
3328 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3329 ok(ret, "HttpSendRequest failed\n");
3330
3331 test_status_code(req, 200);
3332
3334 req = HttpOpenRequestA(con, NULL, "/test_cookie_set_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3335 ok(req != NULL, "HttpOpenRequest failed\n");
3336
3337 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
3338 ok(ret, "HttpAddRequestHeaders failed\n");
3339
3340 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3341 ok(ret, "HttpSendRequest failed\n");
3342
3343 test_status_code(req, 200);
3344
3346 req = HttpOpenRequestA(con, NULL, "/test_cookie_check_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3347 ok(req != NULL, "HttpOpenRequest failed\n");
3348
3349 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
3350 ok(ret, "HttpAddRequestHeaders failed\n");
3351
3352 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3353 ok(ret, "HttpSendRequest failed\n");
3354
3355 test_status_code(req, 200);
3356
3358 req = HttpOpenRequestA(con, NULL, "/test_cookie_check_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3359 ok(req != NULL, "HttpOpenRequest failed\n");
3360
3361 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3362 ok(ret, "HttpSendRequest failed\n");
3363
3364 test_status_code(req, 200);
3365
3367 InternetSetCookieA("http://test.local", "foo", "bar");
3368 req = HttpOpenRequestA(con, NULL, "/test_cookie_check_different_host", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3369 ok(req != NULL, "HttpOpenRequest failed\n");
3370
3371 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3372 ok(ret, "HttpSendRequest failed\n");
3373
3374 test_status_code(req, 200);
3375
3377 req = HttpOpenRequestA(con, NULL, "/test_cookie_check_different_host", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
3378 ok(req != NULL, "HttpOpenRequest failed\n");
3379
3380 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
3381 ok(ret, "HttpAddRequestHeaders failed\n");
3382
3383 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3384 ok(ret, "HttpSendRequest failed\n");
3385
3386 test_status_code(req, 200);
3387
3391
3392 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3393 ok(ses != NULL, "InternetOpenA failed\n");
3394
3395 con = InternetConnectA(ses, "localhost", port, "test1", "pass", INTERNET_SERVICE_HTTP, 0, 0);
3396 ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
3397
3398 req = HttpOpenRequestA( con, "HEAD", "/test_auth_host1", NULL, NULL, NULL, 0, 0);
3399 ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
3400
3401 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3402 ok(ret, "HttpSendRequestA failed %u\n", GetLastError());
3403
3404 test_status_code(req, 200);
3405
3409
3410 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3411 ok(ses != NULL, "InternetOpenA failed\n");
3412
3413 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3414 ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
3415
3416 req = HttpOpenRequestA(con, "HEAD", "/test_auth_host1", NULL, NULL, NULL, 0, 0);
3417 ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
3418
3419 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
3420 ok(ret, "HttpAddRequestHeaders failed\n");
3421
3422 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
3423 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
3424
3425 test_status_code(req, 200);
3426
3430
3431 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3432 ok(ses != NULL, "InternetOpenA failed\n");
3433
3434 con = InternetConnectA(ses, "localhost", port, "test1", "pass2", INTERNET_SERVICE_HTTP, 0, 0);
3435 ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
3436
3437 req = HttpOpenRequestA(con, "HEAD", "/test_auth_host2", NULL, NULL, NULL, 0, 0);
3438 ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
3439
3440 ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
3441 ok(ret, "HttpAddRequestHeaders failed\n");
3442
3443 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3444 ok(ret, "HttpSendRequestA failed %u\n", GetLastError());
3445
3446 test_status_code(req, 200);
3447
3451
3452 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3453 ok(ses != NULL, "InternetOpenA failed\n");
3454
3455 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3456 ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
3457
3458 req = HttpOpenRequestA(con, "HEAD", "/test_auth_host2", NULL, NULL, NULL, 0, 0);
3459 ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
3460
3461 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3462 ok(ret, "HttpSendRequestA failed %u\n", GetLastError());
3463
3464 test_status_code(req, 200);
3465
3469}
3470
3472{
3473 HINTERNET session, connection, req;
3474 DWORD res;
3475
3476 reset_events();
3477
3479 ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError());
3480
3481 pInternetSetStatusCallbackA(session, callback);
3482
3484 connection = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
3485 ok(connection != NULL,"InternetConnect failed with error %u\n", GetLastError());
3487
3489 req = HttpOpenRequestA(connection, "GET", "/testJ", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0xdeadbeaf);
3490 ok(req != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
3492
3504
3505 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
3507 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3509 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
3510
3522
3523 test_status_code(req, 200);
3524
3534
3535 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
3537 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3539 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
3540
3550
3551 test_status_code(req, 210);
3552
3564
3565 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
3567 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3569 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
3570
3582
3583 test_status_code(req, 200);
3584
3587
3589}
3590
3592{
3593 HINTERNET session, connection, req;
3594 DWORD res;
3595
3596 reset_events();
3597
3599 ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError());
3600
3601 pInternetSetStatusCallbackA(session, callback);
3602
3604 connection = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
3605 ok(connection != NULL,"InternetConnect failed with error %u\n", GetLastError());
3607
3609 req = HttpOpenRequestA(connection, "GET", "/testH", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0xdeadbeaf);
3610 ok(req != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
3612
3622
3623 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
3625 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3627 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
3628
3638
3639 test_status_code(req, 210);
3640
3650
3651 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
3653 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3655 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
3656
3666
3667 test_status_code(req, 200);
3668
3671
3673}
3674
3675static void test_no_content(int port)
3676{
3677 HINTERNET session, connection, req;
3678 DWORD res;
3679
3680 trace("Testing 204 no content response...\n");
3681
3682 reset_events();
3683
3685 ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError());
3686
3687 pInternetSetStatusCallbackA(session, callback);
3688
3690 connection = InternetConnectA(session, "localhost", port,
3691 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
3692 ok(connection != NULL,"InternetConnect failed with error %u\n", GetLastError());
3694
3696 req = HttpOpenRequestA(connection, "GET", "/test_no_content", NULL, NULL, NULL,
3698 ok(req != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
3700
3711
3712 res = HttpSendRequestA(req, NULL, -1, NULL, 0);
3714 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3716 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
3717
3726
3728
3729 /*
3730 * The connection should be closed before closing handle. This is true for most
3731 * wininet versions (including Wine), but some old win2k versions fail to do that.
3732 */
3735}
3736
3737static void test_conn_close(int port)
3738{
3739 HINTERNET session, connection, req;
3740 DWORD res, avail, size;
3741 BYTE buf[1024];
3742
3743 trace("Testing connection close connection...\n");
3744
3745 reset_events();
3746
3748 ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError());
3749
3750 pInternetSetStatusCallbackA(session, callback);
3751
3753 connection = InternetConnectA(session, "localhost", port,
3754 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
3755 ok(connection != NULL,"InternetConnect failed with error %u\n", GetLastError());
3757
3759 req = HttpOpenRequestA(connection, "GET", "/test_conn_close", NULL, NULL, NULL,
3761 ok(req != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
3763
3772
3773 res = HttpSendRequestA(req, NULL, -1, NULL, 0);
3775 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3777 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
3778
3787
3788 avail = 0;
3789 res = InternetQueryDataAvailable(req, &avail, 0, 0);
3790 ok(res, "InternetQueryDataAvailable failed: %u\n", GetLastError());
3791 ok(avail != 0, "avail = 0\n");
3792
3793 size = 0;
3794 res = InternetReadFile(req, buf, avail, &size);
3795 ok(res, "InternetReadFile failed: %u\n", GetLastError());
3796
3797 /* IE11 calls those in InternetQueryDataAvailable call. */
3800
3801 res = InternetQueryDataAvailable(req, &avail, 0, 0);
3803 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
3804 ok(!avail, "avail = %u, expected 0\n", avail);
3805
3807
3813 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
3818
3820}
3821
3822static void test_no_cache(int port)
3823{
3824 static const char cache_control_no_cache[] = "/test_cache_control_no_cache";
3825 static const char cache_control_no_store[] = "/test_cache_control_no_store";
3826 static const char cache_url_fmt[] = "http://localhost:%d%s";
3827
3828 char cache_url[256], buf[256];
3829 HINTERNET ses, con, req;
3830 DWORD read, size;
3831 BOOL ret;
3832
3833 trace("Testing no-cache header\n");
3834
3835 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3836 ok(ses != NULL,"InternetOpen failed with error %u\n", GetLastError());
3837
3838 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3839 ok(con != NULL, "InternetConnect failed with error %u\n", GetLastError());
3840
3841 req = HttpOpenRequestA(con, NULL, cache_control_no_cache, NULL, NULL, NULL, 0, 0);
3842 ok(req != NULL, "HttpOpenRequest failed\n");
3843
3844 sprintf(cache_url, cache_url_fmt, port, cache_control_no_cache);
3845 DeleteUrlCacheEntryA(cache_url);
3846
3847 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3848 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
3849 size = 0;
3850 while(InternetReadFile(req, buf, sizeof(buf), &read) && read)
3851 size += read;
3852 ok(size == 12, "read %d bytes of data\n", size);
3854
3855 req = HttpOpenRequestA(con, NULL, cache_control_no_cache, NULL, NULL, NULL, 0, 0);
3856 ok(req != NULL, "HttpOpenRequest failed\n");
3857
3858 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3859 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
3860 size = 0;
3861 while(InternetReadFile(req, buf, sizeof(buf), &read) && read)
3862 size += read;
3863 ok(size == 0, "read %d bytes of data\n", size);
3865 DeleteUrlCacheEntryA(cache_url);
3866
3867 req = HttpOpenRequestA(con, NULL, cache_control_no_store, NULL, NULL, NULL, 0, 0);
3868 ok(req != NULL, "HttpOpenRequest failed\n");
3869
3870 sprintf(cache_url, cache_url_fmt, port, cache_control_no_store);
3871 DeleteUrlCacheEntryA(cache_url);
3872
3873 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3874 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
3875 size = 0;
3876 while(InternetReadFile(req, buf, sizeof(buf), &read) && read)
3877 size += read;
3878 ok(size == 12, "read %d bytes of data\n", size);
3880
3881 ret = DeleteUrlCacheEntryA(cache_url);
3882 ok(!ret && GetLastError()==ERROR_FILE_NOT_FOUND, "cache entry should not exist\n");
3883
3886}
3887
3889{
3890 static const char cache_url_fmt[] = "http://localhost:%d%s";
3891 static const char get_gzip[] = "/test_cache_gzip";
3892 static const char content[] = "gzip test\n";
3893 static const char text_html[] = "text/html";
3894 static const char raw_header[] = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
3895
3896 HINTERNET ses, con, req;
3897 DWORD read, size;
3898 char cache_url[256], buf[256];
3899 BOOL ret;
3900
3901 trace("Testing reading compressed content from cache\n");
3902
3903 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
3904 ok(ses != NULL,"InternetOpen failed with error %u\n", GetLastError());
3905
3906 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3907 ok(con != NULL, "InternetConnect failed with error %u\n", GetLastError());
3908
3909 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
3910 ok(req != NULL, "HttpOpenRequest failed\n");
3911
3912 ret = TRUE;
3915 win_skip("INTERNET_OPTION_HTTP_DECODING not supported\n");
3919 return;
3920 }
3921 ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError());
3922
3923 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
3924 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
3925 size = 0;
3926 while(InternetReadFile(req, buf+size, sizeof(buf)-size, &read) && read)
3927 size += read;
3928 ok(size == 10, "read %d bytes of data\n", size);
3929 buf[size] = 0;
3930 ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf);
3931
3932 size = sizeof(buf)-1;
3934 ok(ret, "HttpQueryInfo(HTTP_QUERY_CONTENT_TYPE) failed: %d\n", GetLastError());
3935 buf[size] = 0;
3936 ok(!strncmp(text_html, buf, size), "buf = %s\n", buf);
3937
3938 size = sizeof(buf)-1;
3940 ok(ret, "HttpQueryInfo(HTTP_QUERY_CONTENT_TYPE) failed: %d\n", GetLastError());
3941 buf[size] = 0;
3942 ok(!strncmp(raw_header, buf, size), "buf = %s\n", buf);
3944
3945 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
3946 ok(req != NULL, "HttpOpenRequest failed\n");
3947
3948 ret = TRUE;
3950 ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError());
3951
3952 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
3953 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
3954 size = 0;
3955 while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
3956 size += read;
3957 todo_wine ok(size == 10, "read %d bytes of data\n", size);
3958 buf[size] = 0;
3959 ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf);
3960
3961 size = sizeof(buf);
3964 "HttpQueryInfo(HTTP_QUERY_CONTENT_ENCODING) returned %d, %d\n",
3965 ret, GetLastError());
3966
3967 size = sizeof(buf)-1;
3969 todo_wine ok(ret, "HttpQueryInfo(HTTP_QUERY_CONTENT_TYPE) failed: %d\n", GetLastError());
3970 buf[size] = 0;
3971 todo_wine ok(!strncmp(text_html, buf, size), "buf = %s\n", buf);
3973
3974 /* Decompression doesn't work while reading from cache */
3975 test_cache_gzip = 0;
3976 sprintf(cache_url, cache_url_fmt, port, get_gzip);
3977 DeleteUrlCacheEntryA(cache_url);
3978
3979 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
3980 ok(req != NULL, "HttpOpenRequest failed\n");
3981
3982 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
3983 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
3984 size = 0;
3985 while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
3986 size += read;
3987 ok(size == 31, "read %d bytes of data\n", size);
3989
3990 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
3991 ok(req != NULL, "HttpOpenRequest failed\n");
3992
3993 ret = TRUE;
3995 ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError());
3996
3997 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
3998 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
3999 size = 0;
4000 while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
4001 size += read;
4002 todo_wine ok(size == 31, "read %d bytes of data\n", size);
4003
4004 size = sizeof(buf);
4006 todo_wine ok(ret, "HttpQueryInfo(HTTP_QUERY_CONTENT_ENCODING) failed: %d\n", GetLastError());
4008
4011
4012 /* Decompression doesn't work while reading from cache */
4013 test_cache_gzip = 0;
4014 sprintf(cache_url, cache_url_fmt, port, get_gzip);
4015 DeleteUrlCacheEntryA(cache_url);
4016
4017 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4018 ok(ses != NULL,"InternetOpen failed with error %u\n", GetLastError());
4019
4020 ret = TRUE;
4022 ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError());
4023
4024 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4025 ok(con != NULL, "InternetConnect failed with error %u\n", GetLastError());
4026
4027 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
4028 ok(req != NULL, "HttpOpenRequest failed\n");
4029
4030 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
4031 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
4032 size = 0;
4033 while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
4034 size += read;
4035 ok(size == 10, "read %d bytes of data\n", size);
4036 buf[size] = 0;
4037 ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf);
4039
4042
4043 /* Decompression doesn't work while reading from cache */
4044 test_cache_gzip = 0;
4045 sprintf(cache_url, cache_url_fmt, port, get_gzip);
4046 DeleteUrlCacheEntryA(cache_url);
4047
4048 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4049 ok(ses != NULL,"InternetOpen failed with error %u\n", GetLastError());
4050
4051 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4052 ok(con != NULL, "InternetConnect failed with error %u\n", GetLastError());
4053
4054 ret = TRUE;
4056 ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError());
4057
4058 req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
4059 ok(req != NULL, "HttpOpenRequest failed\n");
4060
4061 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
4062 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
4063 size = 0;
4064 while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
4065 size += read;
4066 ok(size == 10, "read %d bytes of data\n", size);
4067 buf[size] = 0;
4068 ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf);
4070
4073
4074 DeleteUrlCacheEntryA(cache_url);
4075}
4076
4078{
4079 static const WCHAR header[] = {'U','A','-','C','P','U',':',' ','x','8','6',0};
4080 HINTERNET ses, con, req;
4081 DWORD error;
4082 BOOL ret;
4083
4085 ok(ses != NULL, "InternetOpen failed\n");
4086
4087 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4088 ok(con != NULL, "InternetConnect failed\n");
4089
4090 req = HttpOpenRequestA(con, NULL, "/test1", NULL, NULL, NULL, 0, 0);
4091 ok(req != NULL, "HttpOpenRequest failed\n");
4092
4093 SetLastError(0xdeadbeef);
4094 ret = HttpSendRequestW(req, header, ~0u, NULL, 0);
4095 error = GetLastError();
4096 ok(!ret, "HttpSendRequestW succeeded\n");
4099 broken(error == ERROR_INVALID_PARAMETER), /* IE5 */
4100 "got %u expected ERROR_IO_PENDING\n", error);
4101
4105}
4106
4107static void test_cookie_header(int port)
4108{
4109 HINTERNET ses, con, req;
4110 DWORD size, error;
4111 BOOL ret;
4112 char buffer[256];
4113
4114 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4115 ok(ses != NULL, "InternetOpen failed\n");
4116
4117 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4118 ok(con != NULL, "InternetConnect failed\n");
4119
4120 InternetSetCookieA("http://localhost", "cookie", "biscuit");
4121
4122 req = HttpOpenRequestA(con, NULL, "/testC", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
4123 ok(req != NULL, "HttpOpenRequest failed\n");
4124
4125 buffer[0] = 0;
4126 size = sizeof(buffer);
4127 SetLastError(0xdeadbeef);
4129 error = GetLastError();
4130 ok(!ret, "HttpQueryInfo succeeded\n");
4131 ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "got %u expected ERROR_HTTP_HEADER_NOT_FOUND\n", error);
4132
4133 ret = HttpAddRequestHeadersA(req, "Cookie: cookie=not biscuit\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD);
4134 ok(ret, "HttpAddRequestHeaders failed: %u\n", GetLastError());
4135
4136 buffer[0] = 0;
4137 size = sizeof(buffer);
4139 ok(ret, "HttpQueryInfo failed: %u\n", GetLastError());
4140 ok(!!strstr(buffer, "cookie=not biscuit"), "got '%s' expected \'cookie=not biscuit\'\n", buffer);
4141
4142 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4143 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
4144
4145 test_status_code(req, 200);
4146
4147 buffer[0] = 0;
4148 size = sizeof(buffer);
4150 ok(ret, "HttpQueryInfo failed: %u\n", GetLastError());
4151 ok(!strstr(buffer, "cookie=not biscuit"), "'%s' should not contain \'cookie=not biscuit\'\n", buffer);
4152 ok(!!strstr(buffer, "cookie=biscuit"), "'%s' should contain \'cookie=biscuit\'\n", buffer);
4153
4155
4156 InternetSetCookieA("http://localhost/testCCCC", "subcookie", "data");
4157
4158 req = HttpOpenRequestA(con, NULL, "/test_cookie_path1", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
4159 ok(req != NULL, "HttpOpenRequest failed\n");
4160
4161 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4162 ok(ret, "HttpSendRequest failed\n");
4163
4164 test_status_code(req, 200);
4166
4167 req = HttpOpenRequestA(con, NULL, "/test_cookie_path1/abc", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
4168 ok(req != NULL, "HttpOpenRequest failed\n");
4169
4170 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4171 ok(ret, "HttpSendRequest failed\n");
4172
4173 test_status_code(req, 200);
4175
4176 req = HttpOpenRequestA(con, NULL, "/test_cookie_set_path", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
4177 ok(req != NULL, "HttpOpenRequest failed\n");
4178
4179 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4180 ok(ret, "HttpSendRequest failed\n");
4181
4182 test_status_code(req, 200);
4184
4185 req = HttpOpenRequestA(con, NULL, "/test_cookie_path2", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
4186 ok(req != NULL, "HttpOpenRequest failed\n");
4187
4188 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4189 ok(ret, "HttpSendRequest failed\n");
4190
4191 test_status_code(req, 400);
4193
4194 req = HttpOpenRequestA(con, NULL, "/test_cookie_merge", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
4195 ok(req != NULL, "HttpOpenRequest failed\n");
4196
4197 ret = HttpAddRequestHeadersA(req, "Cookie: manual_cookie=test\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD);
4198 ok(ret, "HttpAddRequestHeaders failed: %u\n", GetLastError());
4199
4200 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4201 ok(ret, "HttpSendRequest failed\n");
4202
4203 test_status_code(req, 200);
4205
4208}
4209
4211{
4213 BOOL ret;
4214
4216 ok(session != NULL, "InternetOpen failed\n");
4217
4218 connect = InternetConnectA(session, "localhost", port, "user", "pwd", INTERNET_SERVICE_HTTP, 0, 0);
4219 ok(connect != NULL, "InternetConnect failed\n");
4220
4221 request = HttpOpenRequestA(connect, NULL, "/test3", NULL, NULL, NULL, 0, 0);
4222 ok(request != NULL, "HttpOpenRequest failed\n");
4223
4225 ok(ret, "HttpSendRequest failed %u\n", GetLastError());
4226
4229
4233}
4234
4236{
4237 test_request_t req;
4238 DWORD err;
4239 BOOL ret;
4240
4241 open_simple_request(&req, "localhost", port, NULL, "/premature_disconnect");
4242
4243 SetLastError(0xdeadbeef);
4244 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4245 err = GetLastError();
4246 todo_wine ok(!ret, "HttpSendRequest succeeded\n");
4248
4249 close_request(&req);
4250}
4251
4253{
4254 test_request_t req;
4255 DWORD size;
4256 BOOL ret;
4257 char buffer[256];
4258
4259 open_simple_request(&req, "localhost", port, NULL, "/testE");
4260
4261 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4262 ok(ret, "HttpSendRequest failed %u\n", GetLastError());
4263
4264 test_status_code(req.request, 401);
4266
4267 buffer[0] = 0;
4268 size = sizeof(buffer);
4270 ok(ret, "HttpQueryInfo failed\n");
4271 ok(!strcmp(buffer, "HTTP/1.0 401 Anonymous requests or requests on unsecure channel are not allowed"),
4272 "headers wrong \"%s\"\n", buffer);
4273
4274 buffer[0] = 0;
4275 size = sizeof(buffer);
4277 ok(ret, "HttpQueryInfo failed\n");
4278 ok(!strcmp(buffer, "winetest"), "server wrong \"%s\"\n", buffer);
4279
4280 close_request(&req);
4281}
4282
4284{
4285 test_request_t req;
4286 DWORD r, count, size;
4287 char buffer[1024];
4288
4289 open_simple_request(&req, "localhost", port, NULL, "/testG");
4290
4292
4293 r = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4294 ok(r, "HttpSendRequest failed %u\n", GetLastError());
4295
4297
4298 count = 0;
4299 memset(buffer, 0, sizeof buffer);
4300 r = InternetReadFile(req.request, buffer, sizeof buffer, &count);
4301 ok(r, "InternetReadFile failed %u\n", GetLastError());
4302 todo_wine ok(count == sizeof page1 - 1, "count was wrong\n");
4303 todo_wine ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
4304
4305 test_status_code(req.request, 200);
4307
4308 buffer[0] = 0;
4309 size = sizeof(buffer);
4311 ok(r, "HttpQueryInfo failed %u\n", GetLastError());
4312 ok(!strcmp(buffer, "OK"), "expected OK got: \"%s\"\n", buffer);
4313
4314 buffer[0] = 0;
4315 size = sizeof(buffer);
4317 ok(r, "HttpQueryInfo failed %u\n", GetLastError());
4318 ok(!strcmp(buffer, "HTTP/1.0"), "expected HTTP/1.0 got: \"%s\"\n", buffer);
4319
4320 buffer[0] = 0;
4321 size = sizeof(buffer);
4323 ok(r, "HttpQueryInfo failed %u\n", GetLastError());
4324 ok(!strcmp(buffer, "HTTP/1.0 200 OK"), "raw headers wrong: \"%s\"\n", buffer);
4325
4326 close_request(&req);
4327}
4328
4329static void test_head_request(int port)
4330{
4332 test_request_t req;
4333 BYTE buf[100];
4334 BOOL ret;
4335
4336 open_simple_request(&req, "localhost", port, "HEAD", "/test_head");
4337
4338 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4339 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
4340
4341 len = sizeof(content_length);
4342 content_length = -1;
4344 ok(ret, "HttpQueryInfo failed: %u\n", GetLastError());
4345 ok(len == sizeof(DWORD), "len = %u\n", len);
4346 ok(content_length == 100, "content_length = %u\n", content_length);
4347
4348 len = -1;
4349 ret = InternetReadFile(req.request, buf, sizeof(buf), &len);
4350 ok(ret, "InternetReadFile failed: %u\n", GetLastError());
4351
4352 len = -1;
4353 ret = InternetReadFile(req.request, buf, sizeof(buf), &len);
4354 ok(ret, "InternetReadFile failed: %u\n", GetLastError());
4355
4356 close_request(&req);
4357}
4358
4359static void test_HttpQueryInfo(int port)
4360{
4361 test_request_t req;
4363 char buffer[1024];
4364 BOOL ret;
4365
4366 open_simple_request(&req, "localhost", port, NULL, "/testD");
4367
4368 size = sizeof(buffer);
4370 error = GetLastError();
4371 ok(!ret || broken(ret), "HttpQueryInfo succeeded\n");
4372 if (!ret) ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "got %u expected ERROR_HTTP_HEADER_NOT_FOUND\n", error);
4373
4374 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4375 ok(ret, "HttpSendRequest failed\n");
4376
4377 index = 0;
4378 size = sizeof(buffer);
4380 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4381 ok(index == 1, "expected 1 got %u\n", index);
4382
4383 index = 0;
4384 size = sizeof(buffer);
4386 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4387 ok(index == 1, "expected 1 got %u\n", index);
4388
4389 index = 0;
4390 size = sizeof(buffer);
4392 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4393 ok(index == 0, "expected 0 got %u\n", index);
4394
4395 size = sizeof(buffer);
4397 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4398 ok(index == 0, "expected 0 got %u\n", index);
4399
4400 index = 0xdeadbeef; /* invalid start index */
4401 size = sizeof(buffer);
4403 todo_wine ok(!ret, "HttpQueryInfo should have failed\n");
4405 "Expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", GetLastError());
4406
4407 index = 0;
4408 size = sizeof(buffer);
4410 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4411 ok(index == 0, "expected 0 got %u\n", index);
4412
4413 size = sizeof(buffer);
4415 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4416 ok(index == 0, "expected 0 got %u\n", index);
4417
4418 size = sizeof(buffer);
4420 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4421 ok(index == 0, "expected 0 got %u\n", index);
4422
4423 test_status_code(req.request, 200);
4424
4425 index = 0xdeadbeef;
4426 size = sizeof(buffer);
4428 ok(!ret, "HttpQueryInfo succeeded\n");
4429 ok(index == 0xdeadbeef, "expected 0xdeadbeef got %u\n", index);
4430
4431 index = 0;
4432 size = sizeof(buffer);
4434 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4435 ok(index == 1, "expected 1 got %u\n", index);
4436
4437 index = 0;
4438 size = sizeof(buffer);
4439 strcpy(buffer, "Server");
4441 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4442 ok(index == 1, "expected 1 got %u\n", index);
4443
4444 index = 0;
4445 size = sizeof(buffer);
4447 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4448 ok(index == 1, "expected 1 got %u\n", index);
4449
4450 size = sizeof(buffer);
4452 ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
4453 ok(index == 2, "expected 2 got %u\n", index);
4454
4455 close_request(&req);
4456}
4457
4458static void test_options(int port)
4459{
4461 HINTERNET ses, con, req;
4462 DWORD size, error;
4463 DWORD_PTR ctx;
4464 BOOL ret;
4465
4466 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4467 ok(ses != NULL, "InternetOpen failed\n");
4468
4469 SetLastError(0xdeadbeef);
4471 error = GetLastError();
4472 ok(!ret, "InternetSetOption succeeded\n");
4473 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
4474
4475 SetLastError(0xdeadbeef);
4477 ok(!ret, "InternetSetOption succeeded\n");
4478 error = GetLastError();
4479 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
4480
4481 SetLastError(0xdeadbeef);
4483 ok(!ret, "InternetSetOption succeeded\n");
4484 error = GetLastError();
4485 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
4486
4487 ctx = 1;
4489 ok(ret, "InternetSetOption failed %u\n", GetLastError());
4490
4491 SetLastError(0xdeadbeef);
4493 error = GetLastError();
4494 ok(!ret, "InternetQueryOption succeeded\n");
4495 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
4496
4497 SetLastError(0xdeadbeef);
4499 error = GetLastError();
4500 ok(!ret, "InternetQueryOption succeeded\n");
4501 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
4502
4503 size = 0;
4504 SetLastError(0xdeadbeef);
4506 error = GetLastError();
4507 ok(!ret, "InternetQueryOption succeeded\n");
4508 ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error);
4509
4510 size = sizeof(ctx);
4511 SetLastError(0xdeadbeef);
4513 error = GetLastError();
4514 ok(!ret, "InternetQueryOption succeeded\n");
4515 ok(error == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %u\n", error);
4516
4517 ctx = 0xdeadbeef;
4518 size = sizeof(ctx);
4520 ok(ret, "InternetQueryOption failed %u\n", GetLastError());
4521 ok(ctx == 1, "expected 1 got %lu\n", ctx);
4522
4523 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4524 ok(con != NULL, "InternetConnect failed\n");
4525
4526 ctx = 0xdeadbeef;
4527 size = sizeof(ctx);
4529 ok(ret, "InternetQueryOption failed %u\n", GetLastError());
4530 ok(ctx == 0, "expected 0 got %lu\n", ctx);
4531
4532 ctx = 2;
4534 ok(ret, "InternetSetOption failed %u\n", GetLastError());
4535
4536 ctx = 0xdeadbeef;
4537 size = sizeof(ctx);
4539 ok(ret, "InternetQueryOption failed %u\n", GetLastError());
4540 ok(ctx == 2, "expected 2 got %lu\n", ctx);
4541
4542 req = HttpOpenRequestA(con, NULL, "/test1", NULL, NULL, NULL, 0, 0);
4543 ok(req != NULL, "HttpOpenRequest failed\n");
4544
4545 ctx = 0xdeadbeef;
4546 size = sizeof(ctx);
4548 ok(ret, "InternetQueryOption failed %u\n", GetLastError());
4549 ok(ctx == 0, "expected 0 got %lu\n", ctx);
4550
4551 ctx = 3;
4553 ok(ret, "InternetSetOption failed %u\n", GetLastError());
4554
4555 ctx = 0xdeadbeef;
4556 size = sizeof(ctx);
4558 ok(ret, "InternetQueryOption failed %u\n", GetLastError());
4559 ok(ctx == 3, "expected 3 got %lu\n", ctx);
4560
4561 size = sizeof(idsi);
4563 ok(ret, "InternetQueryOption failed %u\n", GetLastError());
4564
4565 size = 0;
4566 SetLastError(0xdeadbeef);
4568 error = GetLastError();
4569 ok(!ret, "InternetQueryOption succeeded\n");
4570 ok(error == ERROR_INTERNET_INVALID_OPERATION, "expected ERROR_INTERNET_INVALID_OPERATION, got %u\n", error);
4571
4572 /* INTERNET_OPTION_PROXY */
4573 SetLastError(0xdeadbeef);
4575 error = GetLastError();
4576 ok(!ret, "InternetQueryOption succeeded\n");
4577 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
4578
4579 SetLastError(0xdeadbeef);
4581 error = GetLastError();
4582 ok(!ret, "InternetQueryOption succeeded\n");
4583 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
4584
4585 size = 0;
4586 SetLastError(0xdeadbeef);
4588 error = GetLastError();
4589 ok(!ret, "InternetQueryOption succeeded\n");
4590 ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error);
4591 ok(size >= sizeof(INTERNET_PROXY_INFOA), "expected size to be greater or equal to the struct size\n");
4592
4596}
4597
4598typedef struct {
4599 const char *response_text;
4601 const char *status_text;
4602 const char *raw_headers;
4604
4606 {
4607 "HTTP/1.1 200 OK\r\n"
4608 "Content-Length: 1\r\n"
4609 "\r\nx",
4610 200,
4611 "OK"
4612 },
4613 {
4614 "HTTP/1.1 404 Fail\r\n"
4615 "Content-Length: 1\r\n"
4616 "\r\nx",
4617 404,
4618 "Fail"
4619 },
4620 {
4621 "HTTP/1.1 200\r\n"
4622 "Content-Length: 1\r\n"
4623 "\r\nx",
4624 200,
4625 ""
4626 },
4627 {
4628 "HTTP/1.1 410 \r\n"
4629 "Content-Length: 1\r\n"
4630 "\r\nx",
4631 410,
4632 ""
4633 }
4634};
4635
4636static void test_http_status(int port)
4637{
4638 test_request_t req;
4639 char buf[1000];
4640 DWORD i, size;
4641 BOOL res;
4642
4643 for(i = 0; i < ARRAY_SIZE(http_status_tests); i++) {
4645
4646 open_simple_request(&req, "localhost", port, NULL, "/send_from_buffer");
4647
4648 res = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4649 ok(res, "HttpSendRequest failed\n");
4650
4652
4653 size = sizeof(buf);
4655 ok(res, "HttpQueryInfo failed: %u\n", GetLastError());
4656 ok(!strcmp(buf, http_status_tests[i].status_text), "[%u] Unexpected status text \"%s\", expected \"%s\"\n",
4657 i, buf, http_status_tests[i].status_text);
4658
4659 close_request(&req);
4660 }
4661}
4662
4664{
4666 BOOL ret;
4667
4669 ok(session != NULL, "InternetOpen failed\n");
4670
4672 ok(connect != NULL, "InternetConnect failed\n");
4673
4674 request = HttpOpenRequestA(connect, "RPC_OUT_DATA", "/test_cache_control_verb", NULL, NULL, NULL,
4676 ok(request != NULL, "HttpOpenRequest failed\n");
4678 ok(ret, "HttpSendRequest failed %u\n", GetLastError());
4681
4682 request = HttpOpenRequestA(connect, "POST", "/test_cache_control_verb", NULL, NULL, NULL,
4684 ok(request != NULL, "HttpOpenRequest failed\n");
4686 ok(ret, "HttpSendRequest failed %u\n", GetLastError());
4689
4690 request = HttpOpenRequestA(connect, "HEAD", "/test_cache_control_verb", NULL, NULL, NULL,
4692 ok(request != NULL, "HttpOpenRequest failed\n");
4694 ok(ret, "HttpSendRequest failed %u\n", GetLastError());
4697
4698 request = HttpOpenRequestA(connect, "GET", "/test_cache_control_verb", NULL, NULL, NULL,
4700 ok(request != NULL, "HttpOpenRequest failed\n");
4702 ok(ret, "HttpSendRequest failed %u\n", GetLastError());
4705
4708}
4709
4711{
4712 char data[] = {'t','e','s','t'};
4713 test_request_t req;
4714 BOOL ret;
4715
4716 reset_events();
4717 open_simple_request(&req, "localhost", port, "POST", "/test_request_content_length");
4718
4719 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
4720 ok(ret, "HttpSendRequest failed %u\n", GetLastError());
4721 test_status_code(req.request, 200);
4722
4724
4725 ret = HttpSendRequestA(req.request, NULL, 0, data, sizeof(data));
4726 ok(ret, "HttpSendRequest failed %u\n", GetLastError());
4727 test_status_code(req.request, 200);
4728
4730 close_request(&req);
4731}
4732
4734{
4735 HINTERNET ses, con, req;
4736 char buf[1000];
4737 BOOL ret;
4738
4739 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
4740 ok(ses != NULL, "InternetOpen failed\n");
4741
4742 con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
4743 ok(con != NULL, "InternetConnect failed\n");
4744
4745 req = HttpOpenRequestA(con, "GET", "/echo_request", "HTTP/1.0", NULL, NULL, 0, 0);
4746 ok(req != NULL, "HttpOpenRequest failed\n");
4747
4748 ret = HttpAddRequestHeadersA(req, "Accept-Encoding: gzip\r\n", ~0u, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD);
4749 ok(ret, "HttpAddRequestHeaders failed\n");
4750
4751 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
4752 ok(ret, "HttpSendRequestA failed\n");
4753
4754 test_status_code(req, 200);
4755 receive_simple_request(req, buf, sizeof(buf));
4756 ok(strstr(buf, "Accept-Encoding: gzip") != NULL, "Accept-Encoding header not found in %s\n", buf);
4757
4759
4760 req = HttpOpenRequestA(con, "GET", "/echo_request", "HTTP/1.0", NULL, NULL, 0, 0);
4761 ok(req != NULL, "HttpOpenRequest failed\n");
4762
4763 ret = HttpSendRequestA(req, "Accept-Encoding: gzip", ~0u, NULL, 0);
4764 ok(ret, "HttpSendRequestA failed\n");
4765
4766 test_status_code(req, 200);
4767 receive_simple_request(req, buf, sizeof(buf));
4768 ok(strstr(buf, "Accept-Encoding: gzip") != NULL, "Accept-Encoding header not found in %s\n", buf);
4769
4773}
4774
4776{
4777 HINTERNET ses, con, req;
4778 DWORD status, size;
4779 BOOL ret;
4780 char buffer[0x40];
4781
4782 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
4783 ok( ses != NULL, "InternetOpenA failed\n" );
4784
4785 con = InternetConnectA( ses, "localhost", port, "user", "pwd",
4786 INTERNET_SERVICE_HTTP, 0, 0 );
4787 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
4788
4789 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
4790 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
4791
4792 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
4793 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
4794
4795 size = sizeof(buffer);
4796 SetLastError(0xdeadbeef);
4798 ok(ret, "unexpected failure %u\n", GetLastError());
4799 ok(!strcmp(buffer, "user"), "got %s\n", buffer);
4800 ok(size == 4, "got %u\n", size);
4801
4802 size = sizeof(buffer);
4803 SetLastError(0xdeadbeef);
4805 ok(ret, "unexpected failure %u\n", GetLastError());
4806 ok(!strcmp(buffer, "pwd"), "got %s\n", buffer);
4807 ok(size == 3, "got %u\n", size);
4808
4809 status = 0xdeadbeef;
4810 size = sizeof(status);
4812 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
4813 ok( status == 200, "got %u\n", status );
4814
4815 InternetCloseHandle( req );
4816 InternetCloseHandle( con );
4817 InternetCloseHandle( ses );
4818
4819 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
4820 ok( ses != NULL, "InternetOpenA failed\n" );
4821
4822 con = InternetConnectA( ses, "localhost", port, NULL, NULL,
4823 INTERNET_SERVICE_HTTP, 0, 0 );
4824 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
4825
4826 req = HttpOpenRequestA( con, "PUT", "/upload2.txt", NULL, NULL, NULL, 0, 0 );
4827 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
4828
4829 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
4830 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
4831
4832 size = sizeof(buffer);
4833 SetLastError(0xdeadbeef);
4835 ok(ret, "unexpected failure %u\n", GetLastError());
4836 ok(!strcmp(buffer, "user"), "got %s\n", buffer);
4837 ok(size == 4, "got %u\n", size);
4838
4839 size = sizeof(buffer);
4840 SetLastError(0xdeadbeef);
4842 ok(ret, "unexpected failure %u\n", GetLastError());
4843 ok(!strcmp(buffer, "pwd"), "got %s\n", buffer);
4844 ok(size == 3, "got %u\n", size);
4845
4846 status = 0xdeadbeef;
4847 size = sizeof(status);
4849 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
4850 ok( status == 200, "got %u\n", status );
4851
4852 InternetCloseHandle( req );
4853 InternetCloseHandle( con );
4854 InternetCloseHandle( ses );
4855}
4856
4858{
4859 HINTERNET ses, con, req;
4860 DWORD status, size;
4861 BOOL ret;
4862 char buffer[0x40];
4863
4864 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
4865 ok( ses != NULL, "InternetOpenA failed\n" );
4866
4867 con = InternetConnectA( ses, "localhost", port, "user", "pwd",
4868 INTERNET_SERVICE_HTTP, 0, 0 );
4869 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
4870
4871 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
4872 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
4873
4874 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
4875 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
4876
4877 size = sizeof(buffer);
4878 SetLastError(0xdeadbeef);
4880 ok(ret, "unexpected failure %u\n", GetLastError());
4881 ok(!strcmp(buffer, "user"), "got %s\n", buffer);
4882 ok(size == 4, "got %u\n", size);
4883
4884 size = sizeof(buffer);
4885 SetLastError(0xdeadbeef);
4887 ok(ret, "unexpected failure %u\n", GetLastError());
4888 ok(!strcmp(buffer, "pwd"), "got %s\n", buffer);
4889 ok(size == 3, "got %u\n", size);
4890
4891 status = 0xdeadbeef;
4892 size = sizeof(status);
4894 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
4895 ok( status == HTTP_STATUS_OK, "got %u\n", status );
4896
4897 InternetCloseHandle( req );
4898 InternetCloseHandle( con );
4899 InternetCloseHandle( ses );
4900
4901 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
4902 ok( ses != NULL, "InternetOpenA failed\n" );
4903
4904 /* Clear the cached credentials */
4906 ok(ret, "unexpected failure %u\n", GetLastError());
4907
4908 con = InternetConnectA( ses, "localhost", port, NULL, NULL,
4909 INTERNET_SERVICE_HTTP, 0, 0 );
4910 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
4911
4912 req = HttpOpenRequestA( con, "PUT", "/upload2.txt", NULL, NULL, NULL, 0, 0 );
4913 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
4914
4915 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
4916 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
4917
4918 size = sizeof(buffer);
4919 SetLastError(0xdeadbeef);
4921 ok(ret, "unexpected failure %u\n", GetLastError());
4922 ok(!strcmp(buffer, ""), "got %s\n", buffer);
4923 ok(size == 0, "got %u\n", size);
4924
4925 size = sizeof(buffer);
4926 SetLastError(0xdeadbeef);
4928 ok(ret, "unexpected failure %u\n", GetLastError());
4929 ok(!strcmp(buffer, ""), "got %s\n", buffer);
4930 ok(size == 0, "got %u\n", size);
4931
4932 status = 0xdeadbeef;
4933 size = sizeof(status);
4935 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
4936 ok( status == HTTP_STATUS_BAD_REQUEST, "got %u\n", status );
4937
4938 InternetCloseHandle( req );
4939 InternetCloseHandle( con );
4940 InternetCloseHandle( ses );
4941}
4942
4944{
4945 HINTERNET ses, con, req;
4946 DWORD status, size;
4947 BOOL ret;
4948 char buffer[0x40];
4949
4950 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
4951 ok( ses != NULL, "InternetOpenA failed\n" );
4952
4953 con = InternetConnectA( ses, "localhost", port, "user", "pwd",
4954 INTERNET_SERVICE_HTTP, 0, 0 );
4955 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
4956
4957 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
4958 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
4959
4960 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
4961 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
4962
4963 size = sizeof(buffer);
4964 SetLastError(0xdeadbeef);
4966 ok(ret, "unexpected failure %u\n", GetLastError());
4967 ok(!strcmp(buffer, "user"), "got %s\n", buffer);
4968 ok(size == 4, "got %u\n", size);
4969
4970 size = sizeof(buffer);
4971 SetLastError(0xdeadbeef);
4973 ok(ret, "unexpected failure %u\n", GetLastError());
4974 ok(!strcmp(buffer, "pwd"), "got %s\n", buffer);
4975 ok(size == 3, "got %u\n", size);
4976
4977 status = 0xdeadbeef;
4978 size = sizeof(status);
4980 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
4981 ok( status == 200, "got %u\n", status );
4982
4983 InternetCloseHandle( req );
4984 InternetCloseHandle( con );
4985 InternetCloseHandle( ses );
4986
4987 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
4988 ok( ses != NULL, "InternetOpenA failed\n" );
4989
4990 con = InternetConnectA( ses, "localhost", port, "user1", "pwd1",
4991 INTERNET_SERVICE_HTTP, 0, 0 );
4992 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
4993
4994 req = HttpOpenRequestA( con, "HEAD", "/upload3.txt", NULL, NULL, NULL, 0, 0 );
4995 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
4996
4997 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
4998 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
4999
5000 size = sizeof(buffer);
5001 SetLastError(0xdeadbeef);
5003 ok(ret, "unexpected failure %u\n", GetLastError());
5004 ok(!strcmp(buffer, "user1"), "got %s\n", buffer);
5005 ok(size == 5, "got %u\n", size);
5006
5007 size = sizeof(buffer);
5008 SetLastError(0xdeadbeef);
5010 ok(ret, "unexpected failure %u\n", GetLastError());
5011 ok(!strcmp(buffer, "pwd1"), "got %s\n", buffer);
5012 ok(size == 4, "got %u\n", size);
5013
5014 status = 0xdeadbeef;
5015 size = sizeof(status);
5017 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
5018 ok( status == 200, "got %u\n", status );
5019
5020 InternetCloseHandle( req );
5021 InternetCloseHandle( con );
5022 InternetCloseHandle( ses );
5023}
5024
5025/*
5026 * Manually set the Authorization for both calls.
5027 */
5029{
5030 HINTERNET ses, con, req;
5031 DWORD status, size;
5032 BOOL ret;
5033
5034 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5035 ok( ses != NULL, "InternetOpenA failed\n" );
5036
5037 /* Clear the cached credentials */
5039 ok(ret, "unexpected failure %u\n", GetLastError());
5040
5041 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 );
5042 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
5043
5044 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
5045 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
5046
5047 /* Set Authorization Header */
5048 ret = HttpAddRequestHeadersA(req, "Authorization: Basic dXNlcjpwd2Q=\r\n", ~0u,
5050 ok(ret, "HttpAddRequestHeaders Failed\n");
5051
5052 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5053 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
5054
5055 status = 0xdeadbeef;
5056 size = sizeof(status);
5058 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
5059 ok( status == 200, "got %u\n", status );
5060
5061 InternetCloseHandle( req );
5062 InternetCloseHandle( con );
5063 InternetCloseHandle( ses );
5064
5065 /* Show manual headers are cached. */
5066 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5067 ok( ses != NULL, "InternetOpenA failed\n" );
5068
5069 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 );
5070 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
5071
5072 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
5073 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
5074
5075 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5076 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
5077
5078 status = 0xdeadbeef;
5079 size = sizeof(status);
5081 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
5082 ok( status == 401, "got %u\n", status );
5083
5084 InternetCloseHandle( req );
5085 InternetCloseHandle( con );
5086 InternetCloseHandle( ses );
5087
5088 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5089 ok( ses != NULL, "InternetOpenA failed\n" );
5090
5091 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 );
5092 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
5093
5094 req = HttpOpenRequestA( con, "HEAD", "/upload4.txt", NULL, NULL, NULL, 0, 0 );
5095 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
5096
5097 /* Set Authorization Header */
5098 ret = HttpAddRequestHeadersA(req, "Authorization: Bearer dXNlcjE6cHdkMQ==\r\n", ~0u,
5100 ok(ret, "HttpAddRequestHeaders Failed\n");
5101
5102 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5103 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
5104
5105 status = 0xdeadbeef;
5106 size = sizeof(status);
5108 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
5109 ok( status == 200, "got %u\n", status );
5110
5111 InternetCloseHandle( req );
5112 InternetCloseHandle( con );
5113 InternetCloseHandle( ses );
5114}
5115
5116/*
5117 * Manually set the Authorization for the bearer call, which shows the cached is used.
5118 */
5120{
5121 HINTERNET ses, con, req;
5122 DWORD status, size;
5123 BOOL ret;
5124
5125 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5126 ok( ses != NULL, "InternetOpenA failed\n" );
5127
5128 /* Clear the cached credentials */
5130 ok(ret, "unexpected failure %u\n", GetLastError());
5131
5132 con = InternetConnectA( ses, "localhost", port, "user", "pwd",
5133 INTERNET_SERVICE_HTTP, 0, 0 );
5134 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
5135
5136 req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL, NULL, 0, 0 );
5137 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
5138
5139 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5140 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
5141
5142 status = 0xdeadbeef;
5143 size = sizeof(status);
5145 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
5146 ok( status == 200, "got %u\n", status );
5147
5148 InternetCloseHandle( req );
5149 InternetCloseHandle( con );
5150 InternetCloseHandle( ses );
5151
5152 ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
5153 ok( ses != NULL, "InternetOpenA failed\n" );
5154
5155 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 );
5156 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
5157
5158 req = HttpOpenRequestA( con, "HEAD", "/upload4.txt", NULL, NULL, NULL, 0, 0 );
5159 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
5160
5161 /* Setting an Authorization Header doesn't override the cached one. */
5162 ret = HttpAddRequestHeadersA(req, "Authorization: Bearer dXNlcjE6cHdkMQ==\r\n", ~0u,
5164 ok(ret, "HttpAddRequestHeaders Failed\n");
5165
5166 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5167 ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
5168
5169 status = 0xdeadbeef;
5170 size = sizeof(status);
5172 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
5173 ok( status == 201, "got %u\n", status );
5174
5175 InternetCloseHandle( req );
5176 InternetCloseHandle( con );
5177 InternetCloseHandle( ses );
5178}
5179
5180static void test_async_read(int port)
5181{
5182 HINTERNET ses, con, req;
5184 char buffer[0x100];
5185 DWORD pending_reads;
5186 DWORD res, count, bytes;
5187 BOOL ret;
5188
5189 reset_events();
5190
5191 /* test asynchronous InternetReadFileEx */
5193 ok( ses != NULL, "InternetOpenA failed\n" );
5194 pInternetSetStatusCallbackA( ses, &callback );
5195
5197 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0xdeadbeef );
5198 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
5200
5202 req = HttpOpenRequestA( con, "GET", "/async_read", NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef );
5203 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
5205
5217
5218 SetLastError( 0xdeadbeef );
5219 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5220 ok( !ret, "HttpSendRequestA unexpectedly succeeded\n" );
5221 ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
5223 ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error );
5224
5236
5237 pending_reads = 0;
5238 memset( &ib, 0, sizeof(ib) );
5239 memset( buffer, 0, sizeof(buffer) );
5240 ib.dwStructSize = sizeof(ib);
5241 for (count = 0; count < sizeof(buffer); count += ib.dwBufferLength)
5242 {
5243 ib.lpvBuffer = buffer + count;
5244 ib.dwBufferLength = min(16, sizeof(buffer) - count);
5245
5248
5249 ret = InternetReadFileExA( req, &ib, 0, 0xdeadbeef );
5250 if (!count) /* the first part should arrive immediately */
5251 ok( ret, "InternetReadFileExA failed %u\n", GetLastError() );
5253 if (!ret)
5254 {
5255 ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
5259 if (!pending_reads++)
5260 {
5262 ok( res == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", res );
5264 }
5266 ok( res == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", res );
5267 ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error );
5268 todo_wine_if( pending_reads > 1 )
5269 ok( ib.dwBufferLength != 0, "expected ib.dwBufferLength != 0\n" );
5272 }
5273
5276 if (!ib.dwBufferLength) break;
5277 }
5278
5279 ok( pending_reads == 1, "expected 1 pending read, got %u\n", pending_reads );
5280 ok( !strcmp(buffer, page1), "unexpected buffer content\n" );
5281 close_async_handle( ses, 2 );
5283
5284 /* test asynchronous InternetReadFile */
5286 ok( ses != NULL, "InternetOpenA failed\n" );
5287 pInternetSetStatusCallbackA( ses, &callback );
5288
5290 con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0xdeadbeef );
5291 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
5293
5295 req = HttpOpenRequestA( con, "GET", "/async_read", NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef );
5296 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
5298
5310
5311 SetLastError( 0xdeadbeef );
5312 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
5313 ok( !ret, "HttpSendRequestA unexpectedly succeeded\n" );
5314 ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
5316 ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error );
5317
5329
5330 pending_reads = 0;
5331 memset( buffer, 0, sizeof(buffer) );
5332 for (count = 0; count < sizeof(buffer); count += bytes)
5333 {
5336
5337 bytes = 0xdeadbeef;
5338 ret = InternetReadFile( req, buffer + count, min(16, sizeof(buffer) - count), &bytes );
5339 if (!count) /* the first part should arrive immediately */
5340 ok( ret, "InternetReadFile failed %u\n", GetLastError() );
5341 if (!ret)
5342 {
5343 ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
5344 ok( bytes == 0, "expected 0, got %u\n", bytes );
5348 if (!pending_reads++)
5349 {
5351 ok( res == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", res );
5353 }
5355 ok( res == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", res );
5356 ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error );
5358 todo_wine_if( pending_reads > 1 )
5359 ok( bytes != 0, "expected bytes != 0\n" );
5360 }
5365 }
5366
5369 if (!bytes) break;
5370 }
5371
5373 ok( pending_reads == 1, "expected 1 pending read, got %u\n", pending_reads );
5374 ok( !strcmp(buffer, page1), "unexpected buffer content\n" );
5375 close_async_handle( ses, 2 );
5376}
5377
5378static void server_send_string(const char *msg)
5379{
5381}
5382
5383static size_t server_read_data(char *buf, size_t buf_size)
5384{
5385 return recv(server_socket, buf, buf_size, 0);
5386}
5387
5388#define server_read_request(a) _server_read_request(__LINE__,a)
5389static void _server_read_request(unsigned line, const char *expected_request)
5390{
5391 char buf[4000], *p;
5392 size_t size;
5393
5394 size = server_read_data(buf, sizeof(buf) - 1);
5395 buf[size] = 0;
5396 p = strstr(buf, "\r\n");
5397 if(p) *p = 0;
5398 ok_(__FILE__,line)(p && !strcmp(buf, expected_request), "unexpected request %s\n", buf);
5399}
5400
5403
5405{
5406 switch(status) {
5409 callback(handle, context, status, info, info_size);
5410 break;
5413 callback(handle, context, status, info, info_size);
5415 break;
5417 callback(handle, context, status, info, info_size);
5419 break;
5420 default:
5421 callback(handle, context, status, info, info_size);
5422 }
5423}
5424
5425static void send_socket_request(test_request_t *req, BOOL new_connection)
5426{
5427 BOOL ret;
5428
5431 if(new_connection) {
5434 }
5439
5440 SetLastError(0xdeadbeef);
5441 ret = HttpSendRequestA(req->request, NULL, 0, NULL, 0);
5442 ok(!ret, "HttpSendRequestA unexpectedly succeeded\n");
5443 ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError());
5444
5445 if(new_connection)
5448
5451 if(new_connection) {
5454 }
5457}
5458
5459static void open_socket_request(int port, test_request_t *req, const char *verb)
5460{
5461 /* We're connecting to new socket */
5462 if(!verb)
5463 reset_events();
5464
5466 ok(req->session != NULL, "InternetOpenA failed\n");
5467 pInternetSetStatusCallbackA(req->session, readex_callback);
5468
5470 req->connection = InternetConnectA(req->session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0xdeadbeef);
5471 ok(req->connection != NULL, "InternetConnectA failed %u\n", GetLastError());
5473
5475 req->request = HttpOpenRequestA(req->connection, "GET", verb ? verb : "/socket",
5476 NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef);
5477 ok(req->request != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
5479
5480 send_socket_request(req, !verb);
5481}
5482
5483static void open_read_test_request(int port, test_request_t *req, const char *response)
5484{
5487
5489
5492 received_response_size = 0xdeadbeef;
5493 }
5495
5496 server_send_string(response);
5498
5502 todo_wine
5503 ok(received_response_size == strlen(response), "received_response_size = %u\n", received_response_size);
5504 }
5506 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error);
5507}
5508
5509#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)
5511 DWORD buf_size, const char *exdata, DWORD len, DWORD expect_receive)
5512{
5513 BOOL ret;
5514
5515 if(!skip_receive_notification_tests && expect_receive) {
5518 received_response_size = 0xdeadbeef;
5519 }
5520
5521 memset(buf->lpvBuffer, 0xff, buf_size);
5522 buf->dwBufferLength = buf_size;
5523 ret = InternetReadFileExW(req, buf, flags, 0xdeadbeef);
5524 ok_(__FILE__,line)(ret, "InternetReadFileExW failed: %u\n", GetLastError());
5525 ok_(__FILE__,line)(buf->dwBufferLength == len, "dwBufferLength = %u, expected %u\n", buf->dwBufferLength, len);
5526 if(len && exdata)
5527 ok_(__FILE__,line)(!memcmp(buf->lpvBuffer, exdata, len), "Unexpected data\n");
5528
5529 if(!skip_receive_notification_tests && expect_receive) {
5532 ok_(__FILE__,line)(received_response_size == len, "received_response_size = %u\n", received_response_size);
5533 }
5534}
5535
5536#define readex_expect_sync_data(a,b,c,d,e,f) _readex_expect_sync_data(__LINE__,a,b,c,d,e,f)
5538 DWORD buf_size, const char *exdata, DWORD expect_receive)
5539{
5540 _readex_expect_sync_data_len(line, req, flags, buf, buf_size, exdata, strlen(exdata), expect_receive);
5541}
5542
5543#define read_expect_sync_data_len(a,b,c,d,e) _read_expect_sync_data_len(__LINE__,a,b,c,d,e)
5544static void _read_expect_sync_data_len(unsigned line, HINTERNET req, void *buf, DWORD buf_size,
5545 const char *exdata, DWORD len)
5546{
5547 DWORD ret_size = 0xdeadbeef;
5548 BOOL ret;
5549
5553 received_response_size = 0xdeadbeef;
5554
5555 memset(buf, 0xff, buf_size);
5556 ret = InternetReadFile(req, buf, buf_size, &ret_size);
5557 ok_(__FILE__,line)(ret, "InternetReadFileExW failed: %u\n", GetLastError());
5558 ok_(__FILE__,line)(ret_size == len, "dwBufferLength = %u, expected %u\n", ret_size, len);
5559 if(len && exdata)
5560 ok_(__FILE__,line)(!memcmp(buf, exdata, len), "Unexpected data\n");
5561
5565 ok_(__FILE__,line)(received_response_size == len, "received_response_size = %u\n", received_response_size);
5566 ok_(__FILE__,line)(!req_error, "req_error = %u\n", req_error);
5567}
5568
5569#define read_expect_sync_data(a,b,c,d) _read_expect_sync_data(__LINE__,a,b,c,d)
5570static void _read_expect_sync_data(unsigned line, HINTERNET req, void *buf,
5571 DWORD buf_size, const char *exdata)
5572{
5573 _read_expect_sync_data_len(line, req, buf, buf_size, exdata, strlen(exdata));
5574}
5575
5576static void close_connection(void)
5577{
5578 char c;
5580 recv(server_socket, &c, 1, 0);
5581}
5582
5583#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)
5584static void _send_response_and_wait(unsigned line, const char *response, BOOL do_close_connection,
5585 void *buf, DWORD *ret_size, const char *exdata,
5586 DWORD expected_size, DWORD expected_req_error, DWORD expected_receive_size)
5587{
5591
5592 if(response)
5593 server_send_string(response);
5594
5595 if(do_close_connection)
5597
5599
5603 if(!skip_receive_notification_tests && expected_receive_size != -1)
5604 todo_wine_if(received_response_size != expected_receive_size) /* FIXME! remove when wine is fixed */
5605 ok_(__FILE__,line)(received_response_size == expected_receive_size,
5606 "received_response_size = %u\n", received_response_size);
5607 ok_(__FILE__,line)(req_error == expected_req_error, "req_error = %u, expected %u\n", req_error, expected_req_error);
5608
5609 /* If IRF_NO_WAIT is used, buffer is not changed. */
5610 ok_(__FILE__,line)(*ret_size == expected_size, "dwBufferLength = %u\n", *ret_size);
5611 if(exdata)
5612 ok_(__FILE__,line)(!memcmp(buf, exdata, strlen(exdata)), "unexpected buffer data\n");
5613 else if(buf)
5614 ok_(__FILE__,line)(!*(DWORD*)buf, "buffer data changed\n");
5615}
5616
5617#define send_response_ex_and_wait(a,b,c,d,e,f) _send_response_ex_and_wait(__LINE__,a,b,c,d,e,f)
5618static void _send_response_ex_and_wait(unsigned line, const char *response, BOOL close_connection,
5619 INTERNET_BUFFERSW *buf, const char *exdata, DWORD expected_req_error,
5620 DWORD expected_receive_size)
5621{
5622 _send_response_and_wait(line, response, close_connection, buf->lpvBuffer, &buf->dwBufferLength,
5623 exdata, exdata ? strlen(exdata) : buf->dwBufferLength, expected_req_error,
5624 expected_receive_size);
5625}
5626
5628{
5629 char *response;
5630
5631 response = HeapAlloc(GetProcessHeap(), 0, len+1);
5632 memset(response, 'x', len);
5633 response[len] = 0;
5635 HeapFree(GetProcessHeap(), 0, response);
5636}
5637
5638#define readex_expect_async(a,b,c,d,e) _readex_expect_async(__LINE__,a,b,c,d,e)
5640 DWORD buf_size, const char *exdata)
5641{
5642 unsigned len = 0;
5643 BOOL ret;
5644
5647
5648 memset(buf->lpvBuffer, 0, max(buf_size, sizeof(DWORD)));
5649 buf->dwBufferLength = buf_size;
5650 ret = InternetReadFileExW(req, buf, flags, 0xdeadbeef);
5651 ok_(__FILE__,line)(!ret && GetLastError() == ERROR_IO_PENDING, "InternetReadFileExW returned %x (%u)\n", ret, GetLastError());
5652 ok_(__FILE__,line)(buf->dwBufferLength == buf_size, "dwBufferLength = %u, expected %u\n", buf->dwBufferLength, buf_size);
5653 if(exdata) {
5654 len = strlen(exdata);
5655 ok_(__FILE__,line)(!memcmp(buf->lpvBuffer, exdata, len), "unexpected buffer data\n");
5656 }else {
5657 ok_(__FILE__,line)(!*(DWORD*)buf->lpvBuffer, "buffer data changed\n");
5658 }
5659
5662}
5663
5664static void read_expect_async(HINTERNET req, void *buf, DWORD buf_size, DWORD *ret_size, const char *exdata)
5665{
5666 unsigned len = 0;
5667 const char *p;
5668 BOOL ret;
5669
5671
5672 *ret_size = 0xdeadbeef;
5673 memset(buf, 0, buf_size);
5674 ret = InternetReadFile(req, buf, buf_size, ret_size);
5675 ok(!ret && GetLastError() == ERROR_IO_PENDING, "InternetReadFileExW returned %x (%u)\n", ret, GetLastError());
5676 ok(*ret_size == 0, "dwBufferLength = %u\n", *ret_size);
5677 if(exdata) {
5678 len = strlen(exdata);
5679 ok(!memcmp(buf, exdata, len), "unexpected buffer data\n");
5680 }
5681 for(p = (const char*)buf + len; p < (const char*)buf + buf_size; p++) {
5682 if(*p)
5683 ok(0, "buffer data changed\n");
5684 }
5685
5687}
5688
5689#define expect_data_available(a,b) _expect_data_available(__LINE__,a,b)
5690static DWORD _expect_data_available(unsigned line, HINTERNET req, int exsize)
5691{
5692 DWORD size = 0;
5693 BOOL res;
5694
5695 res = InternetQueryDataAvailable(req, &size, 0, 0);
5696 ok_(__FILE__,line)(res, "InternetQueryDataAvailable failed: %u\n", GetLastError());
5697 if(exsize != -1)
5698 ok_(__FILE__,line)(size == exsize, "size = %u, expected %u\n", size, exsize);
5699
5700 return size;
5701}
5702
5703#define async_query_data_available(a,b) _async_query_data_available(__LINE__,a,b)
5705{
5706 BOOL res;
5707
5710
5711 *size = 0xdeadbeef;
5712 res = InternetQueryDataAvailable(req, size, 0, 0);
5713 ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING,
5714 "InternetQueryDataAvailable returned: %x(%u)\n", res, GetLastError());
5715 ok_(__FILE__,line)(!*size, "size = %u\n", *size);
5716
5719}
5720
5721static void test_http_read(int port)
5722{
5724 test_request_t req;
5725 DWORD read_size;
5726 char buf[24000];
5727 DWORD avail, i;
5728
5729 if(!is_ie7plus)
5730 return;
5731
5732 memset(&ib, 0, sizeof(ib));
5733 ib.dwStructSize = sizeof(ib);
5734 ib.lpvBuffer = buf;
5735
5736 trace("Testing InternetReadFileExW with IRF_ASYNC flag...\n");
5737
5739 "HTTP/1.1 200 OK\r\n"
5740 "Server: winetest\r\n"
5741 "\r\n"
5742 "xx");
5743
5744 readex_expect_async(req.request, IRF_ASYNC, &ib, 4, "xx");
5745
5746 send_response_ex_and_wait("yy1234567890", FALSE, &ib, "xxyy", 0, 2);
5747 readex_expect_sync_data(req.request, IRF_ASYNC, &ib, 4, "1234", 4);
5748 readex_expect_sync_data(req.request, IRF_ASYNC, &ib, 5, "56789", 5);
5749
5750 readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), "0");
5751 send_response_ex_and_wait("123", TRUE, &ib, "0123", 0, 4);
5752
5754
5755 trace("Testing InternetReadFileExW with no flags...\n");
5756
5758 "HTTP/1.1 200 OK\r\n"
5759 "Server: winetest\r\n"
5760 "\r\n"
5761 "xx");
5762
5763 readex_expect_async(req.request, 0, &ib, 4, "xx");
5764
5765 send_response_ex_and_wait("yy1234567890", FALSE, &ib, "xxyy", 0, 2);
5766 readex_expect_sync_data(req.request, 0, &ib, 4, "1234", 4);
5767 readex_expect_sync_data(req.request, 0, &ib, 5, "56789", 5);
5768
5769 readex_expect_async(req.request, 0, &ib, sizeof(buf), "0");
5770 send_response_ex_and_wait("123", TRUE, &ib, "0123", 0, 4);
5771
5773
5774 trace("Testing InternetReadFile...\n");
5775
5777 "HTTP/1.1 200 OK\r\n"
5778 "Server: winetest\r\n"
5779 "\r\n"
5780 "xx");
5781
5782 read_expect_async(req.request, buf, 4, &read_size, "xx");
5783
5784 send_response_and_wait("yy1234567890", FALSE, buf, &read_size, "xxyy", 4, 0, 2);
5785 read_expect_sync_data(req.request, buf, 4, "1234");
5786 read_expect_sync_data(req.request, buf, 5, "56789");
5787
5788 read_expect_async(req.request, buf, sizeof(buf), &read_size, "0");
5789 send_response_and_wait("123", TRUE, buf, &read_size, "0123", 4, 0, 4);
5790
5792
5793 trace("Testing InternetReadFileExW with IRF_NO_WAIT flag...\n");
5794
5796 "HTTP/1.1 200 OK\r\n"
5797 "Server: winetest\r\n"
5798 "\r\n"
5799 "xx");
5800
5802
5803 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "xx", 0);
5804
5806 win_skip("Skipping receive notification tests on too old Windows.\n");
5808 }
5810
5811 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
5812 send_response_ex_and_wait("1234567890", FALSE, &ib, NULL, 0, 10);
5813 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, 5, "12345", 0);
5814 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "67890", 0);
5815
5816 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
5817 send_response_ex_and_wait("12345", TRUE, &ib, NULL, 0, 5);
5818
5819 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "12345", 0);
5820 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", TRUE);
5821
5823
5825 "HTTP/1.1 200 OK\r\n"
5826 "Server: winetest\r\n"
5827 "Transfer-Encoding: chunked\r\n"
5828 "\r\n"
5829 "9\r\n123456789");
5830 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123456789", 0);
5831 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
5832
5833 send_response_ex_and_wait("\r\n1\r\na\r\n1\r\nb\r", FALSE, &ib, NULL, 0, 13);
5834 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0);
5835 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
5836
5837 send_response_ex_and_wait("\n3\r\nab", FALSE, &ib, NULL, 0, 6);
5838 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0);
5839 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
5840
5841 send_response_ex_and_wait("c", FALSE, &ib, NULL, 0, 1);
5842 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "c", 0);
5843 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
5844
5845 send_response_ex_and_wait("\r\n1\r\nx\r\n0\r\n\r\n", TRUE, &ib, NULL, 0, 13);
5846 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "x", 0);
5847 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", 0);
5848
5850
5852 "HTTP/1.1 200 OK\r\n"
5853 "Server: winetest\r\n"
5854 "Transfer-Encoding: chunked\r\n"
5855 "\r\n"
5856 "3\r\n123\r\n");
5857 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123", 0);
5858 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
5859
5860 send_response_ex_and_wait("0\r\n\r\n", TRUE, &ib, NULL, 0, 5);
5861 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", 0);
5862
5864
5866 "HTTP/1.1 200 OK\r\n"
5867 "Server: winetest\r\n"
5868 "Connection: close\r\n"
5869 "\r\n");
5870 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
5871 send_response_ex_and_wait("123", TRUE, &ib, NULL, 0, 3);
5872 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123", 0);
5873
5879
5880 trace("Testing InternetQueryDataAvailable...\n");
5881
5883 "HTTP/1.1 200 OK\r\n"
5884 "Server: winetest\r\n"
5885 "\r\n"
5886 "123");
5888 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123", 0);
5889 readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL);
5890
5891 send_response_len_and_wait(20000, TRUE, &ib);
5893 ok(avail <= 20000, "avail = %u\n", avail);
5894
5900
5902 "HTTP/1.1 200 OK\r\n"
5903 "Server: winetest\r\n"
5904 "Connection: close\r\n"
5905 "\r\n"
5906 "123");
5907
5909 readex_expect_sync_data(req.request, 0, &ib, 3, "123", 0);
5910
5911 async_query_data_available(req.request, &read_size);
5912 send_response_and_wait("1234567890", FALSE, NULL, &read_size, NULL, 10, 10, 10);
5913
5914 readex_expect_sync_data(req.request, 0, &ib, 9, "123456789", 0);
5916 readex_expect_sync_data(req.request, 0, &ib, 1, "0", 0);
5917
5918 async_query_data_available(req.request, &read_size);
5919 send_response_and_wait("1234567890", FALSE, NULL, &read_size, NULL, 10, 10, 10);
5921 for(i = 0; i < 10; i++)
5922 server_send_string("x");
5924
5925 readex_expect_async(req.request, IRF_ASYNC, &ib, 21, "1234567890");
5926 send_response_ex_and_wait("X", FALSE, &ib, "1234567890xxxxxxxxxxX", 0, 11);
5927 async_query_data_available(req.request, &read_size);
5928
5931 send_response_and_wait(NULL, TRUE, NULL, &read_size, NULL, 0, 0, 0);
5934
5936
5938}
5939
5941{
5943 test_request_t req;
5944 char buf[24000];
5945
5946 if(!is_ie7plus)
5947 return;
5948
5949 memset(&ib, 0, sizeof(ib));
5950 ib.dwStructSize = sizeof(ib);
5951 ib.lpvBuffer = buf;
5952
5953 trace("Testing InternetReadFileExW on broken connection...\n");
5954
5956 "HTTP/1.1 200 OK\r\n"
5957 "Server: winetest\r\n"
5958 "Content-Length: 10000\r\n"
5959 "\r\n"
5960 "xx");
5961
5962 /* close connection and make sure that it's closed on handle release. */
5969}
5970
5971static void test_long_url(int port)
5972{
5973 char long_path[INTERNET_MAX_PATH_LENGTH*2] = "/echo_request?";
5974 char buf[sizeof(long_path)*2], url[sizeof(buf)];
5975 test_request_t req;
5976 DWORD size, len;
5977 BOOL ret;
5978
5979 if(!is_ie7plus)
5980 return;
5981
5982 memset(long_path+strlen(long_path), 'x', sizeof(long_path)-strlen(long_path));
5983 long_path[sizeof(long_path)-1] = 0;
5984 open_simple_request(&req, "localhost", port, NULL, long_path);
5985
5986 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
5987 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
5988 test_status_code(req.request, 200);
5989
5990 receive_simple_request(req.request, buf, sizeof(buf));
5991 ok(strstr(buf, long_path) != NULL, "long pathnot found in %s\n", buf);
5992
5993 sprintf(url, "http://localhost:%u%s", port, long_path);
5994
5995 size = sizeof(buf);
5997 ok(ret, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
5998 len = strlen(url);
5999 ok(size == len, "size = %u, expected %u\n", size, len);
6000 ok(!strcmp(buf, url), "Wrong URL %s, expected %s\n", buf, url);
6001
6002 close_request(&req);
6003}
6004
6006{
6008 test_request_t req;
6009 char buf[24000];
6010
6011 if(!is_ie7plus)
6012 return;
6013
6014 memset(&ib, 0, sizeof(ib));
6015 ib.dwStructSize = sizeof(ib);
6016 ib.lpvBuffer = buf;
6017
6019
6020 trace("Testing persistent connection...\n");
6021
6023 "HTTP/1.1 200 OK\r\n"
6024 "Server: winetest\r\n"
6025 "Content-Length: 2\r\n"
6026 "\r\n"
6027 "xx");
6028 readex_expect_sync_data(req.request, IRF_ASYNC, &ib, 4, "xx", 0);
6030
6031 open_socket_request(port, &req, "/test_simple_chunked");
6032 server_read_request("GET /test_simple_chunked HTTP/1.1");
6033
6035 server_send_string("HTTP/1.1 200 OK\r\n"
6036 "Server: winetest\r\n"
6037 "Transfer-Encoding: chunked\r\n"
6038 "\r\n"
6039 "2\r\nab\r\n");
6042 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error);
6043
6044 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0);
6045 readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), NULL);
6046 send_response_ex_and_wait("3\r\nabc\r\n0\r\n\r\n", FALSE, &ib, "abc", 0, 13);
6048
6049 open_socket_request(port, &req, "/chunked");
6050 server_read_request("GET /chunked HTTP/1.1");
6051
6053 server_send_string("HTTP/1.1 200 OK\r\n"
6054 "Server: winetest\r\n"
6055 "Transfer-Encoding: chunked\r\n"
6056 "\r\n"
6057 "2\r\nab\r\n");
6060 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error);
6061
6062 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, 3, "ab", 0);
6064 send_response_ex_and_wait("3\r\nabc\r\n", FALSE, &ib, "abc", 0, 13);
6065
6066 /* send another request on the same request handle, it must drain remaining last chunk marker */
6067 server_send_string("0\r\n\r\n");
6068
6070 server_read_request("GET /chunked HTTP/1.1");
6071
6074 server_send_string("HTTP/1.1 201 OK\r\n"
6075 "Server: winetest\r\n"
6076 "Content-Length: 0\r\n"
6077 "Connection: keep-alive\r\n"
6078 "\r\n");
6081 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error);
6082
6083 test_status_code(req.request, 201);
6085
6086 /* the connection is still valid */
6087 open_socket_request(port, &req, "/another_chunked");
6088 server_read_request("GET /another_chunked HTTP/1.1");
6089
6091 server_send_string("HTTP/1.1 200 OK\r\n"
6092 "Server: winetest\r\n"
6093 "Transfer-Encoding: chunked\r\n"
6094 "\r\n"
6095 "2\r\nab\r\n");
6098 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error);
6099
6100 readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0);
6101 readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), NULL);
6102
6103 /* we're missing trailing '\n'; the connection can't be drained without blocking,
6104 * so it will be closed */
6105 send_response_ex_and_wait("3\r\nabc\r\n0\r\n\r", FALSE, &ib, "abc", 0, 13);
6106
6112
6115}
6116
6117static void test_redirect(int port)
6118{
6119 char buf[4000], expect_url[INTERNET_MAX_URL_LENGTH];
6121 test_request_t req;
6122
6123 if(!is_ie7plus)
6124 return;
6125
6127
6128 memset(&ib, 0, sizeof(ib));
6129 ib.dwStructSize = sizeof(ib);
6130 ib.lpvBuffer = buf;
6131
6132 trace("Testing redirection...\n");
6133
6135
6140
6141 server_send_string("HTTP/1.1 302 Found\r\n"
6142 "Server: winetest\r\n"
6143 "Location: test_redirection\r\n"
6144 "Connection: keep-alive\r\n"
6145 "Content-Length: 0\r\n"
6146 "\r\n");
6147
6148 server_read_request("GET /test_redirection HTTP/1.1");
6149
6151
6152 sprintf(expect_url, "http://localhost:%u/test_redirection", port);
6153 test_request_url(req.request, expect_url);
6154
6156
6157 server_send_string("HTTP/1.1 200 OK\r\n"
6158 "Server: winetest\r\n"
6159 "Content-Length: 3\r\n"
6160 "\r\n"
6161 "xxx");
6162
6164
6169 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error);
6170
6171 test_status_code(req.request, 200);
6172
6175
6176 trace("Test redirect to non-http URL...\n");
6177
6179
6181
6182 server_send_string("HTTP/1.1 302 Found\r\n"
6183 "Server: winetest\r\n"
6184 "Location: test:non:http/url\r\n"
6185 "Connection: keep-alive\r\n"
6186 "Content-Length: 0\r\n"
6187 "\r\n");
6188
6190
6192 ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error);
6193
6194 sprintf(expect_url, "http://localhost:%u/socket", port);
6195 test_request_url(req.request, expect_url);
6196 test_status_code(req.request, 302);
6197
6200
6201 trace("Test redirect to http URL with no host name...\n");
6202
6204
6206
6207 server_send_string("HTTP/1.1 302 Found\r\n"
6208 "Server: winetest\r\n"
6209 "Location: http:///nohost\r\n"
6210 "Connection: keep-alive\r\n"
6211 "Content-Length: 0\r\n"
6212 "\r\n");
6213
6215
6217 ok(req_error == ERROR_INTERNET_INVALID_URL, "expected ERROR_INTERNET_INVALID_URL, got %u\n", req_error);
6218
6219 sprintf(expect_url, "http://localhost:%u/socket", port);
6220 test_request_url(req.request, expect_url);
6221 test_status_code(req.request, 302);
6222
6225
6227}
6228
6230{
6231 test_request_t req;
6232 BOOL ret;
6233
6234 open_simple_request(&req, "localhost", port, NULL, "/A/../B/./C/../../test_remove_dot_segments");
6235
6236 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
6237 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
6238 test_status_code(req.request, 200);
6239
6240 close_request(&req);
6241}
6242
6244{
6247};
6248
6249static void test_large_content(int port)
6250{
6251 struct large_test tests[] = {
6252 { 0, TRUE },
6253 { UINT_MAX-1, TRUE },
6254 { UINT_MAX, TRUE },
6255 { (DWORD64)UINT_MAX+1, FALSE },
6256 { ~0, FALSE },
6257 };
6258 test_request_t req;
6259 DWORD sizelen, len;
6260 DWORD read_size;
6261 DWORD64 len64;
6262 char buf[16];
6263 BOOL ret;
6264 size_t i;
6265
6266 open_simple_request(&req, "localhost", port, "HEAD", "/test_large_content");
6267
6268 for (i = 0; i < ARRAY_SIZE(tests); i++)
6269 {
6270 content_length = tests[i].content_length;
6271 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
6272 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
6273
6274 len = ~0;
6275 sizelen = sizeof(len);
6276 SetLastError(0xdeadbeef);
6278 &len, &sizelen, 0);
6279 if (tests[i].ret)
6280 {
6281 ok(ret, "HttpQueryInfo should have succeeded\n");
6283 broken(GetLastError() == 0xdeadbeef), /* xp, 2k8, vista */
6284 "expected ERROR_SUCCESS, got %x\n", GetLastError());
6285 ok(len == (DWORD)tests[i].content_length, "expected %u, got %u\n",
6287 }
6288 else
6289 {
6290 ok(!ret, "HttpQueryInfo should have failed\n");
6292 "expected ERROR_HTTP_INVALID_HEADER, got %x\n", GetLastError());
6293 ok(len == ~0, "expected ~0, got %u\n", len);
6294 }
6295 ok(sizelen == sizeof(DWORD), "sizelen %u\n", sizelen);
6296 }
6297
6298 /* test argument size */
6299 len64 = ~0;
6300 sizelen = sizeof(len64);
6301 SetLastError(0xdeadbeef);
6303 &len64, &len, 0);
6304 ok(!ret, "HttpQueryInfo should have failed\n");
6306 "expected ERROR_HTTP_INVALID_HEADER, got %x\n", GetLastError());
6307 ok(sizelen == sizeof(DWORD64), "sizelen %u\n", sizelen);
6308 ok(len64 == ~0, "len64 %x%08x\n", (DWORD)(len64 >> 32), (DWORD)len64);
6309
6310 close_request(&req);
6311
6312 /* test internal use of HttpQueryInfo on large size */
6314 "HTTP/1.1 200 OK\r\n"
6315 "Server: winetest\r\n"
6316 "Content-Length: 4294967296\r\n"
6317 "\r\n"
6318 "xx");
6319 read_expect_async(req.request, buf, 4, &read_size, "xx");
6320 send_response_and_wait("yy1234567890", FALSE, buf, &read_size, "xxyy", 4, 0, 2);
6321 read_expect_sync_data(req.request, buf, 10, "1234567890");
6322
6329}
6330
6331static void test_http_connection(void)
6332{
6333 struct server_info si;
6335 DWORD id = 0, r;
6336
6337 si.hEvent = CreateEventW(NULL, 0, 0, NULL);
6338 si.port = 7531;
6339
6340 hThread = CreateThread(NULL, 0, server_thread, &si, 0, &id);
6341 ok( hThread != NULL, "create thread failed\n");
6342
6343 r = WaitForSingleObject(si.hEvent, 10000);
6344 ok (r == WAIT_OBJECT_0, "failed to start wininet test server\n");
6345 if (r != WAIT_OBJECT_0)
6346 {
6348 return;
6349 }
6350
6351 test_basic_request(si.port, "GET", "/test1");
6355 test_basic_request(si.port, "POST", "/test5");
6356 test_basic_request(si.port, "RPC_IN_DATA", "/test5");
6357 test_basic_request(si.port, "RPC_OUT_DATA", "/test5");
6358 test_basic_request(si.port, "GET", "/test6");
6359 test_basic_request(si.port, "GET", "/testF");
6368 test_options(si.port);
6371 test_no_cache(si.port);
6387 test_http_read(si.port);
6389 test_long_url(si.port);
6390#ifdef __REACTOS__
6392{
6393 skip("Skipping test_redirect and test_persistent_connection due to hang. See ROSTESTS-294.\n");
6394}
6395else
6396{
6397#endif
6398 test_redirect(si.port);
6400#ifdef __REACTOS__
6401}
6402#endif
6405
6406 /* send the basic request again to shutdown the server thread */
6407 test_basic_request(si.port, "GET", "/quit");
6408
6409 r = WaitForSingleObject(hThread, 3000);
6410 ok( r == WAIT_OBJECT_0, "thread wait failed\n");
6412}
6413
6415{
6416 LocalFree(info->lpszSubjectInfo);
6417 LocalFree(info->lpszIssuerInfo);
6418 LocalFree(info->lpszProtocolName);
6419 LocalFree(info->lpszSignatureAlgName);
6420 LocalFree(info->lpszEncryptionAlgName);
6421}
6422
6423typedef struct {
6424 const char *ex_subject;
6425 const char *ex_issuer;
6427
6429 "US\r\n"
6430 "55114\r\n"
6431 "Minnesota\r\n"
6432 "Saint Paul\r\n"
6433 "Ste 120\r\n"
6434 "700 Raymond Ave\r\n"
6435 "CodeWeavers\r\n"
6436 "IT\r\n"
6437 "*.winehq.org",
6438
6439 "US\r\n"
6440 "VA\r\n"
6441 "Herndon\r\n"
6442 "Network Solutions L.L.C.\r\n"
6443 "Network Solutions OV Server CA 2"
6444};
6445
6447 "US\r\n"
6448 "Minnesota\r\n"
6449 "Saint Paul\r\n"
6450 "WineHQ\r\n"
6451 "IT\r\n"
6452 "test.winehq.com\r\n"
6453 "webmaster@winehq.org",
6454
6455 "US\r\n"
6456 "Minnesota\r\n"
6457 "Saint Paul\r\n"
6458 "WineHQ\r\n"
6459 "IT\r\n"
6460 "test.winehq.com\r\n"
6461 "webmaster@winehq.org"
6462};
6463
6464static const char *cert_string_fmt =
6465 "Subject:\r\n%s\r\n"
6466 "Issuer:\r\n%s\r\n"
6467 "Effective Date:\t%s %s\r\n"
6468 "Expiration Date:\t%s %s\r\n"
6469 "Security Protocol:\t%s\r\n"
6470 "Signature Type:\t%s\r\n"
6471 "Encryption Type:\t%s\r\n"
6472 "Privacy Strength:\t%s (%u bits)";
6473
6475{
6476 SYSTEMTIME start, expiry;
6477 char expiry_date[32];
6478 char expiry_time[32];
6479 char start_date[32];
6480 char start_time[32];
6481 char expect[512];
6482 char actual[512];
6483 DWORD size;
6484 BOOL res;
6485
6486 size = sizeof(actual);
6487 SetLastError(0xdeadbeef);
6488 memset(actual, 0x55, sizeof(actual));
6490 ok(res, "InternetQueryOption failed: %u\n", GetLastError());
6491
6492 FileTimeToSystemTime(&info->ftStart, &start);
6493 FileTimeToSystemTime(&info->ftExpiry, &expiry);
6494
6495 GetDateFormatA(LOCALE_USER_DEFAULT, 0, &start, NULL, start_date, sizeof(start_date));
6496 GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &start, NULL, start_time, sizeof(start_time));
6497 GetDateFormatA(LOCALE_USER_DEFAULT, 0, &expiry, NULL, expiry_date, sizeof(expiry_date));
6498 GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &expiry, NULL, expiry_time, sizeof(expiry_time));
6499
6500 snprintf(expect, sizeof(expect), cert_string_fmt, info->lpszSubjectInfo, info->lpszIssuerInfo,
6501 start_date, start_time, expiry_date, expiry_time,
6502 info->lpszSignatureAlgName, info->lpszEncryptionAlgName, info->lpszProtocolName,
6503 info->dwKeySize >= 128 ? "High" : "Low", info->dwKeySize);
6504 ok(size == strlen(actual), "size = %u\n", size);
6505 ok(!strcmp(actual, expect), "expected:\n%s\nactual:\n%s\n", expect, actual);
6506
6507 --size;
6508 SetLastError(0xdeadbeef);
6509 memset(actual, 0x55, sizeof(actual));
6511 ok(!res && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %d\n", GetLastError());
6512 ok(size == 1, "unexpected size: %u\n", size);
6513 ok(actual[0] == 0x55, "unexpected byte: %02x\n", actual[0]);
6514}
6515
6517{
6519 DWORD size;
6520 BOOL res;
6521
6522 memset(&info, 0x5, sizeof(info));
6523
6524 size = sizeof(info);
6526 if (!res)
6527 {
6528 win_skip("Querying INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT failed, skipping tests\n");
6529 return;
6530 }
6531
6532 ok(res, "InternetQueryOption failed: %u\n", GetLastError());
6533 ok(size == sizeof(info), "size = %u\n", size);
6534
6535 ok(!strcmp(info.lpszSubjectInfo, test->ex_subject), "lpszSubjectInfo = %s\n", info.lpszSubjectInfo);
6536 ok(!strcmp(info.lpszIssuerInfo, test->ex_issuer), "lpszIssuerInfo = %s\n", info.lpszIssuerInfo);
6537 ok(!info.lpszSignatureAlgName, "lpszSignatureAlgName = %s\n", info.lpszSignatureAlgName);
6538 ok(!info.lpszEncryptionAlgName, "lpszEncryptionAlgName = %s\n", info.lpszEncryptionAlgName);
6539 ok(!info.lpszProtocolName, "lpszProtocolName = %s\n", info.lpszProtocolName);
6540 ok(info.dwKeySize >= 128 && info.dwKeySize <= 256, "dwKeySize = %u\n", info.dwKeySize);
6541
6542 if (is_lang_english())
6544 else
6545 skip("Skipping tests that are English-only\n");
6547}
6548
6549#define test_security_info(a,b,c) _test_security_info(__LINE__,a,b,c)
6550static void _test_security_info(unsigned line, const char *urlc, DWORD error, DWORD ex_flags)
6551{
6554 DWORD flags;
6555 BOOL res;
6556
6557 if(!pInternetGetSecurityInfoByURLA) {
6558 win_skip("pInternetGetSecurityInfoByURLA not available\n");
6559 return;
6560 }
6561
6562 strcpy(url, urlc);
6563 chain = (void*)0xdeadbeef;
6564 flags = 0xdeadbeef;
6565 res = pInternetGetSecurityInfoByURLA(url, &chain, &flags);
6566 if(error == ERROR_SUCCESS) {
6567 ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %u\n", GetLastError());
6568 ok_(__FILE__,line)(chain != NULL, "chain = NULL\n");
6569 ok_(__FILE__,line)(flags == ex_flags, "flags = %x\n", flags);
6571
6572 SetLastError(0xdeadbeef);
6573 res = pInternetGetSecurityInfoByURLA(url, NULL, NULL);
6574 ok_(__FILE__,line)(!res && GetLastError() == ERROR_INVALID_PARAMETER,
6575 "InternetGetSecurityInfoByURLA returned: %x(%u)\n", res, GetLastError());
6576
6577 res = pInternetGetSecurityInfoByURLA(url, &chain, NULL);
6578 ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %u\n", GetLastError());
6580
6581 res = pInternetGetSecurityInfoByURLA(url, NULL, &flags);
6582 ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %u\n", GetLastError());
6583 }else {
6584 ok_(__FILE__,line)(!res && GetLastError() == error,
6585 "InternetGetSecurityInfoByURLA returned: %x(%u), expected %u\n", res, GetLastError(), error);
6586 }
6587}
6588
6589#define test_secflags_option(a,b,c) _test_secflags_option(__LINE__,a,b,c)
6590static void _test_secflags_option(unsigned line, HINTERNET req, DWORD ex_flags, DWORD opt_flags)
6591{
6592 DWORD flags, size;
6593 BOOL res;
6594
6595 flags = 0xdeadbeef;
6596 size = sizeof(flags);
6598 ok_(__FILE__,line)(res, "InternetQueryOptionW(INTERNET_OPTION_SECURITY_FLAGS) failed: %u\n", GetLastError());
6599 ok_(__FILE__,line)((flags & ~opt_flags) == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS flags = %x, expected %x\n",
6600 flags, ex_flags);
6601
6602 /* Option 98 is undocumented and seems to be the same as INTERNET_OPTION_SECURITY_FLAGS */
6603 flags = 0xdeadbeef;
6604 size = sizeof(flags);
6605 res = InternetQueryOptionW(req, 98, &flags, &size);
6606 ok_(__FILE__,line)(res, "InternetQueryOptionW(98) failed: %u\n", GetLastError());
6607 ok_(__FILE__,line)((flags & ~opt_flags) == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS(98) flags = %x, expected %x\n",
6608 flags, ex_flags);
6609}
6610
6611#define set_secflags(a,b,c) _set_secflags(__LINE__,a,b,c)
6612static void _set_secflags(unsigned line, HINTERNET req, BOOL use_undoc, DWORD flags)
6613{
6614 BOOL res;
6615
6616 res = InternetSetOptionW(req, use_undoc ? 99 : INTERNET_OPTION_SECURITY_FLAGS, &flags, sizeof(flags));
6617 ok_(__FILE__,line)(res, "InternetSetOption(INTERNET_OPTION_SECURITY_FLAGS) failed: %u\n", GetLastError());
6618}
6619
6620static void test_security_flags(void)
6621{
6623 HINTERNET ses, conn, req;
6624 DWORD size, flags;
6625 char buf[512];
6626 BOOL res;
6627
6628 if (!https_support)
6629 {
6630 win_skip("Can't make https connections, skipping security flags test\n");
6631 return;
6632 }
6633
6634 trace("Testing security flags...\n");
6635 reset_events();
6636
6638 ok(ses != NULL, "InternetOpen failed\n");
6639
6640 pInternetSetStatusCallbackA(ses, &callback);
6641
6643 conn = InternetConnectA(ses, "test.winehq.com", INTERNET_DEFAULT_HTTPS_PORT,
6645 ok(conn != NULL, "InternetConnect failed with error %u\n", GetLastError());
6647
6649 req = HttpOpenRequestA(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
6651 0xdeadbeef);
6652 ok(req != NULL, "HttpOpenRequest failed\n");
6654
6655 flags = 0xdeadbeef;
6656 size = sizeof(flags);
6657 res = InternetQueryOptionW(req, 98, &flags, &size);
6659 win_skip("Incomplete security flags support, skipping\n");
6660
6661 close_async_handle(ses, 2);
6662 return;
6663 }
6664
6665 test_secflags_option(req, 0, 0);
6666 test_security_info("https://test.winehq.com/data/some_file.html?q", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
6667
6670
6673
6676
6678 res = InternetSetOptionW(req, 99, &flags, sizeof(flags));
6679 ok(!res && GetLastError() == ERROR_INTERNET_OPTION_NOT_SETTABLE, "InternetSetOption(99) failed: %u\n", GetLastError());
6680
6685 SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
6696
6697 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
6698 ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError());
6699
6701 ok(req_error == ERROR_SUCCESS, "req_error = %d\n", req_error);
6702
6716
6717 test_request_flags(req, 0);
6720
6721 res = InternetReadFile(req, buf, sizeof(buf), &size);
6722 ok(res, "InternetReadFile failed: %u\n", GetLastError());
6723 ok(size, "size = 0\n");
6724
6725 /* Collect all existing persistent connections */
6727 ok(res, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
6728
6730 req = HttpOpenRequestA(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
6732 0xdeadbeef);
6733 ok(req != NULL, "HttpOpenRequest failed\n");
6735
6738 ok(res, "InternetQueryOption(INTERNET_OPTION_ERROR_MASK failed: %u\n", GetLastError());
6739
6742 SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
6751
6752 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
6753 ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError());
6754
6757 "req_error = %d\n", req_error);
6758
6759 size = 0;
6761 ok(res || GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %d\n", GetLastError());
6762 ok(size == sizeof(INTERNET_CERTIFICATE_INFOA), "size = %u\n", size);
6764 cert->lpszSubjectInfo = NULL;
6765 cert->lpszIssuerInfo = NULL;
6766 cert->lpszSignatureAlgName = (char *)0xdeadbeef;
6767 cert->lpszEncryptionAlgName = (char *)0xdeadbeef;
6768 cert->lpszProtocolName = (char *)0xdeadbeef;
6769 cert->dwKeySize = 0xdeadbeef;
6771 ok(res, "InternetQueryOption failed: %u\n", GetLastError());
6772 if (res)
6773 {
6774 ok(cert->lpszSubjectInfo && strlen(cert->lpszSubjectInfo) > 1, "expected a non-empty subject name\n");
6775 ok(cert->lpszIssuerInfo && strlen(cert->lpszIssuerInfo) > 1, "expected a non-empty issuer name\n");
6776 ok(!cert->lpszSignatureAlgName, "unexpected signature algorithm name\n");
6777 ok(!cert->lpszEncryptionAlgName, "unexpected encryption algorithm name\n");
6778 ok(!cert->lpszProtocolName, "unexpected protocol name\n");
6779 ok(cert->dwKeySize != 0xdeadbeef, "unexpected key size\n");
6780
6781 LocalFree(cert->lpszSubjectInfo);
6782 LocalFree(cert->lpszIssuerInfo);
6783 }
6785
6786 SetLastError(0xdeadbeef);
6788 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER, "InternetQueryOption failed: %d\n", GetLastError());
6789
6790 size = 0;
6791 SetLastError(0xdeadbeef);
6793 ok(!res && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %d\n", GetLastError());
6794 ok(size == 1, "unexpected size: %u\n", size);
6795
6796 size = 42;
6797 SetLastError(0xdeadbeef);
6798 memset(buf, 0x55, sizeof(buf));
6800 ok(!res && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %d\n", GetLastError());
6801 ok(size == 1, "unexpected size: %u\n", size);
6802 ok(buf[0] == 0x55, "unexpected byte: %02x\n", buf[0]);
6803
6804 size = sizeof(buf);
6805 SetLastError(0xdeadbeef);
6807 ok(res && GetLastError() == ERROR_SUCCESS, "InternetQueryOption failed: %d\n", GetLastError());
6808 ok(size < sizeof(buf), "unexpected size: %u\n", size);
6809
6818
6820 win_skip("Unexpected cert errors %u, skipping security flags tests\n", req_error);
6821
6822 close_async_handle(ses, 3);
6823 return;
6824 }
6825
6826 size = sizeof(buf);
6828 ok(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfoA(HTTP_QUERY_CONTENT_ENCODING) failed: %u\n", GetLastError());
6829
6830 test_request_flags(req, 8);
6831 /* IE11 finds both rev failure and invalid CA. Previous versions required rev failure
6832 to be ignored before invalid CA was reported. */
6834
6837
6845
6846 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
6847 ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError());
6848
6851
6859
6862 test_security_info("https://test.winehq.com/data/some_file.html?q", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
6863
6867 test_http_version(req);
6868
6871 SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
6882
6883 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
6884 ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError());
6885
6887 ok(req_error == ERROR_SUCCESS, "req_error = %d\n", req_error);
6888
6900
6901 test_request_flags(req, 0);
6904
6906 test_security_info("https://test.winehq.com/data/some_file.html?q", 0,
6908
6909 res = InternetReadFile(req, buf, sizeof(buf), &size);
6910 ok(res, "InternetReadFile failed: %u\n", GetLastError());
6911 ok(size, "size = 0\n");
6912
6913 close_async_handle(ses, 3);
6914
6915 /* Collect all existing persistent connections */
6917 ok(res, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
6918
6919 /* Make another request, without setting security flags */
6920
6922 ok(ses != NULL, "InternetOpen failed\n");
6923
6924 pInternetSetStatusCallbackA(ses, &callback);
6925
6927 conn = InternetConnectA(ses, "test.winehq.com", INTERNET_DEFAULT_HTTPS_PORT,
6929 ok(conn != NULL, "InternetConnect failed with error %u\n", GetLastError());
6931
6933 req = HttpOpenRequestA(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
6935 0xdeadbeef);
6936 ok(req != NULL, "HttpOpenRequest failed\n");
6938
6941 test_http_version(req);
6942
6945 SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
6955
6956 res = HttpSendRequestA(req, NULL, 0, NULL, 0);
6957 ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError());
6958
6960 ok(req_error == ERROR_SUCCESS, "req_error = %d\n", req_error);
6961
6972
6973 test_request_flags(req, 0);
6976
6977 res = InternetReadFile(req, buf, sizeof(buf), &size);
6978 ok(res, "InternetReadFile failed: %u\n", GetLastError());
6979 ok(size, "size = 0\n");
6980
6981 close_async_handle(ses, 2);
6982
6983 test_security_info("http://test.winehq.com/data/some_file.html?q", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
6984 test_security_info("file:///c:/dir/file.txt", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
6985 test_security_info("xxx:///c:/dir/file.txt", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
6986}
6987
6988static void test_secure_connection(void)
6989{
6990 static const WCHAR gizmo5[] = {'G','i','z','m','o','5',0};
6991 static const WCHAR testsite[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
6992 static const WCHAR get[] = {'G','E','T',0};
6993 static const WCHAR testpage[] = {'/','t','e','s','t','s','/','h','e','l','l','o','.','h','t','m','l',0};
6994 HINTERNET ses, con, req;
6995 DWORD size, size2, flags, err;
6996 INTERNET_CERTIFICATE_INFOA *certificate_structA = NULL;
6997 INTERNET_CERTIFICATE_INFOW *certificate_structW = NULL;
6998 char certstr1[512], certstr2[512];
6999 BOOL ret;
7000
7002 ok(ses != NULL, "InternetOpen failed\n");
7003
7004 con = InternetConnectA(ses, "test.winehq.org",
7006 INTERNET_SERVICE_HTTP, 0, 0);
7007 ok(con != NULL, "InternetConnect failed\n");
7008
7009 req = HttpOpenRequestA(con, "GET", "/tests/hello.html", NULL, NULL, NULL,
7011 ok(req != NULL, "HttpOpenRequest failed\n");
7012
7013 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
7014 err = GetLastError();
7016 broken(err == ERROR_INTERNET_SECURITY_CHANNEL_ERROR), "HttpSendRequest failed: %u\n", err);
7017 if (!ret)
7018 {
7019 win_skip("Cannot connect to https.\n");
7021 goto done;
7022 }
7023
7024 size = sizeof(flags);
7026 ok(ret, "InternetQueryOption failed: %d\n", GetLastError());
7027 ok(flags & SECURITY_FLAG_SECURE, "expected secure flag to be set\n");
7028
7030
7031 /* Querying the same option through InternetQueryOptionW still results in
7032 * ASCII strings being returned.
7033 */
7034 size = 0;
7036 NULL, &size);
7037 ok(ret || GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %d\n", GetLastError());
7038 ok(size == sizeof(INTERNET_CERTIFICATE_INFOW), "size = %d\n", size);
7039 certificate_structW = HeapAlloc(GetProcessHeap(), 0, size);
7041 certificate_structW, &size);
7042 certificate_structA = (INTERNET_CERTIFICATE_INFOA *)certificate_structW;
7043 ok(ret, "InternetQueryOption failed: %d\n", GetLastError());
7044 if (ret)
7045 {
7046 ok(certificate_structA->lpszSubjectInfo &&
7047 strlen(certificate_structA->lpszSubjectInfo) > 1,
7048 "expected a non-empty subject name\n");
7049 ok(certificate_structA->lpszIssuerInfo &&
7050 strlen(certificate_structA->lpszIssuerInfo) > 1,
7051 "expected a non-empty issuer name\n");
7052 ok(!certificate_structA->lpszSignatureAlgName,
7053 "unexpected signature algorithm name\n");
7054 ok(!certificate_structA->lpszEncryptionAlgName,
7055 "unexpected encryption algorithm name\n");
7056 ok(!certificate_structA->lpszProtocolName,
7057 "unexpected protocol name\n");
7058 ok(certificate_structA->dwKeySize, "expected a non-zero key size\n");
7059 release_cert_info(certificate_structA);
7060 }
7061 HeapFree(GetProcessHeap(), 0, certificate_structW);
7062
7063 SetLastError(0xdeadbeef);
7064 size = sizeof(certstr1);
7066 ok(ret && GetLastError() == ERROR_SUCCESS, "InternetQueryOption failed: %d\n", GetLastError());
7067
7068 SetLastError(0xdeadbeef);
7069 size2 = sizeof(certstr2);
7071 ok(ret && GetLastError() == ERROR_SUCCESS, "InternetQueryOption failed: %d\n", GetLastError());
7072
7073 ok(size == size2, "expected same size\n");
7074 ok(!strcmp(certstr1, certstr2), "expected same string\n");
7075
7079
7080 /* Repeating the tests with the W functions has the same result: */
7082 ok(ses != NULL, "InternetOpen failed\n");
7083
7084 con = InternetConnectW(ses, testsite,
7086 INTERNET_SERVICE_HTTP, 0, 0);
7087 ok(con != NULL, "InternetConnect failed\n");
7088
7089 req = HttpOpenRequestW(con, get, testpage, NULL, NULL, NULL,
7091 ok(req != NULL, "HttpOpenRequest failed\n");
7092
7093 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
7094 ok(ret, "HttpSendRequest failed: %d\n", GetLastError());
7095
7096 size = sizeof(flags);
7098 ok(ret, "InternetQueryOption failed: %d\n", GetLastError());
7099 ok(flags & SECURITY_FLAG_SECURE, "expected secure flag to be set, got %x\n", flags);
7100
7102 NULL, &size);
7103 ok(ret || GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %d\n", GetLastError());
7104 ok(size == sizeof(INTERNET_CERTIFICATE_INFOA), "size = %d\n", size);
7105 certificate_structA = HeapAlloc(GetProcessHeap(), 0, size);
7107 certificate_structA, &size);
7108 ok(ret, "InternetQueryOption failed: %d\n", GetLastError());
7109 if (ret)
7110 {
7111 ok(certificate_structA->lpszSubjectInfo &&
7112 strlen(certificate_structA->lpszSubjectInfo) > 1,
7113 "expected a non-empty subject name\n");
7114 ok(certificate_structA->lpszIssuerInfo &&
7115 strlen(certificate_structA->lpszIssuerInfo) > 1,
7116 "expected a non-empty issuer name\n");
7117 ok(!certificate_structA->lpszSignatureAlgName,
7118 "unexpected signature algorithm name\n");
7119 ok(!certificate_structA->lpszEncryptionAlgName,
7120 "unexpected encryption algorithm name\n");
7121 ok(!certificate_structA->lpszProtocolName,
7122 "unexpected protocol name\n");
7123 ok(certificate_structA->dwKeySize, "expected a non-zero key size\n");
7124 release_cert_info(certificate_structA);
7125 }
7126 HeapFree(GetProcessHeap(), 0, certificate_structA);
7127
7128 /* Again, querying the same option through InternetQueryOptionW still
7129 * results in ASCII strings being returned.
7130 */
7131 size = 0;
7133 NULL, &size);
7134 ok(ret || GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %d\n", GetLastError());
7135 ok(size == sizeof(INTERNET_CERTIFICATE_INFOW), "size = %d\n", size);
7136 certificate_structW = HeapAlloc(GetProcessHeap(), 0, size);
7138 certificate_structW, &size);
7139 certificate_structA = (INTERNET_CERTIFICATE_INFOA *)certificate_structW;
7140 ok(ret, "InternetQueryOption failed: %d\n", GetLastError());
7141 if (ret)
7142 {
7143 ok(certificate_structA->lpszSubjectInfo &&
7144 strlen(certificate_structA->lpszSubjectInfo) > 1,
7145 "expected a non-empty subject name\n");
7146 ok(certificate_structA->lpszIssuerInfo &&
7147 strlen(certificate_structA->lpszIssuerInfo) > 1,
7148 "expected a non-empty issuer name\n");
7149 ok(!certificate_structA->lpszSignatureAlgName,
7150 "unexpected signature algorithm name\n");
7151 ok(!certificate_structA->lpszEncryptionAlgName,
7152 "unexpected encryption algorithm name\n");
7153 ok(!certificate_structA->lpszProtocolName,
7154 "unexpected protocol name\n");
7155 ok(certificate_structA->dwKeySize, "expected a non-zero key size\n");
7156 release_cert_info(certificate_structA);
7157 }
7158 HeapFree(GetProcessHeap(), 0, certificate_structW);
7159
7160done:
7164}
7165
7166static void test_user_agent_header(void)
7167{
7168 HINTERNET ses, con, req;
7169 DWORD size, err;
7170 char buffer[64];
7171 BOOL ret;
7172
7174 ok(ses != NULL, "InternetOpen failed\n");
7175
7176 con = InternetConnectA(ses, "test.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
7177 ok(con != NULL, "InternetConnect failed\n");
7178
7179 req = HttpOpenRequestA(con, "GET", "/tests/hello.html", "HTTP/1.0", NULL, NULL, 0, 0);
7180 ok(req != NULL, "HttpOpenRequest failed\n");
7181
7182 size = sizeof(buffer);
7184 err = GetLastError();
7185 ok(!ret, "HttpQueryInfo succeeded\n");
7186 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", err);
7187
7188 ret = HttpAddRequestHeadersA(req, "User-Agent: Gizmo Project\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
7189 ok(ret, "HttpAddRequestHeaders succeeded\n");
7190
7191 size = sizeof(buffer);
7193 err = GetLastError();
7194 ok(ret, "HttpQueryInfo failed\n");
7195
7197
7198 req = HttpOpenRequestA(con, "GET", "/", "HTTP/1.0", NULL, NULL, 0, 0);
7199 ok(req != NULL, "HttpOpenRequest failed\n");
7200
7201 size = sizeof(buffer);
7203 err = GetLastError();
7204 ok(!ret, "HttpQueryInfo succeeded\n");
7205 ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", err);
7206
7207 ret = HttpAddRequestHeadersA(req, "Accept: audio/*, image/*, text/*\r\nUser-Agent: Gizmo Project\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
7208 ok(ret, "HttpAddRequestHeaders failed\n");
7209
7210 buffer[0] = 0;
7211 size = sizeof(buffer);
7213 ok(ret, "HttpQueryInfo failed: %u\n", GetLastError());
7214 ok(!strcmp(buffer, "audio/*, image/*, text/*"), "got '%s' expected 'audio/*, image/*, text/*'\n", buffer);
7215
7219}
7220
7222{
7223 HINTERNET ses, con, req;
7224 static const char *types[] = { (const char *)6240, "*/*", "%p", "", (const char *)0xffffffff, "*/*", NULL };
7225 DWORD size, error;
7226 char buffer[32];
7227 BOOL ret;
7228
7229 ses = InternetOpenA("MERONG(0.9/;p)", INTERNET_OPEN_TYPE_DIRECT, "", "", 0);
7230 con = InternetConnectA(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
7231 req = HttpOpenRequestA(con, "POST", "/post/post_action.php", "HTTP/1.0", "", types, INTERNET_FLAG_FORMS_SUBMIT, 0);
7232
7233 ok(req != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
7234
7235 buffer[0] = 0;
7236 size = sizeof(buffer);
7237 SetLastError(0xdeadbeef);
7239 error = GetLastError();
7240 ok(!ret || broken(ret), "HttpQueryInfo succeeded\n");
7241 if (!ret) ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", error);
7242 ok(broken(!strcmp(buffer, ", */*, %p, , , */*")) /* IE6 */ ||
7243 broken(!strcmp(buffer, "*/*, %p, */*")) /* IE7/8 */ ||
7244 !strcmp(buffer, ""), "got '%s' expected ''\n", buffer);
7245
7249}
7250
7252{
7255};
7256
7258{
7260 struct context *ctx = (struct context *)context;
7261
7262 if(winetest_debug > 1)
7263 trace("%p 0x%08lx %u %p 0x%08x\n", handle, context, status, info, size);
7264
7265 switch(status) {
7267 trace("request handle: 0x%08lx\n", result->dwResult);
7268 ctx->req = (HINTERNET)result->dwResult;
7269 SetEvent(ctx->event);
7270 break;
7273
7275 ok(type != INTERNET_HANDLE_TYPE_CONNECT_HTTP, "unexpected callback\n");
7276 SetEvent(ctx->event);
7277 break;
7278 }
7282 char *str = info;
7283 ok(str[0] && str[1], "Got string: %s\n", str);
7284 ok(size == strlen(str)+1, "unexpected size %u\n", size);
7285 }
7286 }
7287}
7288
7289static void test_open_url_async(void)
7290{
7291 BOOL ret;
7292 HINTERNET ses, req;
7293 DWORD size, error;
7294 struct context ctx;
7295 ULONG type;
7296
7297 /* Collect all existing persistent connections */
7299 ok(ret, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
7300
7301 /*
7302 * Some versions of IE6 fail those tests. They pass some notification data as UNICODE string, while
7303 * other versions never do. They also hang of following tests. We disable it for everything older
7304 * than IE7.
7305 */
7306 if(!is_ie7plus)
7307 return;
7308
7309 ctx.req = NULL;
7310 ctx.event = CreateEventA(NULL, TRUE, FALSE, "Z:_home_hans_jaman-installer.exe_ev1");
7311
7312 ses = InternetOpenA("AdvancedInstaller", 0, NULL, NULL, INTERNET_FLAG_ASYNC);
7313 ok(ses != NULL, "InternetOpen failed\n");
7314
7315 SetLastError(0xdeadbeef);
7317 error = GetLastError();
7318 ok(!ret, "InternetSetOptionA succeeded\n");
7319 ok(error == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "got %u expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE\n", error);
7320
7322 error = GetLastError();
7323 ok(!ret, "InternetSetOptionA failed\n");
7324 ok(error == ERROR_INTERNET_OPTION_NOT_SETTABLE, "got %u expected ERROR_INTERNET_OPTION_NOT_SETTABLE\n", error);
7325
7326 pInternetSetStatusCallbackW(ses, cb);
7327 ResetEvent(ctx.event);
7328
7329 req = InternetOpenUrlA(ses, "http://test.winehq.org", NULL, 0, 0, (DWORD_PTR)&ctx);
7330 ok(!req && GetLastError() == ERROR_IO_PENDING, "InternetOpenUrl failed\n");
7331
7333
7334 type = 0;
7335 size = sizeof(type);
7337 ok(ret, "InternetQueryOption failed: %u\n", GetLastError());
7339 "expected INTERNET_HANDLE_TYPE_HTTP_REQUEST, got %u\n", type);
7340
7341 size = 0;
7343 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "HttpQueryInfo failed\n");
7344 ok(size > 0, "expected size > 0\n");
7345
7346 ResetEvent(ctx.event);
7349
7351 CloseHandle(ctx.event);
7352}
7353
7355{
7363
7364struct notification
7365{
7366 enum api function; /* api responsible for notification */
7367 unsigned int status; /* status received */
7368 BOOL async; /* delivered from another thread? */
7371};
7372
7373struct info
7374{
7375 enum api function;
7376 const struct notification *test;
7377 unsigned int count;
7378 unsigned int index;
7379 HANDLE wait;
7381 unsigned int line;
7384};
7385
7387
7389{
7390 BOOL status_ok, function_ok;
7391 struct info *info = (struct info *)context;
7392 unsigned int i;
7393
7395
7396 if(info->is_aborted) {
7398 return;
7399 }
7400
7402 {
7403 DWORD size = sizeof(struct info *);
7407
7408 ok(buflen == sizeof(*ar), "unexpected buflen = %d\n", buflen);
7410 ok(ar->dwResult == 1, "ar->dwResult = %ld, expected 1\n", ar->dwResult);
7411 }else {
7412 ok(!ar->dwResult, "ar->dwResult = %ld, expected 1\n", ar->dwResult);
7413 ok(ar->dwError == info->expect_result, "ar->dwError = %d, expected %d\n", ar->dwError, info->expect_result);
7414 }
7415 }
7416
7417 i = info->index;
7418 if (i >= info->count)
7419 {
7421 return;
7422 }
7423
7424 while (info->test[i].status != status &&
7425 (info->test[i].optional || info->test[i].todo) &&
7426 i < info->count - 1 &&
7427 info->test[i].function == info->test[i + 1].function)
7428 {
7429 i++;
7430 }
7431
7432 status_ok = (info->test[i].status == status);
7433 function_ok = (info->test[i].function == info->function);
7434
7435 if (!info->test[i].todo)
7436 {
7437 ok( status_ok, "%u: expected status %u got %u\n", info->line, info->test[i].status, status );
7438 ok( function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function );
7439
7440 if (info->test[i].async)
7441 ok(info->thread != GetCurrentThreadId(), "%u: expected thread %u got %u\n",
7443 }
7444 else
7445 {
7446 todo_wine ok( status_ok, "%u: expected status %u got %u\n", info->line, info->test[i].status, status );
7447 if (status_ok)
7448 todo_wine ok( function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function );
7449 }
7450 if (i == info->count - 1 || info->test[i].function != info->test[i + 1].function) SetEvent( info->wait );
7451 info->index = i+1;
7452
7454}
7455
7456static void setup_test( struct info *info, enum api function, unsigned int line, DWORD expect_result )
7457{
7459 info->line = line;
7461}
7462
7464{
7465 const struct notification *test;
7466 const unsigned int count;
7467 const char *method;
7468 const char *host;
7469 const char *path;
7470 const char *data;
7472};
7473
7475{
7496};
7497
7499{
7518};
7519
7521{
7533};
7534
7536{
7555};
7556
7557static const struct notification_data notification_data[] = {
7558 {
7561 "GET",
7562 "test.winehq.org",
7563 "tests/data.php"
7564 },
7565 {
7568 "POST",
7569 "test.winehq.org",
7570 "tests/post.php",
7571 "Public ID=codeweavers"
7572 },
7573 {
7576 "POST",
7577 "test.winehq.org",
7578 "tests/post.php"
7579 },
7580 {
7583 "GET",
7584 "brokenhost",
7585 "index.html",
7586 NULL,
7587 TRUE
7588 }
7589};
7590
7592{
7593 BOOL ret;
7594 HINTERNET ses, req, con;
7595 struct info info;
7596 DWORD size, written, error;
7598 static const char *accept[2] = {"*/*", NULL};
7599 char buffer[32];
7600
7601 trace("Async HttpSendRequestEx test (%s %s)\n", nd->method, nd->host);
7602
7604
7605 info.test = nd->test;
7606 info.count = nd->count;
7607 info.index = 0;
7611
7612 ses = InternetOpenA( "winetest", 0, NULL, NULL, INTERNET_FLAG_ASYNC );
7613 ok( ses != NULL, "InternetOpen failed\n" );
7614
7615 pInternetSetStatusCallbackA( ses, check_notification );
7616
7618 con = InternetConnectA( ses, nd->host, 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD_PTR)&info );
7619 ok( con != NULL, "InternetConnect failed %u\n", GetLastError() );
7620
7621 WaitForSingleObject( info.wait, 10000 );
7622
7624 req = HttpOpenRequestA( con, nd->method, nd->path, NULL, NULL, accept, 0, (DWORD_PTR)&info );
7625 ok( req != NULL, "HttpOpenRequest failed %u\n", GetLastError() );
7626
7627 WaitForSingleObject( info.wait, 10000 );
7628
7629 if(nd->data) {
7630 memset( &b, 0, sizeof(INTERNET_BUFFERSA) );
7631 b.dwStructSize = sizeof(INTERNET_BUFFERSA);
7632 b.lpcszHeader = "Content-Type: application/x-www-form-urlencoded";
7633 b.dwHeadersLength = strlen( b.lpcszHeader );
7634 b.dwBufferTotal = nd->data ? strlen( nd->data ) : 0;
7635 }
7636
7639 ret = HttpSendRequestExA( req, nd->data ? &b : NULL, NULL, 0x28, 0 );
7640 ok( !ret && GetLastError() == ERROR_IO_PENDING, "HttpSendRequestExA failed %d %u\n", ret, GetLastError() );
7641
7642 error = WaitForSingleObject( info.wait, 10000 );
7643 if(error != WAIT_OBJECT_0) {
7644 skip("WaitForSingleObject returned %d, assuming DNS problem\n", error);
7646 goto abort;
7647 }
7648
7649 size = sizeof(buffer);
7650 SetLastError( 0xdeadbeef );
7652 error = GetLastError();
7653 ok( !ret, "HttpQueryInfoA failed %u\n", GetLastError() );
7654 if(nd->expect_conn_failure) {
7655 ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND got %u\n", error );
7656 }else {
7657 todo_wine
7659 "expected ERROR_INTERNET_INCORRECT_HANDLE_STATE got %u\n", error );
7660 }
7661
7662 if (nd->data)
7663 {
7664 written = 0;
7665 size = strlen( nd->data );
7667 ret = InternetWriteFile( req, nd->data, size, &written );
7668 ok( ret, "InternetWriteFile failed %u\n", GetLastError() );
7669 ok( written == size, "expected %u got %u\n", written, size );
7670
7671 WaitForSingleObject( info.wait, 10000 );
7672
7673 SetLastError( 0xdeadbeef );
7674 ret = HttpEndRequestA( req, (void *)nd->data, 0x28, 0 );
7675 error = GetLastError();
7676 ok( !ret, "HttpEndRequestA succeeded\n" );
7677 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", error );
7678 }
7679
7680 SetLastError( 0xdeadbeef );
7681 setup_test( &info, http_end_request, __LINE__,
7683 ret = HttpEndRequestA( req, NULL, 0x28, 0 );
7684 error = GetLastError();
7685 ok( !ret, "HttpEndRequestA succeeded\n" );
7686 ok( error == ERROR_IO_PENDING, "expected ERROR_IO_PENDING got %u\n", error );
7687
7688 WaitForSingleObject( info.wait, 10000 );
7689
7691 abort:
7692 InternetCloseHandle( req );
7693 InternetCloseHandle( con );
7694 InternetCloseHandle( ses );
7695
7696 WaitForSingleObject( info.wait, 10000 );
7697 Sleep(100);
7700}
7701
7704
7705static void WINAPI closetest_callback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus,
7706 LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
7707{
7708 DWORD len, type;
7709 BOOL res;
7710
7711 if(winetest_debug > 1)
7712 trace("closetest_callback %p: %d\n", hInternet, dwInternetStatus);
7713
7714 ok(hInternet == closetest_session || hInternet == closetest_conn || hInternet == closetest_req,
7715 "Unexpected hInternet %p\n", hInternet);
7716 if(!closetest_closed)
7717 return;
7718
7719 len = sizeof(type);
7722 "InternetQueryOptionA(%p INTERNET_OPTION_HANDLE_TYPE) failed: %x %u, expected TRUE ERROR_INVALID_HANDLE\n",
7724}
7725
7727{
7728 DWORD len, flags;
7729 BOOL res;
7730
7732 ok(closetest_session != NULL,"InternetOpen failed with error %u\n", GetLastError());
7733
7734 pInternetSetStatusCallbackA(closetest_session, closetest_callback);
7735
7737 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
7738 ok(closetest_conn != NULL,"InternetConnect failed with error %u\n", GetLastError());
7739
7740 closetest_req = HttpOpenRequestA(closetest_conn, "GET", "winegecko.php", NULL, NULL, NULL,
7742
7745 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
7746
7748
7750 ok(res, "InternetCloseHandle failed: %u\n", GetLastError());
7752 trace("Closed session handle\n");
7753
7755 ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "InternetCloseConnection(conn) failed: %x %u\n",
7756 res, GetLastError());
7757
7759 ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "InternetCloseConnection(req) failed: %x %u\n",
7760 res, GetLastError());
7761
7762 len = sizeof(flags);
7765 "InternetQueryOptionA(%p INTERNET_OPTION_REQUEST_FLAGS) failed: %x %u, expected TRUE ERROR_INVALID_HANDLE\n",
7767}
7768
7770{
7771 test_request_t req;
7772 DWORD error;
7773 BOOL ret;
7774
7775 open_simple_request(&req, "localhost", 1, NULL, "/");
7776
7777 SetLastError(0xdeadbeef);
7778 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
7779 error = GetLastError();
7780 ok(!ret, "unexpected success\n");
7781 ok(error == ERROR_INTERNET_CANNOT_CONNECT, "wrong error %u\n", error);
7782
7783 close_request(&req);
7784}
7785
7787{
7789 DWORD size, error;
7790 char buffer[128];
7791 BOOL ret;
7792
7793 if(!is_ie7plus)
7794 return;
7795
7797 ok(session != NULL, "InternetOpen failed\n");
7798
7800 INTERNET_SERVICE_HTTP, 0, 0);
7801 ok(connect != NULL, "InternetConnect failed\n");
7802
7804 ok(request != NULL, "HttpOpenRequest failed\n");
7805
7806 SetLastError(0xdeadbeef);
7808 error = GetLastError();
7809 ok(!ret, "HttpSendRequest succeeded\n");
7811 "got %u\n", error);
7812
7813 size = sizeof(buffer);
7814 memset(buffer, 0, sizeof(buffer));
7816 ok(ret, "HttpQueryInfo failed with error %u\n", GetLastError());
7817 ok(!strcmp(buffer, "test.winehq.org:80"), "Expected test.winehg.org:80, got '%s'\n", buffer);
7818
7821
7824 ok(connect != NULL, "InternetConnect failed\n");
7825
7827 ok(request != NULL, "HttpOpenRequest failed\n");
7828
7831 {
7832 win_skip("Can't make https connection\n");
7833 goto done;
7834 }
7835 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
7836
7837 size = sizeof(buffer);
7838 memset(buffer, 0, sizeof(buffer));
7840 ok(ret, "HttpQueryInfo failed with error %u\n", GetLastError());
7841 ok(!strcmp(buffer, "test.winehq.org"), "Expected test.winehg.org, got '%s'\n", buffer);
7842
7845
7848 ok(connect != NULL, "InternetConnect failed\n");
7849
7850 request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, NULL, 0, 0);
7851 ok(request != NULL, "HttpOpenRequest failed\n");
7852
7854 ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
7855
7856 size = sizeof(buffer);
7857 memset(buffer, 0, sizeof(buffer));
7859 ok(ret, "HttpQueryInfo failed with error %u\n", GetLastError());
7860 ok(!strcmp(buffer, "test.winehq.org:443"), "Expected test.winehg.org:443, got '%s'\n", buffer);
7861
7862done:
7866}
7867
7868static void init_status_tests(void)
7869{
7870 memset(expect, 0, sizeof(expect));
7871 memset(optional, 0, sizeof(optional));
7872 memset(wine_allow, 0, sizeof(wine_allow));
7873 memset(notified, 0, sizeof(notified));
7874 memset(status_string, 0, sizeof(status_string));
7875
7876#define STATUS_STRING(status) status_string[status] = #status
7903#undef STATUS_STRING
7904}
7905
7907{
7908 BOOL ret;
7909 DWORD index, size;
7910 char buf[256];
7911
7913 {
7914 ret = HttpAddRequestHeadersA( handle, "winetest: winetest", ~0u, HTTP_ADDREQ_FLAG_ADD );
7915 ok( ret, "HttpAddRequestHeadersA failed %u\n", GetLastError() );
7916 SetEvent( (HANDLE)ctx );
7917 }
7919 {
7920 index = 0;
7921 size = sizeof(buf);
7923 buf, &size, &index );
7924 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
7925 ok( strstr( buf, "winetest: winetest" ) != NULL, "header missing\n" );
7926 SetEvent( (HANDLE)ctx );
7927 }
7928}
7929
7931{
7932 HINTERNET ses, con, req;
7933 DWORD err;
7934 BOOL ret;
7936
7937 ses = InternetOpenA( "winetest", 0, NULL, NULL, INTERNET_FLAG_ASYNC );
7938 ok( ses != NULL, "InternetOpenA failed\n" );
7939
7940 con = InternetConnectA( ses, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
7941 INTERNET_SERVICE_HTTP, 0, 0 );
7942 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
7943
7944 req = HttpOpenRequestA( con, NULL, "/", NULL, NULL, NULL, 0, (DWORD_PTR)wait );
7945 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
7946
7947 pInternetSetStatusCallbackA( req, header_cb );
7948
7949 SetLastError( 0xdeadbeef );
7950 ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
7951 err = GetLastError();
7952 ok( !ret, "HttpSendRequestA succeeded\n" );
7953 ok( err == ERROR_IO_PENDING, "got %u\n", ERROR_IO_PENDING );
7954
7955 WaitForSingleObject( wait, 5000 );
7956 WaitForSingleObject( wait, 5000 );
7957
7958 InternetCloseHandle( req );
7959 InternetCloseHandle( con );
7960 InternetCloseHandle( ses );
7961 CloseHandle( wait );
7962}
7963
7964static void test_cert_string(void)
7965{
7966 HINTERNET ses, con, req;
7967 char actual[512];
7968 DWORD size;
7969 BOOL res;
7970
7971 ses = InternetOpenA( "winetest", 0, NULL, NULL, 0 );
7972 ok( ses != NULL, "InternetOpenA failed\n" );
7973
7974 con = InternetConnectA( ses, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
7975 INTERNET_SERVICE_HTTP, 0, 0 );
7976 ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
7977
7978 req = HttpOpenRequestA( con, NULL, "/", NULL, NULL, NULL, 0, 0 );
7979 ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
7980
7981 size = sizeof(actual);
7982 SetLastError( 0xdeadbeef );
7983 memset( actual, 0x55, sizeof(actual) );
7986 "InternetQueryOption failed: %u\n", GetLastError() );
7987 ok( size == 0, "unexpected size: %u\n", size );
7988 ok( actual[0] == 0x55, "unexpected byte: %02x\n", actual[0] );
7989
7990 InternetCloseHandle( req );
7991 InternetCloseHandle( con );
7992 InternetCloseHandle( ses );
7993}
7994
7996{
7997 HMODULE hdll;
7998
8000 {
8001 win_skip("Skipping wininet:http due to hang ROSTESTS-357\n");
8002 return;
8003 }
8004
8005 hdll = GetModuleHandleA("wininet.dll");
8006
8007 if(!GetProcAddress(hdll, "InternetGetCookieExW")) {
8008 win_skip("Too old IE (older than 6.0)\n");
8009 return;
8010 }
8011
8012 pInternetSetStatusCallbackA = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackA");
8013 pInternetSetStatusCallbackW = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackW");
8014 pInternetGetSecurityInfoByURLA = (void*)GetProcAddress(hdll, "InternetGetSecurityInfoByURLA");
8015
8016 if(!pInternetGetSecurityInfoByURLA) {
8017 is_ie7plus = FALSE;
8018 win_skip("IE6 found. It's too old for some tests.\n");
8019 }
8020
8021 init_events();
8052 free_events();
8053}
#define broken(x)
Definition: _sntprintf.h:21
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define read
Definition: acwin.h:96
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 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:33
#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 WAIT_TIMEOUT
Definition: dderror.h:14
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_IO_PENDING
Definition: dderror.h:15
#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:3327
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:4038
content
Definition: atl_ax.c:994
VOID WINAPI CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT pChainContext)
Definition: chain.c:2960
static const WCHAR empty[]
Definition: main.c:47
#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
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 LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
USHORT port
Definition: uri.c:228
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1418
BOOL WINAPI HttpEndRequestA(HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5349
BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest, LPCSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1329
HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession, LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion, LPCSTR lpszReferrer, LPCSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:1410
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5595
BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:4018
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3870
BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5677
BOOL WINAPI HttpSendRequestExA(HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffersIn, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5445
HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession, LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion, LPCWSTR lpszReferrer, LPCWSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:3469
BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength)
Definition: internet.c:2697
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2114
BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength)
Definition: internet.c:2730
BOOL WINAPI InternetLockRequestFile(HINTERNET hInternet, HANDLE *lphLockReqHandle)
Definition: internet.c:4032
BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:2248
BOOL WINAPI InternetUnlockRequestFile(HANDLE hLockHandle)
Definition: internet.c:4061
BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:1978
DWORD WINAPI InternetSetFilePointer(HINTERNET hFile, LONG lDistanceToMove, PVOID pReserved, DWORD dwMoveContext, DWORD_PTR dwContext)
Definition: internet.c:2095
BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer, DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
Definition: internet.c:2154
HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:1057
BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:3131
HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl, LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3779
BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:2210
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1414
BOOL WINAPI InternetQueryDataAvailable(HINTERNET hFile, LPDWORD lpdwNumberOfBytesAvailable, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3959
HINTERNET WINAPI InternetConnectA(HINTERNET hInternet, LPCSTR lpszServerName, INTERNET_PORT nServerPort, LPCSTR lpszUserName, LPCSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1321
HINTERNET WINAPI InternetConnectW(HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1258
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:979
BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:2837
BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
Definition: urlcache.c:3298
BOOL WINAPI CreateUrlCacheEntryA(LPCSTR lpszUrlName, DWORD dwExpectedFileSize, LPCSTR lpszFileExtension, LPSTR lpszFileName, DWORD dwReserved)
Definition: urlcache.c:2796
BOOL WINAPI CommitUrlCacheEntryA(LPCSTR lpszUrlName, LPCSTR lpszLocalFileName, FILETIME ExpireTime, FILETIME LastModifiedTime, DWORD CacheEntryType, LPBYTE lpHeaderInfo, DWORD dwHeaderSize, LPCSTR lpszFileExtension, LPCSTR lpszOriginalUrl)
Definition: urlcache.c:3063
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
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
#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 GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
const GLubyte * c
Definition: glext.h:8905
GLuint index
Definition: glext.h:6031
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
GLuint64EXT * result
Definition: glext.h:11304
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
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
static IUnknown testsite
Definition: httpreq.c:1213
#define abort()
Definition: i386-dis.c:34
#define UINT_MAX
Definition: limits.h:41
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define inet_addr(cp)
Definition: inet.h:98
#define c
Definition: ke_i.h:80
#define b
Definition: ke_i.h:79
LANGID WINAPI GetUserDefaultLangID(void)
Definition: lang.c:744
INT WINAPI GetTimeFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1044
INT WINAPI GetDateFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpDateStr, INT cchOut)
Definition: lcformat.c:936
USHORT LANGID
Definition: mui.h:9
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#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(buf, format,...)
Definition: sprintf.c:55
static IPrintDialogCallback callback
Definition: printdlg.c:326
static const WCHAR url[]
Definition: encode.c:1432
static BYTE cert[]
Definition: msg.c:1437
static const char * strw(LPCWSTR x)
Definition: actctx.c:49
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
static HINSTANCE hkernel32
Definition: process.c:66
#define todo_wine_if(is_todo)
Definition: custom.c:76
#define todo_wine
Definition: custom.c:79
static const CHAR post_data[]
Definition: protocol.c:217
static LPCWSTR file_name
Definition: protocol.c:147
static BOOL test_redirect
Definition: protocol.c:149
static WCHAR http[]
Definition: url.c:30
static WCHAR password[]
Definition: url.c:33
static WCHAR username[]
Definition: url.c:32
static void test_http_connection(void)
Definition: http.c:6331
#define CHECK_EXPECT(status)
Definition: http.c:69
static void test_basic_auth_credentials_different(int port)
Definition: http.c:4943
static const struct notification async_send_request_ex_test[]
Definition: http.c:7474
static const char okmsg2[]
Definition: http.c:2118
#define _SECURITY_FLAG_CERT_REV_FAILED
Definition: http.c:37
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:5537
static void _read_expect_sync_data_len(unsigned line, HINTERNET req, void *buf, DWORD buf_size, const char *exdata, DWORD len)
Definition: http.c:5544
static const char ok_with_length2[]
Definition: http.c:2186
static HINTERNET closetest_session
Definition: http.c:7702
static void test_connection_header(int port)
Definition: http.c:3170
static void test_request_content_length(int port)
Definition: http.c:4710
static void server_send_string(const char *msg)
Definition: http.c:5378
#define async_query_data_available(a, b)
Definition: http.c:5703
static int notified[MAX_INTERNET_STATUS]
Definition: http.c:111
static void test_proxy_direct(int port)
Definition: http.c:2711
static HANDLE conn_wait_event
Definition: http.c:114
static const char expandcontmsg[]
Definition: http.c:2103
static DWORD _expect_data_available(unsigned line, HINTERNET req, int exsize)
Definition: http.c:5690
static void _readex_expect_async(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, DWORD buf_size, const char *exdata)
Definition: http.c:5639
static DWORD CALLBACK server_thread(LPVOID param)
Definition: http.c:2201
static void WINAPI header_cb(HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID info, DWORD len)
Definition: http.c:7906
static void HttpSendRequestEx_test(void)
Definition: http.c:1353
#define test_http_version(a)
Definition: http.c:352
static HANDLE complete_event
Definition: http.c:114
#define test_secflags_option(a, b, c)
Definition: http.c:6589
static const char okmsg[]
Definition: http.c:2108
#define TESTF_COMPRESSED
Definition: http.c:119
static const char largemsg[]
Definition: http.c:2128
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:5618
static void _test_security_info(unsigned line, const char *urlc, DWORD error, DWORD ex_flags)
Definition: http.c:6550
static void test_basic_auth_credentials_end_session(int port)
Definition: http.c:4857
static BOOL https_support
Definition: http.c:45
static CRITICAL_SECTION notification_cs
Definition: http.c:7386
#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:7456
static void test_no_cache(int port)
Definition: http.c:3822
static void test_basic_auth_credentials_reuse(int port)
Definition: http.c:4775
static void test_no_content(int port)
Definition: http.c:3675
#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:7520
static void _open_simple_request(unsigned line, test_request_t *req, const char *host, int port, const char *verb, const char *url)
Definition: http.c:534
#define receive_simple_request(a, b, c)
Definition: http.c:560
static const char noauthmsg2[]
Definition: http.c:2161
static void release_cert_info(INTERNET_CERTIFICATE_INFOA *info)
Definition: http.c:6414
static void test_cookie_header(int port)
Definition: http.c:4107
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:2154
#define send_response_and_wait(a, b, c, d, e, f, g, h)
Definition: http.c:5583
static void open_read_test_request(int port, test_request_t *req, const char *response)
Definition: http.c:5483
static void test_remove_dot_segments(int port)
Definition: http.c:6229
static void read_expect_async(HINTERNET req, void *buf, DWORD buf_size, DWORD *ret_size, const char *exdata)
Definition: http.c:5664
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:5584
static void test_connection_break(int port)
Definition: http.c:5940
#define MAX_INTERNET_STATUS
Definition: http.c:109
static void _server_read_request(unsigned line, const char *expected_request)
Definition: http.c:5389
static const http_status_test_t http_status_tests[]
Definition: http.c:4605
#define STATUS_STRING(status)
static void test_secure_connection(void)
Definition: http.c:6988
static void test_proxy_indirect(int port)
Definition: http.c:2663
static void test_connection_closing(int port)
Definition: http.c:3471
static const char notokmsg[]
Definition: http.c:2149
#define CHECK_NOTIFIED(status)
Definition: http.c:103
static const char page1[]
Definition: http.c:2174
static void test_response_without_headers(int port)
Definition: http.c:4283
static void test_concurrent_header_access(void)
Definition: http.c:7930
@ http_send_request_ex
Definition: http.c:7358
@ internet_close_handle
Definition: http.c:7361
@ http_end_request
Definition: http.c:7360
@ internet_writefile
Definition: http.c:7359
@ http_open_request
Definition: http.c:7357
@ internet_connect
Definition: http.c:7356
static void test_basic_authentication(int port)
Definition: http.c:4210
#define send_response_ex_and_wait(a, b, c, d, e, f)
Definition: http.c:5617
static int strcmp_wa(LPCWSTR strw, const char *stra)
Definition: http.c:194
static HINTERNET closetest_req
Definition: http.c:7702
static const char garbagemsg[]
Definition: http.c:2097
#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:7705
static void _close_request(unsigned line, test_request_t *req)
Definition: http.c:548
static const char ok_with_length[]
Definition: http.c:2180
static BOOL closetest_closed
Definition: http.c:7703
static int test_cache_gzip
Definition: http.c:2197
static void test_header_override(int port)
Definition: http.c:3224
static void init_status_tests(void)
Definition: http.c:7868
static void test_cert_struct(HINTERNET req, const cert_struct_test_t *test)
Definition: http.c:6516
static INTERNET_STATUS_CALLBACK
Definition: http.c:170
#define set_secflags(a, b, c)
Definition: http.c:6611
#define close_request(a)
Definition: http.c:547
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:1576
static void test_cache_control_verb(int port)
Definition: http.c:4663
static void test_open_url_async(void)
Definition: http.c:7289
static void test_large_content(int port)
Definition: http.c:6249
#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:5689
static int server_socket
Definition: http.c:2199
#define CHECK_NOTIFIED2(status, num)
Definition: http.c:94
#define read_expect_sync_data(a, b, c, d)
Definition: http.c:5569
static void InternetReadFile_chunked_test(void)
Definition: http.c:962
static void test_basic_auth_credentials_cached_manual(int port)
Definition: http.c:5119
static void send_socket_request(test_request_t *req, BOOL new_connection)
Definition: http.c:5425
#define test_request_url(a, b)
Definition: http.c:339
static void test_user_agent_header(void)
Definition: http.c:7166
static const char * status_string[MAX_INTERNET_STATUS]
Definition: http.c:112
#define server_read_request(a)
Definition: http.c:5388
static const char okmsg_cookie_path[]
Definition: http.c:2133
static void _async_query_data_available(unsigned line, HINTERNET req, DWORD *size)
Definition: http.c:5704
static void InternetOpenUrlA_test(void)
Definition: http.c:1316
static void test_head_request(int port)
Definition: http.c:4329
static void test_header_handling_order(int port)
Definition: http.c:3079
#define open_simple_request(a, b, c, d, e)
Definition: http.c:533
static void test_async_read(int port)
Definition: http.c:5180
#define CHECK_NOT_NOTIFIED(status)
Definition: http.c:106
static const cert_struct_test_t test_winehq_org_cert
Definition: http.c:6428
static void test_basic_request(int port, const char *verb, const char *url)
Definition: http.c:2636
static DWORD received_response_size
Definition: http.c:5402
static void reset_events(void)
Definition: http.c:238
static void InternetOpenRequest_test(void)
Definition: http.c:1428
static void test_async_HttpSendRequestEx(const struct notification_data *nd)
Definition: http.c:7591
static void HttpHeaders_test(void)
Definition: http.c:1766
static void CALLBACK check_notification(HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID buffer, DWORD buflen)
Definition: http.c:7388
static void test_InternetCloseHandle(void)
Definition: http.c:7726
static void test_persistent_connection(int port)
Definition: http.c:6005
static const struct notification async_send_request_ex_chunked_test[]
Definition: http.c:7535
static void test_successive_HttpSendRequest(int port)
Definition: http.c:3591
static DWORD _receive_simple_request(unsigned line, HINTERNET req, char *buf, size_t buf_size)
Definition: http.c:561
static void close_connection(void)
Definition: http.c:5576
#define TESTF_REDIRECT
Definition: http.c:118
static void test_HttpSendRequestW(int port)
Definition: http.c:4077
#define test_security_info(a, b, c)
Definition: http.c:6549
static const char * send_buffer
Definition: http.c:2198
static void test_basic_auth_credentials_manual(int port)
Definition: http.c:5028
static void test_default_service_port(void)
Definition: http.c:7786
static void test_cache_read_gzipped(int port)
Definition: http.c:3888
static void test_cert_struct_string(HINTERNET req, const INTERNET_CERTIFICATE_INFOA *info)
Definition: http.c:6474
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:572
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:6590
static void test_premature_disconnect(int port)
Definition: http.c:4235
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:2113
static void test_cache_read(void)
Definition: http.c:1477
static const char * cert_string_fmt
Definition: http.c:6464
static void test_HttpQueryInfo(int port)
Definition: http.c:4359
static void InternetLockRequestFile_test(void)
Definition: http.c:1713
static void test_connection_failure(void)
Definition: http.c:7769
#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:5536
static void test_http_status(int port)
Definition: http.c:4636
static const struct notification async_send_request_ex_test2[]
Definition: http.c:7498
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:5459
static const char contmsg[]
Definition: http.c:2100
static void test_bogus_accept_types_array(void)
Definition: http.c:7221
static HINTERNET closetest_conn
Definition: http.c:7702
static void WINAPI readex_callback(HINTERNET handle, DWORD_PTR context, DWORD status, void *info, DWORD info_size)
Definition: http.c:5404
static void InternetReadFileExA_test(int flags)
Definition: http.c:1085
static const cert_struct_test_t test_winehq_com_cert
Definition: http.c:6446
static void _read_expect_sync_data(unsigned line, HINTERNET req, void *buf, DWORD buf_size, const char *exdata)
Definition: http.c:5570
#define SET_EXPECT2(status, num)
Definition: http.c:49
static void test_http_read(int port)
Definition: http.c:5721
static int expect[MAX_INTERNET_STATUS]
Definition: http.c:110
static void test_cert_string(void)
Definition: http.c:7964
#define readex_expect_async(a, b, c, d, e)
Definition: http.c:5638
static void test_accept_encoding(int port)
Definition: http.c:4733
static void InternetReadFile_test(int flags, const test_data_t *test)
Definition: http.c:585
static BOOL skip_receive_notification_tests
Definition: http.c:5401
static const char proxymsg[]
Definition: http.c:2167
static BOOL proxy_active(void)
Definition: http.c:201
static void test_invalid_response_headers(int port)
Definition: http.c:4252
static void test_conn_close(int port)
Definition: http.c:3737
static DWORD64 content_length
Definition: http.c:2127
static void test_options(int port)
Definition: http.c:4458
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:5510
static int close_handle_cnt
Definition: http.c:366
#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:6612
static void test_security_flags(void)
Definition: http.c:6620
#define SET_EXPECT(status)
Definition: http.c:52
static const char okmsg_cookie[]
Definition: http.c:2141
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:5627
static void test_long_url(void)
Definition: url.c:481
#define min(a, b)
Definition: monoChain.cc:55
#define closesocket
Definition: ncftp.h:477
HANDLE hThread
Definition: wizard.c:28
api
Definition: notification.c:38
#define server_read_data(a)
Definition: notification.c:843
#define BOOL
Definition: nt_native.h:43
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
#define LOCALE_USER_DEFAULT
#define err(...)
static unsigned int file_size
Definition: regtests2xml.c:47
static FILE * out
Definition: regtests2xml.c:44
#define test
Definition: rosglue.h:37
const WCHAR * str
#define LANG_ENGLISH
Definition: nls.h:52
#define PRIMARYLANGID(l)
Definition: nls.h:16
int winetest_debug
#define ros_skip_flaky
Definition: test.h:177
#define win_skip
Definition: test.h:160
int winetest_interactive
#define memset(x, y, z)
Definition: compat.h:39
static PVOID hdll
Definition: shimdbg.c:126
HRESULT hr
Definition: shlfolder.c:183
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
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
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
LPVOID lpvBuffer
Definition: wininet.h:277
DWORD dwStructSize
Definition: wininet.h:272
const char * ex_issuer
Definition: http.c:6425
const char * ex_subject
Definition: http.c:6424
Definition: inflate.c:139
Definition: http.c:7252
HINTERNET req
Definition: http.c:7254
HANDLE event
Definition: http.c:7253
Definition: fci.c:127
const char * status_text
Definition: http.c:4601
const char * raw_headers
Definition: http.c:4602
const char * response_text
Definition: http.c:4599
unsigned int line
Definition: notification.c:67
enum api function
Definition: notification.c:62
unsigned int index
Definition: notification.c:65
BOOL is_aborted
Definition: http.c:7383
DWORD expect_result
Definition: http.c:7382
const struct notification * test
Definition: notification.c:63
DWORD thread
Definition: http.c:7380
HANDLE wait
Definition: notification.c:66
unsigned int count
Definition: notification.c:64
BOOL ret
Definition: http.c:6246
DWORD64 content_length
Definition: http.c:6245
Definition: parser.c:49
const struct notification * test
Definition: http.c:7465
const char * path
Definition: http.c:7469
const char * data
Definition: http.c:7470
const char * host
Definition: http.c:7468
const char * method
Definition: http.c:7467
const unsigned int count
Definition: http.c:7466
BOOL expect_conn_failure
Definition: http.c:7471
enum api function
Definition: notification.c:51
unsigned int status
Definition: notification.c:52
BOOL optional
Definition: http.c:7370
BOOL todo
Definition: http.c:7369
BOOL async
Definition: http.c:7368
Definition: tftpd.h:86
HANDLE hEvent
Definition: http.c:2193
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
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
rwlock_t lock
Definition: tcpcore.h:0
struct sock * chain
Definition: tcpcore.h:1
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define MAKEWORD(a, b)
Definition: typedefs.h:248
uint64_t DWORD64
Definition: typedefs.h:67
unsigned char * LPBYTE
Definition: typedefs.h:53
int64_t LONGLONG
Definition: typedefs.h:68
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2290 u
int ret
char * host
Definition: whois.c:55
#define FILE_END
Definition: winbase.h:114
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define WINAPI
Definition: msvc.h:6
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
static const char nocontentmsg[]
Definition: winhttp.c:2202
#define HTTP_STATUS_OK
Definition: winhttp.h:240
#define HTTP_STATUS_BAD_REQUEST
Definition: winhttp.h:255
LPVOID HINTERNET
Definition: winhttp.h:32
#define SECURITY_FLAG_SECURE
Definition: winhttp.h:285
#define ICU_BROWSER_MODE
Definition: winhttp.h:294
#define INTERNET_DEFAULT_HTTP_PORT
Definition: winhttp.h:36
#define SECURITY_FLAG_STRENGTH_STRONG
Definition: winhttp.h:288
#define SECURITY_FLAG_IGNORE_UNKNOWN_CA
Definition: winhttp.h:281
#define SECURITY_FLAG_IGNORE_CERT_CN_INVALID
Definition: winhttp.h:283
#define INTERNET_DEFAULT_HTTPS_PORT
Definition: winhttp.h:37
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_OPTION_PROXY_PASSWORD
Definition: wininet.h:738
#define HTTP_QUERY_SET_COOKIE
Definition: wininet.h:1566
#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_OPTION_PROXY_USERNAME
Definition: wininet.h:737
#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_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_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 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:332
UINT_PTR SOCKET
Definition: winsock.h:47
#define SO_REUSEADDR
Definition: winsock.h:180
#define SOL_SOCKET
Definition: winsock.h:398
#define snprintf
Definition: wintirpc.h:48
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193