Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
dfd9681f
Commit
dfd9681f
authored
Aug 14, 2008
by
Zac Brown
Committed by
Alexandre Julliard
Aug 19, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp: Add test for adding/querying headers.
parent
db0b7bef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
371 additions
and
1 deletion
+371
-1
winhttp.c
dlls/winhttp/tests/winhttp.c
+371
-1
No files found.
dlls/winhttp/tests/winhttp.c
View file @
dfd9681f
...
...
@@ -19,7 +19,6 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <winhttp.h>
...
...
@@ -184,10 +183,381 @@ static void test_WinHttpTimeToSystemTime(void)
"Returned SYSTEMTIME structure did not match expected SYSTEMTIME structure.
\n
"
);
}
static
void
test_WinHttpAddHeaders
(
void
)
{
HINTERNET
session
,
request
,
connection
;
BOOL
ret
;
WCHAR
buffer
[
MAX_PATH
];
WCHAR
check_buffer
[
MAX_PATH
];
DWORD
index
,
len
,
oldlen
;
static
const
WCHAR
test_site
[]
=
{
'c'
,
'r'
,
'o'
,
's'
,
's'
,
'o'
,
'v'
,
'e'
,
'r'
,
'.'
,
'c'
,
'o'
,
'd'
,
'e'
,
'w'
,
'e'
,
'a'
,
'v'
,
'e'
,
'r'
,
's'
,
'.'
,
'c'
,
'o'
,
'm'
,
0
};
static
const
WCHAR
test_file
[]
=
{
'/'
,
'p'
,
'o'
,
's'
,
't'
,
't'
,
'e'
,
's'
,
't'
,
'.'
,
'p'
,
'h'
,
'p'
,
0
};
static
const
WCHAR
test_verb
[]
=
{
'P'
,
'O'
,
'S'
,
'T'
,
0
};
static
const
WCHAR
test_header_begin
[]
=
{
'P'
,
'O'
,
'S'
,
'T'
,
' '
,
'/'
,
'p'
,
'o'
,
's'
,
't'
,
't'
,
'e'
,
's'
,
't'
,
'.'
,
'p'
,
'h'
,
'p'
,
' '
,
'H'
,
'T'
,
'T'
,
'P'
,
'/'
,
'1'
};
static
const
WCHAR
test_header_end
[]
=
{
'\r'
,
'\n'
,
'\r'
,
'\n'
,
0
};
static
const
WCHAR
test_header_name
[]
=
{
'W'
,
'a'
,
'r'
,
'n'
,
'i'
,
'n'
,
'g'
,
0
};
static
const
WCHAR
test_flag_coalesce
[]
=
{
't'
,
'e'
,
's'
,
't'
,
'2'
,
','
,
' '
,
't'
,
'e'
,
's'
,
't'
,
'4'
,
0
};
static
const
WCHAR
test_flag_coalesce_comma
[]
=
{
't'
,
'e'
,
's'
,
't'
,
'2'
,
','
,
' '
,
't'
,
'e'
,
's'
,
't'
,
'4'
,
','
,
' '
,
't'
,
'e'
,
's'
,
't'
,
'5'
,
0
};
static
const
WCHAR
test_flag_coalesce_semicolon
[]
=
{
't'
,
'e'
,
's'
,
't'
,
'2'
,
','
,
' '
,
't'
,
'e'
,
's'
,
't'
,
'4'
,
','
,
' '
,
't'
,
'e'
,
's'
,
't'
,
'5'
,
';'
,
' '
,
't'
,
'e'
,
's'
,
't'
,
'6'
,
0
};
static
const
WCHAR
test_headers
[][
14
]
=
{
{
'W'
,
'a'
,
'r'
,
'n'
,
'i'
,
'n'
,
'g'
,
':'
,
't'
,
'e'
,
's'
,
't'
,
'1'
,
0
},
{
'W'
,
'a'
,
'r'
,
'n'
,
'i'
,
'n'
,
'g'
,
':'
,
't'
,
'e'
,
's'
,
't'
,
'2'
,
0
},
{
'W'
,
'a'
,
'r'
,
'n'
,
'i'
,
'n'
,
'g'
,
':'
,
't'
,
'e'
,
's'
,
't'
,
'3'
,
0
},
{
'W'
,
'a'
,
'r'
,
'n'
,
'i'
,
'n'
,
'g'
,
':'
,
't'
,
'e'
,
's'
,
't'
,
'4'
,
0
},
{
'W'
,
'a'
,
'r'
,
'n'
,
'i'
,
'n'
,
'g'
,
':'
,
't'
,
'e'
,
's'
,
't'
,
'5'
,
0
},
{
'W'
,
'a'
,
'r'
,
'n'
,
'i'
,
'n'
,
'g'
,
':'
,
't'
,
'e'
,
's'
,
't'
,
'6'
,
0
},
{
'W'
,
'a'
,
'r'
,
'n'
,
'i'
,
'n'
,
'g'
,
':'
,
't'
,
'e'
,
's'
,
't'
,
'7'
,
0
}
};
static
const
WCHAR
test_indices
[][
6
]
=
{
{
't'
,
'e'
,
's'
,
't'
,
'1'
,
0
},
{
't'
,
'e'
,
's'
,
't'
,
'2'
,
0
},
{
't'
,
'e'
,
's'
,
't'
,
'3'
,
0
},
{
't'
,
'e'
,
's'
,
't'
,
'4'
,
0
}
};
session
=
WinHttpOpen
(
test_useragent
,
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
,
WINHTTP_NO_PROXY_NAME
,
WINHTTP_NO_PROXY_BYPASS
,
0
);
todo_wine
ok
(
session
!=
NULL
,
"WinHttpOpen failed to open session.
\n
"
);
connection
=
WinHttpConnect
(
session
,
test_site
,
INTERNET_DEFAULT_HTTP_PORT
,
0
);
todo_wine
ok
(
connection
!=
NULL
,
"WinHttpConnect failed to open a connection, error: %u.
\n
"
,
GetLastError
());
request
=
WinHttpOpenRequest
(
connection
,
test_verb
,
test_file
,
NULL
,
WINHTTP_NO_REFERER
,
WINHTTP_DEFAULT_ACCEPT_TYPES
,
0
);
if
(
request
==
NULL
&&
GetLastError
()
==
ERROR_WINHTTP_NAME_NOT_RESOLVED
)
{
skip
(
"Network unreachable, skipping.
\n
"
);
goto
done
;
}
todo_wine
ok
(
request
!=
NULL
,
"WinHttpOpenRequest failed to open a request, error: %u.
\n
"
,
GetLastError
());
index
=
0
;
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders unexpectedly succeeded, found 'Warning' header."
);
ret
=
WinHttpAddRequestHeaders
(
request
,
test_headers
[
0
],
-
1L
,
WINHTTP_ADDREQ_FLAG_ADD
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpAddRequestHeader failed to add new header, got %d with error %u.
\n
"
,
ret
,
GetLastError
());
index
=
0
;
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
1
,
"WinHttpQueryHeaders failed: header index not incremented
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
0
],
sizeof
(
test_indices
[
0
]))
==
0
,
"WinHttpQueryHeaders failed: incorrect string returned
\n
"
);
ok
(
len
==
5
*
sizeof
(
WCHAR
),
"WinHttpQueryHeaders failed: invalid length returned, expected 5, got %d
\n
"
,
len
);
}
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders unexpectedly succeeded, second index should not exist.
\n
"
);
/* Try to fetch the header info with a buffer thats big enough to fit string but not NULL terminator. */
index
=
0
;
len
=
5
*
sizeof
(
WCHAR
);
memcpy
(
buffer
,
check_buffer
,
sizeof
(
buffer
));
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders unexpectedly succeeded with a buffer thats too small.
\n
"
);
ok
(
memcmp
(
buffer
,
check_buffer
,
sizeof
(
buffer
))
==
0
,
"WinHttpQueryHeaders failed, modified the buffer when it should not have.
\n
"
);
todo_wine
ok
(
len
==
6
*
sizeof
(
WCHAR
),
"WinHttpQueryHeaders returned invalid length, expected 12, got %d
\n
"
,
len
);
/* Try with a NULL buffer */
index
=
0
;
len
=
sizeof
(
buffer
);
SetLastError
(
0xdeadbeef
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_RAW_HEADERS_CRLF
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
NULL
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders unexpectedly succeeded.
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Expected ERROR_INSUFFICIENT_BUFFER, got %u
\n
"
,
GetLastError
());
ok
(
len
>
40
,
"WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d
\n
"
,
len
);
ok
(
index
==
0
,
"WinHttpQueryHeaders incorrectly incremented header index.
\n
"
);
/* Try with a NULL buffer and a length thats too small */
index
=
0
;
len
=
10
;
SetLastError
(
0xdeadbeef
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_RAW_HEADERS_CRLF
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
NULL
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders unexpectedly succeeded.
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICENT_BUFFER, go %u
\n
"
,
GetLastError
());
ok
(
len
>
40
,
"WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d
\n
"
,
len
);
}
ok
(
index
==
0
,
"WinHttpQueryHeaders incorrectly incremented header index.
\n
"
);
index
=
0
;
len
=
0
;
SetLastError
(
0xdeadbeef
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_RAW_HEADERS_CRLF
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
NULL
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders unexpectedly succeeded.
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %u
\n
"
,
GetLastError
());
ok
(
len
>
40
,
"WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d
\n
"
,
len
);
}
ok
(
index
==
0
,
"WinHttpQueryHeaders failed: index was incremented.
\n
"
);
/* valid query */
oldlen
=
len
;
index
=
0
;
len
=
sizeof
(
buffer
);
memset
(
buffer
,
0xff
,
sizeof
(
buffer
));
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_RAW_HEADERS_CRLF
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: got %d
\n
"
,
ret
);
ok
(
len
+
sizeof
(
WCHAR
)
<=
oldlen
,
"WinHttpQueryHeaders resulting length longer than advertized.
\n
"
);
ok
((
len
<
sizeof
(
buffer
)
-
sizeof
(
WCHAR
))
&&
buffer
[
len
/
sizeof
(
WCHAR
)]
==
0
,
"WinHttpQueryHeaders did not append NULL terminator
\n
"
);
ok
(
len
==
lstrlenW
(
buffer
)
*
sizeof
(
WCHAR
),
"WinHttpQueryHeaders returned incorrect length.
\n
"
);
ok
(
memcmp
(
buffer
,
test_header_begin
,
sizeof
(
test_header_begin
))
==
0
,
"WinHttpQueryHeaders returned invalid beginning of header string.
\n
"
);
ok
(
memcmp
(
buffer
+
lstrlenW
(
buffer
)
-
4
,
test_header_end
,
sizeof
(
test_header_end
))
==
0
,
"WinHttpQueryHeaders returned invalid end of header string.
\n
"
);
}
ok
(
index
==
0
,
"WinHttpQueryHeaders incremented header index.
\n
"
);
/* tests for more indices */
ret
=
WinHttpAddRequestHeaders
(
request
,
test_headers
[
1
],
-
1L
,
WINHTTP_ADDREQ_FLAG_ADD
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpAddRequestHeaders failed to add duplicate header: %d
\n
"
,
ret
);
index
=
0
;
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
1
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
0
],
sizeof
(
test_indices
[
0
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
2
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
1
],
sizeof
(
test_indices
[
1
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
ret
=
WinHttpAddRequestHeaders
(
request
,
test_headers
[
2
],
-
1L
,
WINHTTP_ADDREQ_FLAG_REPLACE
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpAddRequestHeaders failed to add duplicate header.
\n
"
);
index
=
0
;
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
1
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
1
],
sizeof
(
test_indices
[
1
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
2
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
2
],
sizeof
(
test_indices
[
2
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
/* add if new flag */
ret
=
WinHttpAddRequestHeaders
(
request
,
test_headers
[
3
],
-
1L
,
WINHTTP_ADDREQ_FLAG_ADD_IF_NEW
);
ok
(
ret
==
FALSE
,
"WinHttpAddRequestHeaders incorrectly replaced existing header.
\n
"
);
index
=
0
;
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
1
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
1
],
sizeof
(
test_indices
[
1
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
2
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
2
],
sizeof
(
test_indices
[
2
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders succeeded unexpectedly, found third header.
\n
"
);
/* coalesce flag */
ret
=
WinHttpAddRequestHeaders
(
request
,
test_headers
[
3
],
-
1L
,
WINHTTP_ADDREQ_FLAG_COALESCE
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE.
\n
"
);
index
=
0
;
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
1
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_flag_coalesce
,
sizeof
(
test_flag_coalesce
))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
2
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
2
],
sizeof
(
test_indices
[
2
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders succeeded unexpectedly, found third header.
\n
"
);
/* coalesce with comma flag */
ret
=
WinHttpAddRequestHeaders
(
request
,
test_headers
[
4
],
-
1L
,
WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA.
\n
"
);
index
=
0
;
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
1
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_flag_coalesce_comma
,
sizeof
(
test_flag_coalesce_comma
))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
2
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
2
],
sizeof
(
test_indices
[
2
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders succeeded unexpectedly, found third header.
\n
"
);
/* coalesce with semicolon flag */
ret
=
WinHttpAddRequestHeaders
(
request
,
test_headers
[
5
],
-
1L
,
WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON.
\n
"
);
index
=
0
;
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
1
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_flag_coalesce_semicolon
,
sizeof
(
test_flag_coalesce_semicolon
))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
2
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
2
],
sizeof
(
test_indices
[
2
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders succeeded unexpectedly, found third header.
\n
"
);
/* add and replace flags */
ret
=
WinHttpAddRequestHeaders
(
request
,
test_headers
[
3
],
-
1L
,
WINHTTP_ADDREQ_FLAG_ADD
|
WINHTTP_ADDREQ_FLAG_REPLACE
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE.
\n
"
);
index
=
0
;
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
1
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
2
],
sizeof
(
test_indices
[
2
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
todo_wine
{
ok
(
ret
==
TRUE
,
"WinHttpQueryHeaders failed: %u
\n
"
,
GetLastError
());
ok
(
index
==
2
,
"WinHttpQueryHeaders failed to increment index.
\n
"
);
ok
(
memcmp
(
buffer
,
test_indices
[
3
],
sizeof
(
test_indices
[
2
]))
==
0
,
"WinHttpQueryHeaders returned incorrect string.
\n
"
);
}
len
=
sizeof
(
buffer
);
ret
=
WinHttpQueryHeaders
(
request
,
WINHTTP_QUERY_CUSTOM
|
WINHTTP_QUERY_FLAG_REQUEST_HEADERS
,
test_header_name
,
buffer
,
&
len
,
&
index
);
ok
(
ret
==
FALSE
,
"WinHttpQueryHeaders succeeded unexpectedly, found third header.
\n
"
);
ret
=
WinHttpCloseHandle
(
request
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpCloseHandle failed on closing request, got %d.
\n
"
,
ret
);
done:
ret
=
WinHttpCloseHandle
(
connection
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpCloseHandle failed on closing connection, got %d.
\n
"
,
ret
);
ret
=
WinHttpCloseHandle
(
session
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpCloseHandle failed on closing session, got %d.
\n
"
,
ret
);
}
START_TEST
(
winhttp
)
{
test_OpenRequest
();
test_SendRequest
();
test_WinHttpTimeFromSystemTime
();
test_WinHttpTimeToSystemTime
();
test_WinHttpAddHeaders
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment