Commit d6083181 authored by Robert Lubos's avatar Robert Lubos Committed by Benjamin Cabé
Browse files

net: websocket: Make use of any leftover data after HTTP processing



In case HTTP client read out more data from a socket that it processed
it will indicate there is leftover data in the receive buffer available.
Make use of it at the websocket level, so that no data is lost. As we
reuse the same receive buffer in this case, it's only needed to update
the count variable to indicate how many bytes are available.

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent 4a85e470
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -384,10 +384,11 @@ int websocket_connect(int sock, struct websocket_request *wreq,

	NET_DBG("[%p] WS connection to peer established (fd %d)", ctx, fd);

	/* We will re-use the temp buffer in receive function if needed but
	 * in order that to work the amount of data in buffer must be set to 0
	/* We will re-use the temp buffer in receive function. If there were
	 * any leftover data from HTTP headers processing, we need to reflect
	 * this in the count variable.
	 */
	ctx->recv_buf.count = 0;
	ctx->recv_buf.count = req.data_len;

	/* Init parser FSM */
	ctx->parser_state = WEBSOCKET_PARSER_STATE_OPCODE;