wininet: Replacing a header with an empty value deletes it.
Hans Leidekker
hans at codeweavers.com
Thu Aug 29 08:26:18 CDT 2013
---
dlls/wininet/http.c | 2 +-
dlls/wininet/tests/http.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index b6ed7df..954c98b 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -6062,7 +6062,7 @@ static DWORD HTTP_ProcessHeader(http_request_t *request, LPCWSTR field, LPCWSTR
{
HTTP_DeleteCustomHeader( request, index );
- if (value)
+ if (value && value[0])
{
HTTPHEADERW hdr;
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index f04fc7b..bf57223 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -1759,6 +1759,27 @@ static void HttpHeaders_test(void)
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"value3")==0, "incorrect string was returned(%s)\n",buffer);
+ ok(HttpAddRequestHeaders(hRequest, "Authorization: Basic\r\n", -1, HTTP_ADDREQ_FLAG_ADD),
+ "unable to add header %u\n", GetLastError());
+
+ index = 0;
+ buffer[0] = 0;
+ len = sizeof(buffer);
+ ok(HttpQueryInfo(hRequest, HTTP_QUERY_AUTHORIZATION|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &len, &index),
+ "unable to query header %u\n", GetLastError());
+ ok(index == 1, "index was not incremented\n");
+ ok(!strcmp(buffer, "Basic"), "incorrect string was returned (%s)\n", buffer);
+
+ ok(HttpAddRequestHeaders(hRequest, "Authorization:\r\n", -1, HTTP_ADDREQ_FLAG_REPLACE),
+ "unable to remove header %u\n", GetLastError());
+
+ index = 0;
+ len = sizeof(buffer);
+ SetLastError(0xdeadbeef);
+ ok(!HttpQueryInfo(hRequest, HTTP_QUERY_AUTHORIZATION|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &len, &index),
+ "header still present\n");
+ ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "got %u\n", GetLastError());
+
ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
done:
ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
--
1.8.4.rc3
More information about the wine-patches
mailing list