1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

Check status before checking for Sec-WebSocket-Accept

If the server rejects the attempt to establish a connection by returning
a response status other than 101, then it will not include the
Sec-WebSocket-Accept header. We need to check for 101 status (and return
an appropriate error message) before looking for the accept header.

See #1200
This commit is contained in:
Joe Littlejohn 2018-03-07 20:23:46 +08:00 committed by Andy Green
parent 3e3c270f76
commit fad43ff8e9

View file

@ -728,12 +728,6 @@ lws_client_interpret_server_handshake(struct lws *wsi)
return 0;
}
if (lws_hdr_total_length(wsi, WSI_TOKEN_ACCEPT) == 0) {
lwsl_info("no ACCEPT\n");
cce = "HS: ACCEPT missing";
goto bail3;
}
if (p && strncmp(p, "101", 3)) {
lwsl_warn(
"lws_client_handshake: got bad HTTP response '%s'\n", p);
@ -741,6 +735,12 @@ lws_client_interpret_server_handshake(struct lws *wsi)
goto bail3;
}
if (lws_hdr_total_length(wsi, WSI_TOKEN_ACCEPT) == 0) {
lwsl_info("no ACCEPT\n");
cce = "HS: ACCEPT missing";
goto bail3;
}
p = lws_hdr_simple_ptr(wsi, WSI_TOKEN_UPGRADE);
if (!p) {
lwsl_info("no UPGRADE\n");