commit e4d87b72a0334579c096c3cc22bf0514d24dd9f9
parent 6bfba49ba57b07e30490a55995095a8fc624665e
Author: Joris Vink <joris@coders.se>
Date: Mon, 30 Jan 2017 21:52:22 +0100
websocket improvements.
- properly send a CLOSE control frame back if the client sent us one.
- make sure we can send messages that are exactly USHRT_MAX bytes long.
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/websocket.c b/src/websocket.c
@@ -180,7 +180,7 @@ websocket_frame_build(struct kore_buf *frame, u_int8_t op, const void *data,
u_int64_t len64;
if (len > WEBSOCKET_PAYLOAD_SINGLE) {
- if (len < USHRT_MAX)
+ if (len <= USHRT_MAX)
len_1 = WEBSOCKET_PAYLOAD_EXTEND_1;
else
len_1 = WEBSOCKET_PAYLOAD_EXTEND_2;
@@ -328,6 +328,7 @@ websocket_recv_frame(struct netbuf *nb)
}
break;
case WEBSOCKET_OP_CLOSE:
+ kore_websocket_send(c, WEBSOCKET_OP_CLOSE, NULL, 0);
kore_connection_disconnect(c);
break;
case WEBSOCKET_OP_PING: