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

winhttp: Pass server initiated websocket close request to application.

parent 85747f0a
...@@ -3591,6 +3591,8 @@ static DWORD receive_close_status( struct socket *socket, unsigned int len ) ...@@ -3591,6 +3591,8 @@ static DWORD receive_close_status( struct socket *socket, unsigned int len )
static DWORD handle_control_frame( struct socket *socket ) static DWORD handle_control_frame( struct socket *socket )
{ {
DWORD ret;
TRACE( "opcode %u.\n", socket->opcode ); TRACE( "opcode %u.\n", socket->opcode );
switch (socket->opcode) switch (socket->opcode)
...@@ -3602,7 +3604,7 @@ static DWORD handle_control_frame( struct socket *socket ) ...@@ -3602,7 +3604,7 @@ static DWORD handle_control_frame( struct socket *socket )
return socket_drain( socket ); return socket_drain( socket );
case SOCKET_OPCODE_CLOSE: case SOCKET_OPCODE_CLOSE:
if (socket->state != SOCKET_STATE_CLOSED) if (socket->state < SOCKET_STATE_SHUTDOWN)
WARN( "SOCKET_OPCODE_CLOSE received, socket->state %u.\n", socket->state ); WARN( "SOCKET_OPCODE_CLOSE received, socket->state %u.\n", socket->state );
if (socket->close_frame_received) if (socket->close_frame_received)
{ {
...@@ -3610,9 +3612,9 @@ static DWORD handle_control_frame( struct socket *socket ) ...@@ -3610,9 +3612,9 @@ static DWORD handle_control_frame( struct socket *socket )
return ERROR_WINHTTP_INVALID_SERVER_RESPONSE; return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
} }
receive_close_status( socket, socket->read_size ); ret = receive_close_status( socket, socket->read_size );
socket->read_size = 0; socket->read_size = 0;
return ERROR_WINHTTP_INVALID_SERVER_RESPONSE; return ret;
default: default:
ERR("unhandled control opcode %02x\n", socket->opcode); ERR("unhandled control opcode %02x\n", socket->opcode);
...@@ -3654,7 +3656,8 @@ static DWORD socket_receive( struct socket *socket, void *buf, DWORD len, DWORD ...@@ -3654,7 +3656,8 @@ static DWORD socket_receive( struct socket *socket, void *buf, DWORD len, DWORD
{ {
if (!(ret = receive_frame( socket, &socket->read_size, &socket->opcode ))) if (!(ret = receive_frame( socket, &socket->read_size, &socket->opcode )))
{ {
if (!(socket->opcode & CONTROL_BIT) || (ret = handle_control_frame( socket ))) break; if (!(socket->opcode & CONTROL_BIT) || (ret = handle_control_frame( socket ))
|| socket->opcode == SOCKET_OPCODE_CLOSE) break;
} }
else if (ret == WSAETIMEDOUT) ret = socket_send_pong( socket ); else if (ret == WSAETIMEDOUT) ret = socket_send_pong( socket );
if (ret) break; if (ret) break;
......
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