Commit f738af16 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

winhttp: Read any data left in the request buffer for websocket connections.

Fixes the case where a websocket server sends an unsolicited frame with the upgrade response. Signed-off-by: 's avatarHans Leidekker <hans@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 54742a90
......@@ -3309,9 +3309,20 @@ DWORD WINAPI WinHttpWebSocketSend( HINTERNET hsocket, WINHTTP_WEB_SOCKET_BUFFER_
static DWORD receive_bytes( struct socket *socket, char *buf, DWORD len, DWORD *ret_len )
{
DWORD err;
if ((err = netconn_recv( socket->request->netconn, buf, len, 0, (int *)ret_len ))) return err;
if (*ret_len != len) return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
DWORD err, size = 0, needed = len;
char *ptr = buf;
int received;
if (socket->request->read_size)
{
size = min( needed, socket->request->read_size );
memcpy( ptr, socket->request->read_buf + socket->request->read_pos, size );
remove_data( socket->request, size );
needed -= size;
ptr += size;
}
if ((err = netconn_recv( socket->request->netconn, ptr, needed, 0, &received ))) return err;
if ((*ret_len = size + received) != len) return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
return ERROR_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