Don't require Sec-WebSocket-Protocol header.
RFC 6455 11.3.4 says this header MAY be used, so allow connections without it.
This commit is contained in:
parent
17175afd73
commit
73e0c62b4c
|
|
@ -475,12 +475,17 @@ int parse_handshake(ws_ctx_t *ws_ctx, char *handshake) {
|
|||
strncpy(headers->connection, start, end-start);
|
||||
headers->connection[end-start] = '\0';
|
||||
|
||||
//RFC 6455 11.3.4 - Sec-WebSocket-Protocol MAY appear multiple times
|
||||
//in a request. Or it may not appear at all.
|
||||
start = strstr(handshake, "\r\nSec-WebSocket-Protocol: ");
|
||||
if (!start) { return 0; }
|
||||
start += 26;
|
||||
end = strstr(start, "\r\n");
|
||||
strncpy(headers->protocols, start, end-start);
|
||||
headers->protocols[end-start] = '\0';
|
||||
if (start) {
|
||||
start += 26;
|
||||
end = strstr(start, "\r\n");
|
||||
strncpy(headers->protocols, start, end-start);
|
||||
headers->protocols[end-start] = '\0';
|
||||
} else {
|
||||
headers->protocols[0] = '\0';
|
||||
}
|
||||
} else {
|
||||
// Hixie 75 or 76
|
||||
ws_ctx->hybi = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue