wininet: Reset context length for http status 304.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 8825ed72d7
)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
parent
3bf9bae9bf
commit
a6af1e31dd
|
@ -2918,7 +2918,12 @@ 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"))
|
||||
{
|
||||
if (HTTP_GetCustomHeaderIndex(request, L"Content-Length", 0, FALSE) == -1 ||
|
||||
!wcscmp(request->verb, L"HEAD"))
|
||||
request->read_size = 0;
|
||||
request->contentLength = request->netconn_stream.content_length = 0;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -2399,12 +2399,41 @@ static DWORD CALLBACK server_thread(LPVOID param)
|
|||
recvfrom(c, buffer, buffer_size, 0, NULL, NULL);
|
||||
send(c, ok_with_length, sizeof(ok_with_length)-1, 0);
|
||||
}
|
||||
|
||||
if (strstr(buffer, "GET /test_no_content_content_length"))
|
||||
{
|
||||
static const char nocontentmsg[] = "HTTP/1.1 204 No Content\r\nConnection: close\r\n"
|
||||
"Content-Length: 10\r\n\r\n0123456789";
|
||||
send(c, nocontentmsg, sizeof(nocontentmsg)-1, 0);
|
||||
}
|
||||
if (strstr(buffer, "GET /test_no_content"))
|
||||
{
|
||||
static const char nocontentmsg[] = "HTTP/1.1 204 No Content\r\nConnection: close\r\n\r\n";
|
||||
static const char nocontentmsg[] = "HTTP/1.1 204 No Content\r\nConnection: close\r\n\r\n"
|
||||
"0123456789";
|
||||
send(c, nocontentmsg, sizeof(nocontentmsg)-1, 0);
|
||||
}
|
||||
if (strstr(buffer, "GET /test_not_modified_content_length"))
|
||||
{
|
||||
static const char notmodifiedmsg[] = "HTTP/1.1 304 Not Modified\r\nConnection: close\r\n"
|
||||
"Content-Length: 10\r\n\r\n0123456789";
|
||||
send(c, notmodifiedmsg, sizeof(notmodifiedmsg)-1, 0);
|
||||
}
|
||||
else if (strstr(buffer, "GET /test_not_modified"))
|
||||
{
|
||||
static const char notmodifiedmsg[] = "HTTP/1.1 304 Not Modified\r\nConnection: close\r\n"
|
||||
"\r\n0123456789";
|
||||
send(c, notmodifiedmsg, sizeof(notmodifiedmsg)-1, 0);
|
||||
}
|
||||
if (strstr(buffer, "HEAD /head_content_length"))
|
||||
{
|
||||
static const char headmsg[] = "HTTP/1.1 200 OK\r\nConnection: close\r\n"
|
||||
"Content-Length: 10\r\n\r\n0123456789";
|
||||
send(c, headmsg, sizeof(headmsg)-1, 0);
|
||||
}
|
||||
else if (strstr(buffer, "HEAD /head"))
|
||||
{
|
||||
static const char headmsg[] = "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n0123456789";
|
||||
send(c, headmsg, sizeof(headmsg)-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";
|
||||
|
@ -3511,6 +3540,106 @@ 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 = 0xdeadbeef;
|
||||
ret = InternetQueryDataAvailable(req, &avail, 0, 0);
|
||||
ok(ret, "InternetQueryDataAvailable failed: %u\n", GetLastError());
|
||||
ok(!avail, "got %d\n", avail);
|
||||
InternetCloseHandle(req);
|
||||
|
||||
req = HttpOpenRequestA(con, NULL, "/test_not_modified_content_length", 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 = 0xdeadbeef;
|
||||
ret = InternetQueryDataAvailable(req, &avail, 0, 0);
|
||||
ok(ret, "InternetQueryDataAvailable failed: %u\n", GetLastError());
|
||||
ok(avail == 10, "got %d\n", avail);
|
||||
InternetCloseHandle(req);
|
||||
|
||||
req = HttpOpenRequestA(con, NULL, "/test_no_content", 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, 204);
|
||||
|
||||
avail = 0xdeadbeef;
|
||||
ret = InternetQueryDataAvailable(req, &avail, 0, 0);
|
||||
ok(ret, "InternetQueryDataAvailable failed: %u\n", GetLastError());
|
||||
ok(!avail, "got %d\n", avail);
|
||||
InternetCloseHandle(req);
|
||||
|
||||
req = HttpOpenRequestA(con, NULL, "/test_no_content_content_length", 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, 204);
|
||||
|
||||
avail = 0xdeadbeef;
|
||||
ret = InternetQueryDataAvailable(req, &avail, 0, 0);
|
||||
ok(ret, "InternetQueryDataAvailable failed: %u\n", GetLastError());
|
||||
ok(avail == 10, "got %d\n", avail);
|
||||
InternetCloseHandle(req);
|
||||
|
||||
req = HttpOpenRequestA(con, "HEAD", "/head", 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, 200);
|
||||
|
||||
avail = 0xdeadbeef;
|
||||
ret = InternetQueryDataAvailable(req, &avail, 0, 0);
|
||||
ok(ret, "InternetQueryDataAvailable failed: %u\n", GetLastError());
|
||||
ok(!avail, "got %d\n", avail);
|
||||
InternetCloseHandle(req);
|
||||
|
||||
req = HttpOpenRequestA(con, "HEAD", "/head_content_length", 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, 200);
|
||||
|
||||
avail = 0xdeadbeef;
|
||||
ret = InternetQueryDataAvailable(req, &avail, 0, 0);
|
||||
ok(ret, "InternetQueryDataAvailable failed: %u\n", GetLastError());
|
||||
ok(!avail, "got %d\n", avail);
|
||||
|
||||
InternetCloseHandle(req);
|
||||
InternetCloseHandle(con);
|
||||
InternetCloseHandle(ses);
|
||||
}
|
||||
|
||||
static void test_conn_close(int port)
|
||||
{
|
||||
HINTERNET session, connection, req;
|
||||
|
@ -6084,6 +6213,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);
|
||||
|
|
Loading…
Reference in New Issue