trace 22 fix zero length close from client
close() from javascript api in Chrome and Firefox doesn't do the right thing. It's because the payload is zero-length (with a frame key...) This fixes it. Reported-by: 巫书轶 Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
897fec3a89
commit
1bc12f9e99
1 changed files with 3 additions and 17 deletions
|
@ -706,26 +706,10 @@ libwebsocket_rx_sm(struct libwebsocket *wsi, unsigned char c)
|
||||||
case LWS_RXPS_04_FRAME_HDR_1:
|
case LWS_RXPS_04_FRAME_HDR_1:
|
||||||
handle_first:
|
handle_first:
|
||||||
|
|
||||||
/*
|
|
||||||
* 04 spec defines the opcode like this: (1, 2, and 3 are
|
|
||||||
* "control frame" opcodes which may not be fragmented or
|
|
||||||
* have size larger than 126)
|
|
||||||
*
|
|
||||||
* frame-opcode =
|
|
||||||
* %x0 ; continuation frame
|
|
||||||
* / %x1 ; connection close
|
|
||||||
* / %x2 ; ping
|
|
||||||
* / %x3 ; pong
|
|
||||||
* / %x4 ; text frame
|
|
||||||
* / %x5 ; binary frame
|
|
||||||
* / %x6-F ; reserved
|
|
||||||
*
|
|
||||||
* FIN (b7)
|
|
||||||
*/
|
|
||||||
|
|
||||||
wsi->u.ws.opcode = c & 0xf;
|
wsi->u.ws.opcode = c & 0xf;
|
||||||
wsi->u.ws.rsv = c & 0x70;
|
wsi->u.ws.rsv = c & 0x70;
|
||||||
wsi->u.ws.final = !!((c >> 7) & 1);
|
wsi->u.ws.final = !!((c >> 7) & 1);
|
||||||
|
|
||||||
switch (wsi->u.ws.opcode) {
|
switch (wsi->u.ws.opcode) {
|
||||||
case LWS_WS_OPCODE_07__TEXT_FRAME:
|
case LWS_WS_OPCODE_07__TEXT_FRAME:
|
||||||
case LWS_WS_OPCODE_07__BINARY_FRAME:
|
case LWS_WS_OPCODE_07__BINARY_FRAME:
|
||||||
|
@ -870,6 +854,8 @@ handle_first:
|
||||||
wsi->lws_rx_parse_state =
|
wsi->lws_rx_parse_state =
|
||||||
LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED;
|
LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED;
|
||||||
wsi->u.ws.frame_mask_index = 0;
|
wsi->u.ws.frame_mask_index = 0;
|
||||||
|
if (wsi->u.ws.rx_packet_length == 0)
|
||||||
|
goto spill;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue