winhttp: Don't send notifications when connection is closed on read finish.

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2021-10-15 16:59:48 +03:00 committed by Alexandre Julliard
parent 228c3bdfec
commit d349013dde
2 changed files with 12 additions and 30 deletions

View File

@ -1797,13 +1797,11 @@ static void finished_reading( struct request *request )
if (!wcsicmp( connection, L"close" )) close = TRUE;
}
else if (!wcscmp( request->version, L"HTTP/1.0" )) close = TRUE;
if (close)
{
close_connection( request );
return;
}
cache_connection( request->netconn );
if (close)
netconn_close( request->netconn );
else
cache_connection( request->netconn );
request->netconn = NULL;
}

View File

@ -1124,32 +1124,15 @@ static const struct notification read_test[] =
{ winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL }
};
static const struct notification read_allow_close_test[] =
{
{ winhttp_read_data, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, NF_ALLOW },
{ winhttp_read_data, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, NF_ALLOW },
{ winhttp_read_data, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_ALLOW },
{ winhttp_read_data, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_ALLOW },
{ winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL }
};
#define read_request_data(a,b,c,d) _read_request_data(a,b,c,d,__LINE__)
static void _read_request_data(struct test_request *req, struct info *info, const char *expected_data, BOOL closing_connection, unsigned line)
#define read_request_data(a,b,c) _read_request_data(a,b,c,__LINE__)
static void _read_request_data(struct test_request *req, struct info *info, const char *expected_data, unsigned line)
{
char buffer[1024];
DWORD len;
BOOL ret;
if (closing_connection)
{
info->test = read_allow_close_test;
info->count = ARRAY_SIZE( read_allow_close_test );
}
else
{
info->test = read_test;
info->count = ARRAY_SIZE( read_test );
}
info->test = read_test;
info->count = ARRAY_SIZE( read_test );
info->index = 0;
setup_test( info, winhttp_read_data, line );
@ -1180,7 +1163,7 @@ static void test_persistent_connection(int port)
"Content-Length: 1\r\n"
"\r\n"
"X" );
read_request_data( &req, &info, "X", FALSE );
read_request_data( &req, &info, "X" );
close_request( &req, &info, FALSE );
/* chunked connection test */
@ -1194,7 +1177,7 @@ static void test_persistent_connection(int port)
"\r\n"
"9\r\n123456789\r\n"
"0\r\n\r\n" );
read_request_data( &req, &info, "123456789", FALSE );
read_request_data( &req, &info, "123456789" );
close_request( &req, &info, FALSE );
/* HTTP/1.1 connections are persistent by default, no additional header is needed */
@ -1206,7 +1189,7 @@ static void test_persistent_connection(int port)
"Content-Length: 2\r\n"
"\r\n"
"xx" );
read_request_data( &req, &info, "xx", FALSE );
read_request_data( &req, &info, "xx" );
close_request( &req, &info, FALSE );
open_async_request( port, &req, &info, L"/test", TRUE );
@ -1218,6 +1201,7 @@ static void test_persistent_connection(int port)
"Connection: close\r\n"
"\r\n"
"yy" );
read_request_data( &req, &info, "yy" );
close_request( &req, &info, TRUE );
SetEvent( server_socket_done );