32#include <httprequest.h>
38DEFINE_GUID(
GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
41 {
'W',
'i',
'n',
'e',
' ',
'R',
'e',
'g',
'r',
'e',
's',
's',
'i',
'o',
'n',
' ',
'T',
'e',
's',
't',0};
42static const WCHAR test_winehq[] = {
't',
'e',
's',
't',
'.',
'w',
'i',
'n',
'e',
'h',
'q',
'.',
'o',
'r',
'g',0};
43static const WCHAR test_winehq_https[] = {
'h',
't',
't',
'p',
's',
':',
'/',
'/',
't',
'e',
's',
't',
'.',
'w',
'i',
'n',
'e',
'h',
'q',
'.',
'o',
'r',
'g',
':',
'4',
'4',
'3',0};
98 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
103 ok(!
ret,
"should fail to query option\n");
105 "expected ERROR_INSUFFICIENT_BUFFER, got %u\n",
GetLastError());
112 ok(!
ret,
"should fail to query option\n");
114 "expected ERROR_INSUFFICIENT_BUFFER, got %u\n",
GetLastError());
124 ok(
size ==
sizeof(
feature),
"WinHttpQueryOption should set the size: %u\n",
size);
126 "expected WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP, got %#x\n",
feature);
132 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
139 "expected ERROR_INSUFFICIENT_BUFFER, got %u\n",
GetLastError());
146 "expected ERROR_INSUFFICIENT_BUFFER, got %u\n",
GetLastError());
159 "expected WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS, got %#x\n",
feature);
164 ok(!
ret,
"should fail to set disable feature for a session\n");
166 "expected ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, got %u\n",
GetLastError());
170 ok(connection !=
NULL,
"WinHttpConnect failed to open a connection, error: %u\n",
GetLastError());
175 ok(!
ret,
"should fail to set disable feature for a connection\n");
177 "expected ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, got %u\n",
GetLastError());
184 skip(
"Network unreachable, skipping the test\n");
192 ok(!
ret,
"should fail to query disable feature for a request\n");
194 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
217 ok(!
ret,
"should fail to query disable feature for a request\n");
219 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
225 ok(!
ret,
"should fail to query enabled features for a request\n");
232 ok(!
ret,
"should fail to enable WINHTTP_ENABLE_SSL_REVOCATION with invalid parameters\n");
237 ok(!
ret,
"should fail to enable WINHTTP_ENABLE_SSL_REVOCATION with invalid parameters\n");
242 ok(
ret,
"failed to set feature\n");
249 ok(!
ret,
"should fail to enable WINHTTP_ENABLE_SSL_REVOCATION with invalid parameters\n");
264 ok(
ret,
"WinHttpCloseHandle failed on closing connection: %u\n",
GetLastError());
280 ok(
session !=
NULL,
"WinHttpOpen failed to open session.\n");
287 ok (connection ==
NULL,
"WinHttpConnect succeeded in opening connection to NULL server argument.\n");
294 ok(connection !=
NULL,
"WinHttpConnect failed to open a connection, error: %u.\n",
err);
303 skip(
"Network unreachable, skipping.\n");
306 ok(
request !=
NULL,
"WinHttpOpenrequest failed to open a request, error: %u.\n",
err);
314 skip(
"Connection failed, skipping.\n");
317 ok(
ret,
"WinHttpSendRequest failed: %u\n",
err);
323 ok(
ret,
"WinHttpCloseHandle failed on closing request, got %u.\n",
err);
328 ok(
ret ==
TRUE,
"WinHttpCloseHandle failed on closing connection, got %d.\n",
ret);
330 ok(
ret ==
TRUE,
"WinHttpCloseHandle failed on closing session, got %d.\n",
ret);
354 skip(
"connection failed, skipping\n");
368 {
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
369 '/',
'x',
'-',
'w',
'w',
'w',
'-',
'f',
'o',
'r',
'm',
'-',
'u',
'r',
'l',
'e',
'n',
'c',
'o',
'd',
'e',
'd',0};
370 static const WCHAR test_file[] = {
't',
'e',
's',
't',
's',
'/',
'p',
'o',
's',
't',
'.',
'p',
'h',
'p',0};
371 static const WCHAR postW[] = {
'P',
'O',
'S',
'T',0};
373 static const char test_post[] =
"mode => Test\0\n";
383 total_len = optional_len =
sizeof(
post_data);
388 ok(
session !=
NULL,
"WinHttpOpen failed to open session.\n");
391 ok(connection !=
NULL,
"WinHttpConnect failed to open a connection, error: %u.\n",
GetLastError());
397 skip(
"Network unreachable, skipping.\n");
425 skip(
"connection failed, skipping\n");
444 ok(bytes_rw == 1,
"WinHttpWriteData failed, wrote %u bytes instead of 1 byte.\n", bytes_rw);
449 ok(bytes_rw == -1,
"Expected bytes_rw to remain unchanged.\n");
471 ok(bytes_rw ==
sizeof(test_post) - 1,
"Read %u bytes\n", bytes_rw);
472 ok(!
memcmp(
buffer, test_post,
sizeof(test_post) - 1),
"Data read did not match.\n");
476 ok(
ret ==
TRUE,
"WinHttpCloseHandle failed on closing request, got %d.\n",
ret);
478 ok(
ret ==
TRUE,
"WinHttpCloseHandle failed on closing connection, got %d.\n",
ret);
480 ok(
ret ==
TRUE,
"WinHttpCloseHandle failed on closing session, got %d.\n",
ret);
487 static const WCHAR expected_string[] =
488 {
'M',
'o',
'n',
',',
' ',
'2',
'8',
' ',
'J',
'u',
'l',
' ',
'2',
'0',
'0',
'8',
' ',
489 '1',
'0',
':',
'0',
'5',
':',
'5',
'2',
' ',
'G',
'M',
'T',0};
496 ok(!
ret,
"WinHttpTimeFromSystemTime succeeded\n");
502 ok(!
ret,
"WinHttpTimeFromSystemTime succeeded\n");
508 ok(
ret,
"WinHttpTimeFromSystemTime failed: %u\n",
err);
510 ok(
memcmp(time_string, expected_string,
sizeof(expected_string)) == 0,
511 "Time string returned did not match expected time string.\n");
518 static const SYSTEMTIME expected_time = {2008, 7, 1, 28, 10, 5, 52, 0};
519 static const WCHAR time_string1[] =
520 {
'M',
'o',
'n',
',',
' ',
'2',
'8',
' ',
'J',
'u',
'l',
' ',
'2',
'0',
'0',
'8',
' ',
521 +
'1',
'0',
':',
'0',
'5',
':',
'5',
'2',
' ',
'G',
'M',
'T',
'\n',0};
522 static const WCHAR time_string2[] =
523 {
' ',
'm',
'o',
'n',
' ',
'2',
'8',
' ',
'j',
'u',
'l',
' ',
'2',
'0',
'0',
'8',
' ',
524 '1',
'0',
' ',
'0',
'5',
' ',
'5',
'2',
'\n',0};
530 ok(!
ret,
"WinHttpTimeToSystemTime succeeded\n");
536 ok(!
ret,
"WinHttpTimeToSystemTime succeeded\n");
542 ok(
ret,
"WinHttpTimeToSystemTime failed: %u\n",
err);
545 "Returned SYSTEMTIME structure did not match expected SYSTEMTIME structure.\n");
550 ok(
ret,
"WinHttpTimeToSystemTime failed: %u\n",
err);
553 "Returned SYSTEMTIME structure did not match expected SYSTEMTIME structure.\n");
564 static const WCHAR test_file[] = {
'/',
'p',
'o',
's',
't',
't',
'e',
's',
't',
'.',
'p',
'h',
'p',0};
565 static const WCHAR test_verb[] = {
'P',
'O',
'S',
'T',0};
566 static const WCHAR test_header_begin[] =
567 {
'P',
'O',
'S',
'T',
' ',
'/',
'p',
'o',
's',
't',
't',
'e',
's',
't',
'.',
'p',
'h',
'p',
' ',
'H',
'T',
'T',
'P',
'/',
'1'};
568 static const WCHAR full_path_test_header_begin[] =
569 {
'P',
'O',
'S',
'T',
' ',
'h',
't',
't',
'p',
':',
'/',
'/',
't',
'e',
's',
't',
'.',
'w',
'i',
'n',
'e',
'h',
'q',
'.',
'o',
'r',
'g',
':',
'8',
'0',
570 '/',
'p',
'o',
's',
't',
't',
'e',
's',
't',
'.',
'p',
'h',
'p',
' ',
'H',
'T',
'T',
'P',
'/',
'1'};
571 static const WCHAR test_header_end[] = {
'\r',
'\n',
'\r',
'\n',0};
572 static const WCHAR test_header_name[] = {
'W',
'a',
'r',
'n',
'i',
'n',
'g',0};
573 static const WCHAR test_header_name2[] = {
'n',
'a',
'm',
'e',0};
574 static const WCHAR test_header_name3[] = {
'a',0};
575 static const WCHAR test_header_range[] = {
'R',
'a',
'n',
'g',
'e',0};
576 static const WCHAR test_header_range_bytes[] = {
'R',
'a',
'n',
'g',
'e',
':',
' ',
'b',
'y',
't',
'e',
's',
'=',
'0',
'-',
'7',
'7',
'3',
'\r',
'\n',0};
577 static const WCHAR test_header_bytes[] = {
'b',
'y',
't',
'e',
's',
'=',
'0',
'-',
'7',
'7',
'3',0};
579 static const WCHAR test_flag_coalesce[] = {
't',
'e',
's',
't',
'2',
',',
' ',
't',
'e',
's',
't',
'4',0};
580 static const WCHAR test_flag_coalesce_reverse[] = {
't',
'e',
's',
't',
'3',
',',
' ',
't',
'e',
's',
't',
'4',0};
581 static const WCHAR test_flag_coalesce_comma[] =
582 {
't',
'e',
's',
't',
'2',
',',
' ',
't',
'e',
's',
't',
'4',
',',
' ',
't',
'e',
's',
't',
'5',0};
583 static const WCHAR test_flag_coalesce_comma_reverse[] =
584 {
't',
'e',
's',
't',
'3',
',',
' ',
't',
'e',
's',
't',
'4',
',',
' ',
't',
'e',
's',
't',
'5',0};
585 static const WCHAR test_flag_coalesce_semicolon[] =
586 {
't',
'e',
's',
't',
'2',
',',
' ',
't',
'e',
's',
't',
'4',
',',
' ',
't',
'e',
's',
't',
'5',
';',
' ',
't',
'e',
's',
't',
'6',0};
587 static const WCHAR test_flag_coalesce_semicolon_reverse[] =
588 {
't',
'e',
's',
't',
'3',
',',
' ',
't',
'e',
's',
't',
'4',
',',
' ',
't',
'e',
's',
't',
'5',
';',
' ',
't',
'e',
's',
't',
'6',0};
590 static const WCHAR field[] = {
'f',
'i',
'e',
'l',
'd',0};
591 static const WCHAR value[] = {
'v',
'a',
'l',
'u',
'e',
' ',0};
592 static const WCHAR value_nospace[] = {
'v',
'a',
'l',
'u',
'e',0};
595 static const WCHAR test_headers[][14] =
597 {
'W',
'a',
'r',
'n',
'i',
'n',
'g',
':',
't',
'e',
's',
't',
'1',0},
598 {
'W',
'a',
'r',
'n',
'i',
'n',
'g',
':',
't',
'e',
's',
't',
'2',0},
599 {
'W',
'a',
'r',
'n',
'i',
'n',
'g',
':',
't',
'e',
's',
't',
'3',0},
600 {
'W',
'a',
'r',
'n',
'i',
'n',
'g',
':',
't',
'e',
's',
't',
'4',0},
601 {
'W',
'a',
'r',
'n',
'i',
'n',
'g',
':',
't',
'e',
's',
't',
'5',0},
602 {
'W',
'a',
'r',
'n',
'i',
'n',
'g',
':',
't',
'e',
's',
't',
'6',0},
603 {
'W',
'a',
'r',
'n',
'i',
'n',
'g',
':',
't',
'e',
's',
't',
'7',0},
609 {
' ',
'e',
' ',
':',
'f',0},
610 {
'f',
'i',
'e',
'l',
'd',
':',
' ',
'v',
'a',
'l',
'u',
'e',
' ',0},
611 {
'n',
'a',
'm',
'e',
':',
' ',
'v',
'a',
'l',
'u',
'e',0},
612 {
'n',
'a',
'm',
'e',
':',0}
614 static const WCHAR test_indices[][6] =
616 {
't',
'e',
's',
't',
'1',0},
617 {
't',
'e',
's',
't',
'2',0},
618 {
't',
'e',
's',
't',
'3',0},
619 {
't',
'e',
's',
't',
'4',0}
624 ok(
session !=
NULL,
"WinHttpOpen failed to open session.\n");
627 ok(connection !=
NULL,
"WinHttpConnect failed to open a connection, error: %u.\n",
GetLastError());
633 skip(
"Network unreachable, skipping.\n");
642 ok(
ret ==
FALSE,
"WinHttpQueryHeaders unexpectedly succeeded, found 'Warning' header.\n");
646 ok(
ret,
"WinHttpAddRequestHeaders failed to add new header, got %d with error %u.\n",
ret,
err);
654 ok(
index == 1,
"WinHttpQueryHeaders failed: header index not incremented\n");
655 ok(
memcmp(
buffer, test_indices[0],
sizeof(test_indices[0])) == 0,
"WinHttpQueryHeaders failed: incorrect string returned\n");
656 ok(
len == 5*
sizeof(
WCHAR),
"WinHttpQueryHeaders failed: invalid length returned, expected 5, got %d\n",
len);
660 ok(
ret ==
FALSE,
"WinHttpQueryHeaders unexpectedly succeeded, second index should not exist.\n");
671 ok(
ret ==
FALSE,
"WinHttpQueryHeaders unexpectedly succeeded with a buffer that's too small.\n");
673 "WinHttpQueryHeaders failed, modified the buffer when it should not have.\n");
674 ok(
len == 6*
sizeof(
WCHAR),
"WinHttpQueryHeaders returned invalid length, expected 12, got %d\n",
len);
682 ok(
ret ==
FALSE,
"WinHttpQueryHeaders unexpectedly succeeded.\n");
684 ok(
len > 40,
"WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n",
len);
685 ok(
index == 0,
"WinHttpQueryHeaders incorrectly incremented header index.\n");
693 ok(
ret ==
FALSE,
"WinHttpQueryHeaders unexpectedly succeeded.\n");
695 "WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICENT_BUFFER, got %u\n",
GetLastError());
696 ok(
len > 40,
"WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n",
len);
697 ok(
index == 0,
"WinHttpQueryHeaders incorrectly incremented header index.\n");
704 ok(
ret ==
FALSE,
"WinHttpQueryHeaders unexpectedly succeeded.\n");
706 "WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %u\n",
GetLastError());
707 ok(
len > 40,
"WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n",
len);
708 ok(
index == 0,
"WinHttpQueryHeaders failed: index was incremented.\n");
717 ok(
ret ==
TRUE,
"WinHttpQueryHeaders failed: got %d\n",
ret);
718 ok(
len +
sizeof(
WCHAR) <= oldlen,
"WinHttpQueryHeaders resulting length longer than advertized.\n");
721 ok(
memcmp(
buffer, test_header_begin,
sizeof(test_header_begin)) == 0 ||
722 memcmp(
buffer, full_path_test_header_begin,
sizeof(full_path_test_header_begin)) == 0,
723 "WinHttpQueryHeaders returned invalid beginning of header string.\n");
725 "WinHttpQueryHeaders returned invalid end of header string.\n");
726 ok(
index == 0,
"WinHttpQueryHeaders incremented header index.\n");
733 ok(
ret ==
FALSE,
"WinHttpQueryHeaders unexpectedly succeeded.\n");
735 "WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %u\n",
GetLastError());
736 ok(
len > 40,
"WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n",
len);
737 ok(
index == 0,
"WinHttpQueryHeaders failed: index was incremented.\n");
746 ok(
len +
sizeof(
WCHAR) <= oldlen,
"resulting length longer than advertized\n");
748 "no double NULL terminator\n");
749 ok(
memcmp(
buffer, test_header_begin,
sizeof(test_header_begin)) == 0 ||
750 memcmp(
buffer, full_path_test_header_begin,
sizeof(full_path_test_header_begin)) == 0,
751 "invalid beginning of header string.\n");
752 ok(
index == 0,
"header index was incremented\n");
756 ok(
ret ==
TRUE,
"WinHttpAddRequestHeaders failed to add duplicate header: %d\n",
ret);
763 ok(
index == 1,
"WinHttpQueryHeaders failed to increment index.\n");
764 ok(
memcmp(
buffer, test_indices[0],
sizeof(test_indices[0])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
770 ok(
index == 2,
"WinHttpQueryHeaders failed to increment index.\n");
771 ok(
memcmp(
buffer, test_indices[1],
sizeof(test_indices[1])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
774 ok(
ret ==
TRUE,
"WinHttpAddRequestHeaders failed to add duplicate header.\n");
781 ok(
index == 1,
"WinHttpQueryHeaders failed to increment index.\n");
783 ok(
memcmp(
buffer, test_indices[
reverse ? 2 : 1],
sizeof(test_indices[
reverse ? 2 : 1])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
789 ok(
index == 2,
"WinHttpQueryHeaders failed to increment index.\n");
790 ok(
memcmp(
buffer, test_indices[
reverse ? 1 : 2],
sizeof(test_indices[
reverse ? 1 : 2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
794 ok(
ret ==
FALSE,
"WinHttpAddRequestHeaders incorrectly replaced existing header.\n");
801 ok(
index == 1,
"WinHttpQueryHeaders failed to increment index.\n");
802 ok(
memcmp(
buffer, test_indices[
reverse ? 2 : 1],
sizeof(test_indices[
reverse ? 2 : 1])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
808 ok(
index == 2,
"WinHttpQueryHeaders failed to increment index.\n");
809 ok(
memcmp(
buffer, test_indices[
reverse ? 1 : 2],
sizeof(test_indices[
reverse ? 1 : 2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
814 ok(
ret ==
FALSE,
"WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
818 ok(
ret ==
TRUE,
"WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE.\n");
825 ok(
index == 1,
"WinHttpQueryHeaders failed to increment index.\n");
827 reverse ?
sizeof(test_flag_coalesce_reverse) :
sizeof(test_flag_coalesce)) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
833 ok(
index == 2,
"WinHttpQueryHeaders failed to increment index.\n");
834 ok(
memcmp(
buffer, test_indices[
reverse ? 1 : 2],
sizeof(test_indices[
reverse ? 1 : 2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
839 ok(
ret ==
FALSE,
"WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
843 ok(
ret ==
TRUE,
"WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA.\n");
850 ok(
index == 1,
"WinHttpQueryHeaders failed to increment index.\n");
852 reverse ?
sizeof(test_flag_coalesce_comma_reverse) :
sizeof(test_flag_coalesce_comma)) == 0,
853 "WinHttpQueryHeaders returned incorrect string.\n");
859 ok(
index == 2,
"WinHttpQueryHeaders failed to increment index.\n");
860 ok(
memcmp(
buffer, test_indices[
reverse ? 1 : 2],
sizeof(test_indices[
reverse ? 1 : 2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
865 ok(
ret ==
FALSE,
"WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
870 ok(
ret ==
TRUE,
"WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON.\n");
877 ok(
index == 1,
"WinHttpQueryHeaders failed to increment index.\n");
879 reverse ?
sizeof(test_flag_coalesce_semicolon_reverse) :
sizeof(test_flag_coalesce_semicolon)) == 0,
880 "WinHttpQueryHeaders returned incorrect string.\n");
886 ok(
index == 2,
"WinHttpQueryHeaders failed to increment index.\n");
887 ok(
memcmp(
buffer, test_indices[
reverse ? 1 : 2],
sizeof(test_indices[
reverse ? 1 : 2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
892 ok(
ret ==
FALSE,
"WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
896 ok(
ret ==
TRUE,
"WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE.\n");
903 ok(
index == 1,
"WinHttpQueryHeaders failed to increment index.\n");
904 ok(
memcmp(
buffer, test_indices[
reverse ? 3 : 2],
sizeof(test_indices[
reverse ? 3 : 2])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
910 ok(
index == 2,
"WinHttpQueryHeaders failed to increment index.\n");
911 ok(
memcmp(
buffer, test_indices[
reverse ? 1 : 3],
sizeof(test_indices[
reverse ? 1 : 3])) == 0,
"WinHttpQueryHeaders returned incorrect string.\n");
916 ok(
ret ==
FALSE,
"WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
919 ok(!
ret,
"WinHttpAddRequestHeaders failed\n");
922 ok(
ret,
"WinHttpAddRequestHeaders failed\n");
933 ok(!
ret,
"WinHttpAddRequestHeaders failed\n");
936 ok(!
ret,
"WinHttpAddRequestHeaders failed\n");
939 ok(!
ret,
"WinHttpAddRequestHeaders failed\n");
942 ok(
ret,
"WinHttpAddRequestHeaders failed\n");
956 ok(!
ret,
"unexpected success\n");
968 ok(!
memcmp(
buffer, test_header_bytes,
sizeof(test_header_bytes)),
"incorrect string returned\n");
976 ok(!
ret,
"unexpected success\n");
981 ok(!
ret,
"unexpected success\n");
993 ok(!
memcmp(
buffer, value_nospace,
sizeof(value_nospace)),
"incorrect string\n");
1004 ok(!
ret,
"unexpected success\n");
1016 ok(!
memcmp(
buffer, value_nospace,
sizeof(value_nospace)),
"incorrect string\n");
1019 ok(
ret ==
TRUE,
"WinHttpCloseHandle failed on closing request, got %d.\n",
ret);
1022 ok(
ret ==
TRUE,
"WinHttpCloseHandle failed on closing connection, got %d.\n",
ret);
1024 ok(
ret ==
TRUE,
"WinHttpCloseHandle failed on closing session, got %d.\n",
ret);
1034 trace(
"WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR\n");
1037#define X(x) if (flags & x) trace("%s\n", #x);
1050 static const char data_start[] =
"<!DOCTYPE html PUBLIC";
1079 ok(!
ret,
"unexpected success\n");
1081 "setting client cert context returned %u\n",
err);
1087 skip(
"Connection failed, skipping.\n");
1118 ok(!
ret,
"success\n");
1122 ok(!
ret,
"success\n");
1144 skip(
"secure connection failed, skipping remaining secure tests\n");
1154 size =
sizeof(bitness);
1169 trace(
"dwKeySize %u\n",
info.dwKeySize);
1177 skip(
"connection error, skipping remaining secure tests\n");
1185 ok(available_size > 2014,
"available_size = %u\n", available_size);
1195 ok(!
ret,
"succeeded unexpectedly\n");
1206 if (read_size <= 32)
1209 ok(read_size >= available_size,
"read_size = %u, available_size = %u\n", read_size, available_size);
1243 skip(
"connection failed, skipping\n");
1266 skip(
"connection failed, skipping\n");
1278 ok(!
ret,
"succeeded unexpectedly\n");
1300 'S',
'o',
'f',
't',
'w',
'a',
'r',
'e',
'\\',
1301 'M',
'i',
'c',
'r',
'o',
's',
'o',
'f',
't',
'\\',
1302 'W',
'i',
'n',
'd',
'o',
'w',
's',
'\\',
1303 'C',
'u',
'r',
'r',
'e',
'n',
't',
'V',
'e',
'r',
's',
'i',
'o',
'n',
'\\',
1304 'I',
'n',
't',
'e',
'r',
'n',
'e',
't',
' ',
'S',
'e',
't',
't',
'i',
'n',
'g',
's',
'\\',
1305 'C',
'o',
'n',
'n',
'e',
'c',
't',
'i',
'o',
'n',
's',0 };
1307 'W',
'i',
'n',
'H',
't',
't',
'p',
'S',
'e',
't',
't',
'i',
'n',
'g',
's',0 };
1349 if (
sizeof(
void *) >
sizeof(
int) ||
wow64)
1360 static WCHAR wideString[] = { 0x226f, 0x575b, 0 };
1361 static WCHAR normalString[] = {
'f',
'o',
'o',0 };
1397 "expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
1401 info.dwAccessType = 0xdeadbeef;
1406 "expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
1414 "expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
1415 info.lpszProxyBypass = normalString;
1419 "expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
1422 info.lpszProxy = wideString;
1426 skip(
"couldn't set default proxy configuration: access denied\n");
1430 "expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
1432 info.lpszProxy = normalString;
1436 skip(
"couldn't set default proxy configuration: access denied\n");
1458 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1463 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1468 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1473 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1494 ok(
value == 0x0123,
"Expected 0x0123, got %u\n",
value);
1501 ok(
value == 0x4567,
"Expected 0x4567, got %u\n",
value);
1508 ok(
value == 0x89ab,
"Expected 0x89ab, got %u\n",
value);
1515 ok(
value == 0xcdef,
"Expected 0xcdef, got %u\n",
value);
1575 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1587 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1599 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1611 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1622 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1629 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1636 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1643 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1648 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1653 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1658 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1663 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1668 "expected ERROR_WINHTTP_INVALID_TYPE, got %u\n",
GetLastError());
1673 "expected ERROR_WINHTTP_INVALID_TYPE, got %u\n",
GetLastError());
1679 "expected ERROR_WINHTTP_INVALID_TYPE, got %u\n",
GetLastError());
1685 "expected ERROR_WINHTTP_INVALID_TYPE, got %u\n",
GetLastError());
1691 "expected ERROR_WINHTTP_INVALID_TYPE, got %u\n",
GetLastError());
1697 "expected ERROR_WINHTTP_INVALID_TYPE, got %u\n",
GetLastError());
1710 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1722 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1734 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1746 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1757 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1764 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1771 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1778 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1783 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1788 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1793 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1798 "expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError());
1817 ok(
value == 0xcdef,
"Expected 0xcdef, got %u\n",
value);
1824 ok(
value == 0x89ab,
"Expected 0x89ab, got %u\n",
value);
1831 ok(
value == 0x4567,
"Expected 0x4567, got %u\n",
value);
1838 ok(
value == 0x0123,
"Expected 0x0123, got %u\n",
value);
1898 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1910 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1922 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1934 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
1949 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1961 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1973 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1985 ok(
value == 0xdead,
"Expected 0xdead, got %u\n",
value);
1997 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
2009 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
2021 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
2033 ok(
value == 0xbeefdead,
"Expected 0xbeefdead, got %u\n",
value);
2065 ok(!
ret,
"expected failure\n");
2106 static const WCHAR nxdomain[] =
2107 {
'n',
'x',
'd',
'o',
'm',
'a',
'i',
'n',
'.',
'w',
'i',
'n',
'e',
'h',
'q',
'.',
'o',
'r',
'g',0};
2131 skip(
"nxdomain returned success. Broken ISP redirects?\n");
2135 "expected ERROR_WINHTTP_NAME_NOT_RESOLVED got %u\n",
GetLastError());
2147 skip(
"Skipping host resolution tests, host resolution preformed by proxy\n");
2165 skip(
"connection failed, skipping\n");
2168 ok(
ret,
"failed to send request\n");
2178"<HEAD><TITLE>winhttp test page</TITLE></HEAD>\r\n"
2179"<BODY>The quick brown fox jumped over the lazy dog<P></BODY>\r\n"
2183"HTTP/1.1 200 OK\r\n"
2184"Server: winetest\r\n"
2188"HTTP/1.1 400 Bad Request\r\n"
2192"HTTP/1.1 200 OK\r\n"
2193"Set-Cookie: name = value \r\n"
2194"Set-Cookie: NAME = value \r\n"
2198"HTTP/1.1 200 OK\r\n"
2199"Set-Cookie: name2=value; Domain = localhost; Path=/cookie5;Expires=Wed, 13 Jan 2021 22:23:01 GMT; HttpOnly; \r\n"
2203"HTTP/1.1 204 No Content\r\n"
2204"Server: winetest\r\n"
2208"HTTP/1.1 304 Not Modified\r\n"
2212"HTTP/1.1 401 Unauthorized\r\n"
2213"Server: winetest\r\n"
2214"Connection: close\r\n"
2215"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
2216"Content-Length: 12\r\n"
2217"Content-Type: text/plain\r\n"
2221"HTTP/1.1 200 OK\r\n"
2222"Server: winetest\r\n"
2223"Connection: close\r\n"
2224"Content-Length: 11\r\n"
2225"Content-Type: text/plain\r\n"
2229"HTTP/1.1 200 OK\r\n"
2230"Content-Length: 100\r\n"
2234"HTTP/1.1 401 Unauthorized\r\n"
2235"Server: winetest\r\n"
2236"WWW-Authenticate: Bearer\r\n"
2237"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
2238"WWW-Authenticate: NTLM\r\n"
2239"Content-Length: 10\r\n"
2240"Content-Type: text/plain\r\n"
2244"HTTP/1.1 401 Unauthorized\r\n"
2245"Server: winetest\r\n"
2246"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
2247"WWW-Authenticate: NTLM\r\n"
2248"Content-Length: 10240\r\n"
2249"Content-Type: text/plain\r\n"
2253"HTTP/1.1 302 Found\r\n"
2254"Content-Length: 0\r\n"
2256"WWW-Authenticate: Passport1.4\r\n"
2269#define BIG_BUFFER_LEN 0x2250
2274 int r,
c = -1,
i, on;
2279 int last_request = 0;
2311 if (
i < 4)
continue;
2324 if (
strstr(
buffer,
"Authorization: Basic dXNlcjpwd2Q="))
2332 if (
strstr(
buffer,
"Authorization: Basic dXNlcjpwd2Q="))
2386 for (
i = 0;
i < 10240;
i++)
send(
c,
"A", 1, 0);
2404 if (
strstr(
buffer,
"Cookie: name=value2; NAME=value; name=value\r\n") ||
2412 if (
strstr(
buffer,
"Cookie: NAME=value; name=value\r\n") ||
2425 static const char res[] =
"%0D%0A%1F%7F%3C%20%one?%1F%7F%20!%22%23$%&'()*+,-./:;%3C=%3E?@%5B%5C%5D"
2426 "%5E_%60%7B%7C%7D~%0D%0A ";
2427 static const char res2[] =
"%0D%0A%1F%7F%3C%20%25two?%1F%7F%20!%22%23$%25&'()*+,-./:;%3C=%3E?@%5B%5C%5D"
2428 "%5E_%60%7B%7C%7D~%0D%0A ";
2429 static const char res3[] =
"\x1f\x7f<%20%three?\x1f\x7f%20!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
2430 static const char res4[] =
"%0D%0A%1F%7F%3C%20%four?\x1f\x7f%20!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
2431 static const char res5[] =
"&text=one%C2%80%7F~";
2432 static const char res6[] =
"&text=two%C2%80\x7f~";
2433 static const char res7[] =
"&text=%E5%90%9B%E3%81%AE%E5%90%8D%E3%81%AF";
2457 }
while (!last_request);
2465 static const WCHAR test_header_end_clrf[] = {
'\r',
'\n',
'\r',
'\n',0};
2466 static const WCHAR test_header_end_raw[] = {0,0};
2469 WCHAR buffer2[0x100];
2522 ok(!
ret,
"unexpected success\n");
2524 ok(supported == 0xdeadbeef,
"got %x\n", supported);
2528 size =
sizeof(buffer2);
2529 memset(buffer2, 0,
sizeof(buffer2));
2532 ok(!
memcmp(buffer2 +
lstrlenW(buffer2) - 4, test_header_end_clrf,
sizeof(test_header_end_clrf)),
2533 "WinHttpQueryHeaders returned invalid end of header string\n");
2535 size =
sizeof(buffer2);
2536 memset(buffer2, 0,
sizeof(buffer2));
2539 ok(!
memcmp(buffer2 + (
size /
sizeof(
WCHAR)) - 1, test_header_end_raw,
sizeof(test_header_end_raw)),
2540 "WinHttpQueryHeaders returned invalid end of header string\n");
2541 ok(buffer2[(
size /
sizeof(
WCHAR)) - 2] != 0,
"returned string has too many NULL characters\n");
2557 static const WCHAR authW[] = {
'/',
'a',
'u',
't',
'h',0};
2558 static const WCHAR auth_with_credsW[] = {
'/',
'a',
'u',
't',
'h',
'_',
'w',
'i',
't',
'h',
'_',
'c',
'r',
'e',
'd',
's',0};
2559 static WCHAR userW[] = {
'u',
's',
'e',
'r',0};
2560 static WCHAR passW[] = {
'p',
'w',
'd',0};
2561 static WCHAR pass2W[] = {
'p',
'w',
'd',
'2',0};
2579 ok(!
ret,
"expected failure\n");
2585 ok(!
ret,
"expected failure\n");
2588 supported = 0xdeadbeef;
2592 ok(!
ret,
"expected failure\n");
2594 ok(supported == 0xdeadbeef,
"got %x\n", supported);
2596 supported =
first = 0xdeadbeef;
2600 ok(!
ret,
"expected failure\n");
2602 ok(supported == 0xdeadbeef,
"got %x\n", supported);
2609 ok(!
ret,
"expected failure\n");
2611 ok(supported == 0xdeadbeef,
"got %x\n", supported);
2619 ok(!
ret,
"expected failure\n");
2621 ok(supported == 0xdeadbeef,
"got %x\n", supported);
2643 ok(
size == 12,
"expected 12, got %u\n",
size);
2651 ok(
ret,
"failed to query authentication schemes %u\n",
error);
2660 ok(
ret,
"failed to set credentials %u\n",
error);
2672 ok(!
ret,
"expected failure\n");
2678 ok(!
ret,
"expected failure\n");
2684 ok(!
ret,
"expected failure\n");
2690 ok(!
ret,
"expected failure\n");
2714 ok(
size == 11,
"expected 11, got %u\n",
size);
2753 ok(
size == 11,
"expected 11, got %u\n",
size);
2834 static const WCHAR multiauthW[] = {
'/',
'm',
'u',
'l',
't',
'i',
'a',
'u',
't',
'h',0};
2835 static const WCHAR www_authenticateW[] =
2836 {
'W',
'W',
'W',
'-',
'A',
'u',
't',
'h',
'e',
'n',
't',
'i',
'c',
'a',
't',
'e',0};
2837 static const WCHAR getW[] = {
'G',
'E',
'T',0};
2854 ok(
ret,
"expected success\n");
2857 ok(
ret,
"expected success\n");
2861 ok(
ret,
"expected success\n");
2869 ok(
ret,
"expected success\n");