Commit 01c02f60 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

winhttp: Return ERROR_INVALID_OPERATION when websocket is in the wrong state.

parent 917e8dbf
......@@ -3324,7 +3324,7 @@ DWORD WINAPI WinHttpWebSocketSend( HINTERNET hsocket, WINHTTP_WEB_SOCKET_BUFFER_
if (socket->state != SOCKET_STATE_OPEN)
{
release_object( &socket->hdr );
return ERROR_WINHTTP_INCORRECT_HANDLE_STATE;
return ERROR_INVALID_OPERATION;
}
if (socket->request->connect->hdr.flags & WINHTTP_FLAG_ASYNC)
......@@ -3625,7 +3625,7 @@ DWORD WINAPI WinHttpWebSocketReceive( HINTERNET hsocket, void *buf, DWORD len, D
if (socket->state > SOCKET_STATE_SHUTDOWN)
{
release_object( &socket->hdr );
return ERROR_WINHTTP_INCORRECT_HANDLE_STATE;
return ERROR_INVALID_OPERATION;
}
if (socket->request->connect->hdr.flags & WINHTTP_FLAG_ASYNC)
......@@ -3704,7 +3704,7 @@ DWORD WINAPI WinHttpWebSocketShutdown( HINTERNET hsocket, USHORT status, void *r
if (socket->state >= SOCKET_STATE_SHUTDOWN)
{
release_object( &socket->hdr );
return ERROR_WINHTTP_INCORRECT_HANDLE_STATE;
return ERROR_INVALID_OPERATION;
}
if (socket->request->connect->hdr.flags & WINHTTP_FLAG_ASYNC)
......@@ -3814,7 +3814,7 @@ DWORD WINAPI WinHttpWebSocketClose( HINTERNET hsocket, USHORT status, void *reas
if (socket->state >= SOCKET_STATE_CLOSED)
{
release_object( &socket->hdr );
return ERROR_WINHTTP_INCORRECT_HANDLE_STATE;
return ERROR_INVALID_OPERATION;
}
if (socket->request->connect->hdr.flags & WINHTTP_FLAG_ASYNC)
......@@ -3859,7 +3859,7 @@ DWORD WINAPI WinHttpWebSocketQueryCloseStatus( HINTERNET hsocket, USHORT *status
if (socket->state < SOCKET_STATE_CLOSED)
{
release_object( &socket->hdr );
return ERROR_WINHTTP_INCORRECT_HANDLE_STATE;
return ERROR_INVALID_OPERATION;
}
*status = socket->status;
......
......@@ -816,6 +816,12 @@ static void test_websocket(BOOL secure)
ok( err == ERROR_SUCCESS, "got %u\n", err );
WaitForSingleObject( info.wait, INFINITE );
err = pWinHttpWebSocketShutdown( socket, 1000, (void *)"success", sizeof("success") );
ok( err == ERROR_INVALID_OPERATION, "got %u\n", err );
err = pWinHttpWebSocketSend( socket, WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE,
(void*)"hello", sizeof("hello") );
ok( err == ERROR_INVALID_OPERATION, "got %u\n", err );
setup_test( &info, winhttp_websocket_receive, __LINE__ );
buffer[0] = 0;
size = 0xdeadbeef;
......@@ -838,8 +844,15 @@ static void test_websocket(BOOL secure)
ok( type == 0xdeadbeef, "got %u\n", type );
ok( buffer[0] == 'h', "unexpected data\n" );
close_status = 0xdead;
size = sizeof(buffer) + 1;
err = pWinHttpWebSocketQueryCloseStatus( socket, &close_status, buffer, sizeof(buffer), &size );
ok( err == ERROR_INVALID_OPERATION, "got %u\n", err );
ok( close_status == 0xdead, "got %u\n", close_status );
ok( size == sizeof(buffer) + 1, "got %u\n", size );
setup_test( &info, winhttp_websocket_close, __LINE__ );
ret = pWinHttpWebSocketClose( socket, 1000, (void *)"success", sizeof("success") );
err = pWinHttpWebSocketClose( socket, 1000, (void *)"success", sizeof("success") );
ok( err == ERROR_SUCCESS, "got %u\n", err );
WaitForSingleObject( info.wait, INFINITE );
......
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