winhttp: Drain frames until close frame in socket_close().
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:
parent
ea60e4678c
commit
c892634244
|
@ -3686,9 +3686,16 @@ static DWORD socket_close( struct socket *socket, USHORT status, const void *rea
|
||||||
socket->state = SOCKET_STATE_SHUTDOWN;
|
socket->state = SOCKET_STATE_SHUTDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = receive_frame( socket, &count, &socket->opcode ))) goto done;
|
while (1)
|
||||||
if (socket->opcode != SOCKET_OPCODE_CLOSE ||
|
{
|
||||||
(count && (count < sizeof(socket->status) || count > sizeof(socket->status) + sizeof(socket->reason))))
|
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;
|
ret = ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
@ -659,6 +659,7 @@ static const struct notification websocket_test[] =
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, NF_SIGNAL },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, NF_SIGNAL },
|
||||||
{ winhttp_websocket_complete_upgrade, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 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_send, WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE, NF_SIGNAL },
|
||||||
{ winhttp_websocket_shutdown, WINHTTP_CALLBACK_STATUS_SHUTDOWN_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 },
|
||||||
{ 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];
|
char buffer[1024];
|
||||||
USHORT close_status;
|
USHORT close_status;
|
||||||
DWORD protocols, flags;
|
DWORD protocols, flags;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
if (!pWinHttpWebSocketCompleteUpgrade)
|
if (!pWinHttpWebSocketCompleteUpgrade)
|
||||||
{
|
{
|
||||||
|
@ -788,10 +790,14 @@ static void test_websocket(BOOL secure)
|
||||||
ok( err == ERROR_SUCCESS, "got %u\n", err );
|
ok( err == ERROR_SUCCESS, "got %u\n", err );
|
||||||
WaitForSingleObject( info.wait, INFINITE );
|
WaitForSingleObject( info.wait, INFINITE );
|
||||||
|
|
||||||
setup_test( &info, winhttp_websocket_send, __LINE__ );
|
for (i = 0; i < 2; ++i)
|
||||||
err = pWinHttpWebSocketSend( socket, 0, (void *)"hello", sizeof("hello") );
|
{
|
||||||
ok( err == ERROR_SUCCESS, "got %u\n", err );
|
setup_test( &info, winhttp_websocket_send, __LINE__ );
|
||||||
WaitForSingleObject( info.wait, INFINITE );
|
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__ );
|
setup_test( &info, winhttp_websocket_shutdown, __LINE__ );
|
||||||
err = pWinHttpWebSocketShutdown( socket, 1000, (void *)"success", sizeof("success") );
|
err = pWinHttpWebSocketShutdown( socket, 1000, (void *)"success", sizeof("success") );
|
||||||
|
|
Loading…
Reference in New Issue