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

Subject: [PATCH] fixes for handling multiple protocols in handshake

This commit is contained in:
Rene Jager 2014-10-28 23:27:20 +01:00 committed by Andy Green
parent bbbf07a834
commit c0eb2c3e9d
3 changed files with 9 additions and 10 deletions

View file

@ -565,12 +565,12 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context,
}
while (*pc && *pc != ',')
pc++;
while (*pc && *pc != ' ')
while (*pc && *pc == ' ')
pc++;
}
if (!okay) {
lwsl_err("lws_client_int_s_hs: got bad protocol %s\n", p);
lwsl_err("lws_client_int_s_hs: got bad protocol '%s'\n", p);
goto bail2;
}
@ -588,7 +588,7 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context,
}
if (wsi->protocol == NULL) {
lwsl_err("lws_client_int_s_hs: fail protocol %s\n", p);
lwsl_err("lws_client_int_s_hs: fail protocol '%s'\n", p);
goto bail2;
}

View file

@ -217,10 +217,7 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
if (lws_hdr_total_length(wsi, WSI_TOKEN_PROTOCOL)) {
LWS_CPYAPP(p, "\x0d\x0aSec-WebSocket-Protocol: ");
n = lws_hdr_copy(wsi, p, 128, WSI_TOKEN_PROTOCOL);
if (n < 0)
goto bail;
p += n;
LWS_CPYAPP(p, wsi->protocol->name);
}
#ifndef LWS_NO_EXTENSIONS

View file

@ -428,9 +428,9 @@ upgrade_h2c:
"HTTP/1.1 101 Switching Protocols\x0d\x0a"
"Connection: Upgrade\x0d\x0a"
"Upgrade: h2c\x0d\x0a\x0d\x0a");
n = lws_issue_raw(wsi, (unsigned char *)protocol_list,
strlen(protocol_list));
if (n != strlen(protocol_list)) {
n = lws_issue_raw(wsi, (unsigned char *)wsi->protocol->name,
strlen(wsi->protocol->name));
if (n != strlen(wsi->protocol->name)) {
lwsl_debug("http2 switch: ERROR writing to socket\n");
return 1;
}
@ -471,6 +471,8 @@ upgrade_ws:
protocol_name[n] = '\0';
if (*p)
p++;
while (*p == ' ')
p++;
lwsl_info("checking %s\n", protocol_name);