Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winhttp/request.c | 13 ++++++++++--- dlls/winhttp/tests/notification.c | 14 ++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index af04292ea06..f4f81af42da 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -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; diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c index 6b0e11023da..1573dd37faa 100644 --- a/dlls/winhttp/tests/notification.c +++ b/dlls/winhttp/tests/notification.c @@ -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") );