Commit c8926342 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

winhttp: Drain frames until close frame in socket_close().

parent ea60e467
......@@ -3686,9 +3686,16 @@ static DWORD socket_close( struct socket *socket, USHORT status, const void *rea
socket->state = SOCKET_STATE_SHUTDOWN;
}
if ((ret = receive_frame( socket, &count, &socket->opcode ))) goto done;
if (socket->opcode != SOCKET_OPCODE_CLOSE ||
(count && (count < sizeof(socket->status) || count > sizeof(socket->status) + sizeof(socket->reason))))
while (1)
{
if ((ret = receive_frame( socket, &count, &socket->opcode ))) goto done;
if (socket->opcode == SOCKET_OPCODE_CLOSE) break;
socket->read_size = count;
if ((ret = socket_drain( socket ))) goto done;
}
if ((count && (count < sizeof(socket->status) || count > sizeof(socket->status) + sizeof(socket->reason))))
{
ret = ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
goto done;
......
......@@ -659,6 +659,7 @@ static const struct notification websocket_test[] =
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, NF_SIGNAL },
{ winhttp_websocket_complete_upgrade, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, NF_SIGNAL },
{ winhttp_websocket_send, WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE, NF_SIGNAL },
{ winhttp_websocket_send, WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE, NF_SIGNAL },
{ winhttp_websocket_shutdown, WINHTTP_CALLBACK_STATUS_SHUTDOWN_COMPLETE, NF_SIGNAL },
{ winhttp_websocket_receive, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL },
{ winhttp_websocket_receive, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL },
......@@ -681,6 +682,7 @@ static void test_websocket(BOOL secure)
char buffer[1024];
USHORT close_status;
DWORD protocols, flags;
unsigned int i;
if (!pWinHttpWebSocketCompleteUpgrade)
{
......@@ -788,10 +790,14 @@ static void test_websocket(BOOL secure)
ok( err == ERROR_SUCCESS, "got %u\n", err );
WaitForSingleObject( info.wait, INFINITE );
setup_test( &info, winhttp_websocket_send, __LINE__ );
err = pWinHttpWebSocketSend( socket, 0, (void *)"hello", sizeof("hello") );
ok( err == ERROR_SUCCESS, "got %u\n", err );
WaitForSingleObject( info.wait, INFINITE );
for (i = 0; i < 2; ++i)
{
setup_test( &info, winhttp_websocket_send, __LINE__ );
err = pWinHttpWebSocketSend( socket, WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE,
(void*)"hello", sizeof("hello") );
ok( err == ERROR_SUCCESS, "got %u\n", err );
WaitForSingleObject( info.wait, INFINITE );
}
setup_test( &info, winhttp_websocket_shutdown, __LINE__ );
err = pWinHttpWebSocketShutdown( socket, 1000, (void *)"success", sizeof("success") );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment