Ziqing Hui : wininet/tests: Test adding empty HTTP header.

Alexandre Julliard julliard at winehq.org
Wed May 4 16:14:44 CDT 2022


Module: wine
Branch: master
Commit: 3b8d9ac3d2d9980e4f29841a751a333e023fde56
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=3b8d9ac3d2d9980e4f29841a751a333e023fde56

Author: Ziqing Hui <zhui at codeweavers.com>
Date:   Fri Apr 15 11:43:09 2022 +0800

wininet/tests: Test adding empty HTTP header.

Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wininet/tests/http.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 80b3160820b..ec576ae81e2 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -2063,6 +2063,32 @@ static void HttpHeaders_test(void)
        "header still present\n");
     ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "got %lu\n", GetLastError());
 
+    /* Header with empty value should cause a failure */
+    todo_wine
+    {
+    SetLastError(0xdeadbeef);
+    ok(!HttpAddRequestHeadersA(hRequest, "EmptyTest1:", -1, HTTP_ADDREQ_FLAG_ADD), "Empty header should not be added.\n");
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error code %lu.\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ok(!HttpAddRequestHeadersA(hRequest, "EmptyTest2:\r\n", -1, HTTP_ADDREQ_FLAG_ADD), "Empty header should not be added.\n");
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error code %lu.\n", GetLastError());
+
+    len = sizeof(buffer);
+    strcpy(buffer, "EmptyTest1");
+    SetLastError(0xdeadbeef);
+    ok(!HttpQueryInfoA(hRequest, HTTP_QUERY_CUSTOM | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &len, NULL),
+       "Header with empty value is present.\n");
+    ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "Got unexpected error code %lu.\n", GetLastError());
+
+    len = sizeof(buffer);
+    strcpy(buffer, "EmptyTest2");
+    SetLastError(0xdeadbeef);
+    ok(!HttpQueryInfoA(hRequest, HTTP_QUERY_CUSTOM | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &len, NULL),
+       "Header with empty value is present.\n");
+    ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "Got unexpected error code %lu.\n", GetLastError());
+    }
+
     ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
 done:
     ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");




More information about the wine-cvs mailing list