Skip to content

Commit

Permalink
winhttp: Do not cache connection if suggested by request headers.
Browse files Browse the repository at this point in the history
(cherry picked from commit ff97d39)

CW-Bug-Id: #23656
  • Loading branch information
Paul Gofman authored and ivyl committed May 23, 2024
1 parent 3a8f5bd commit eb55f0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 9 additions & 11 deletions dlls/winhttp/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@ static DWORD refill_buffer( struct request *request, BOOL notify )

static void finished_reading( struct request *request )
{
BOOL close = FALSE, notify;
BOOL close = FALSE, close_request_headers;
WCHAR connection[20];
DWORD size = sizeof(connection);

Expand All @@ -1937,18 +1937,16 @@ static void finished_reading( struct request *request )
}
else if (!wcscmp( request->version, L"HTTP/1.0" )) close = TRUE;

if (close)
size = sizeof(connection);
close_request_headers =
(!query_headers( request, WINHTTP_QUERY_CONNECTION | WINHTTP_QUERY_FLAG_REQUEST_HEADERS, NULL, connection, &size, NULL )
|| !query_headers( request, WINHTTP_QUERY_PROXY_CONNECTION | WINHTTP_QUERY_FLAG_REQUEST_HEADERS, NULL, connection, &size, NULL ))
&& !wcsicmp( connection, L"close" );
if (close || close_request_headers)
{
size = sizeof(connection);
notify = (!query_headers( request, WINHTTP_QUERY_CONNECTION | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
NULL, connection, &size, NULL )
|| !query_headers( request, WINHTTP_QUERY_PROXY_CONNECTION | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
NULL, connection, &size, NULL ))
&& !wcsicmp( connection, L"close" );

if (notify) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, 0, 0 );
if (close_request_headers) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, 0, 0 );
netconn_release( request->netconn );
if (notify) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, 0, 0 );
if (close_request_headers) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, 0, 0 );
}
else
cache_connection( request->netconn );
Expand Down
2 changes: 1 addition & 1 deletion dlls/winhttp/tests/winhttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2580,7 +2580,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
ok(!!strstr(buffer, "GET /cached"), "request not found.\n");
send(c, okmsg_length0, sizeof okmsg_length0 - 1, 0);
r = server_receive_request(c, buffer, sizeof(buffer));
todo_wine ok(!r, "got %d, buffer[0] %d.\n", r, buffer[0]);
ok(!r, "got %d, buffer[0] %d.\n", r, buffer[0]);
}
if (strstr(buffer, "GET /notcached"))
{
Expand Down

0 comments on commit eb55f0b

Please sign in to comment.