On Mon, 2021-09-27 at 22:48 +1000, Alistair Leslie-Hughes wrote: 'Reset context length for http status 304' would be a better subject.
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index e9363208471..4bfd93aa3be 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2918,7 +2918,9 @@ 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->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..d32f01be2c5 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -2381,6 +2381,11 @@ 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"; + send(c, notmodifiedmsg, sizeof(notmodifiedmsg)-1, 0); + }
This test also succeeds without resetting content length. To show that the patch is correct you should add a non-zero content length header and call InternetQueryDataAvailable.