Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/wininet/http.c | 5 ++++- dlls/wininet/tests/http.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index e9363208471..b2862ead789 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2918,7 +2918,10 @@ static DWORD set_content_length(http_request_t *request) WCHAR encoding[20]; DWORD size;
- if(request->status_code == HTTP_STATUS_NO_CONTENT || !wcscmp(request->verb, L"HEAD")) { + if(request->status_code == HTTP_STATUS_NO_CONTENT || request->status_code == HTTP_STATUS_NOT_MODIFIED || + !wcscmp(request->verb, L"HEAD")) + { + request->read_size = 0; request->contentLength = request->netconn_stream.content_length = 0; return ERROR_SUCCESS; } diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index bf4dce80bef..716d2b5cb76 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -2381,6 +2381,13 @@ static DWORD CALLBACK server_thread(LPVOID param) static const char nocontentmsg[] = "HTTP/1.1 204 No Content\r\nConnection: close\r\n\r\n"; send(c, nocontentmsg, sizeof(nocontentmsg)-1, 0); } + if (strstr(buffer, "GET /test_not_modified")) + { + static const char notmodifiedmsg[] = "HTTP/1.1 304 Not Modified\r\nConnection: close\r\n" + "\r\n" + "0123456789"; + send(c, notmodifiedmsg, sizeof(notmodifiedmsg)-1, 0); + } if (strstr(buffer, "GET /test_conn_close")) { static const char conn_close_response[] = "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\nsome content"; @@ -3487,6 +3494,36 @@ static void test_no_content(int port) CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); }
+static void test_not_modified(int port) +{ + DWORD avail; + HINTERNET ses, con, req; + BOOL ret; + + ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + ok(ses != NULL, "InternetOpen failed\n"); + + con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + ok(con != NULL, "InternetConnect failed\n"); + + req = HttpOpenRequestA(con, NULL, "/test_not_modified", NULL, NULL, NULL, 0, 0); + ok(req != NULL, "HttpOpenRequest failed\n"); + + SetLastError(0xdeadbeef); + ret = HttpSendRequestW(req, NULL, 0, NULL, 0); + ok(ret, "HttpSendRequest failed: %u\n", GetLastError()); + test_status_code(req, 304); + + avail = 0; + ret = InternetQueryDataAvailable(req, &avail, 0, 0); + ok(ret, "InternetQueryDataAvailable failed: %u\n", GetLastError()); + ok(avail == 0, "got %d\n", avail); + + InternetCloseHandle(req); + InternetCloseHandle(con); + InternetCloseHandle(ses); +} + static void test_conn_close(int port) { HINTERNET session, connection, req; @@ -6060,6 +6097,7 @@ static void test_http_connection(void) test_HttpSendRequestW(si.port); test_options(si.port); test_no_content(si.port); + test_not_modified(si.port); test_conn_close(si.port); test_no_cache(si.port); test_cache_read_gzipped(si.port);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=99066
Your paranoid android.
=== w8adm (32 bit report) ===
wininet: http.c:697: Test failed: req_error = 12007 http.c:708: Test failed: expected status 11 (INTERNET_STATUS_NAME_RESOLVED) 1 times, received 0 times http.c:721: Test failed: expected status 30 (INTERNET_STATUS_SENDING_REQUEST) 1 times, received 0 times http.c:722: Test failed: expected status 31 (INTERNET_STATUS_REQUEST_SENT) 1 times, received 0 times http.c:723: Test failed: expected status 40 (INTERNET_STATUS_RECEIVING_RESPONSE) 1 times, received 0 times http.c:724: Test failed: expected status 41 (INTERNET_STATUS_RESPONSE_RECEIVED) 1 times, received 0 times http.c:733: Test failed: flags = 8, expected 0 http.c:747: Test failed: Expected any header character, got 0x00 http.c:774: Test failed: Expected 0x0000, got 7777 http.c:937: Test failed: Returned zero size in response to request complete http.c:376: Test failed: unexpected status 10 (INTERNET_STATUS_RESOLVING_NAME) http.c:376: Test failed: unexpected status 11 (INTERNET_STATUS_NAME_RESOLVED) http.c:718: Test failed: expected status 10 (INTERNET_STATUS_RESOLVING_NAME) 0 times, received 1 times http.c:719: Test failed: expected status 11 (INTERNET_STATUS_NAME_RESOLVED) 0 times, received 1 times
On Wed, 2021-09-29 at 19:17 +1000, Alistair Leslie-Hughes wrote:
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index e9363208471..b2862ead789 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2918,7 +2918,10 @@ static DWORD set_content_length(http_request_t *request) WCHAR encoding[20]; DWORD size;
- if(request->status_code == HTTP_STATUS_NO_CONTENT || !wcscmp(request->verb, L"HEAD")) {
- if(request->status_code == HTTP_STATUS_NO_CONTENT || request->status_code == HTTP_STATUS_NOT_MODIFIED ||
!wcscmp(request->verb, L"HEAD"))
- {
request->read_size = 0;
request->contentLength = request->netconn_stream.content_length = 0; return ERROR_SUCCESS;
This is still not correct. I've added some tests on top of yours that check these responses, with and without Content-Length header.
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=99068
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/wininet/tests/http.c:2375 Task: Patch failed to apply
=== debiant2 (build log) ===
error: patch failed: dlls/wininet/tests/http.c:2375 Task: Patch failed to apply
=== debiant2 (build log) ===
error: patch failed: dlls/wininet/tests/http.c:2375 Task: Patch failed to apply