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

ws: client: if server sends no subprotocol prefer any existing protocol

This commit is contained in:
kzhdev 2019-04-04 20:04:25 -05:00 committed by Andy Green
parent c40394f968
commit 0850231a09

View file

@ -305,9 +305,17 @@ bad_conn_format:
if (!len) {
lwsl_info("%s: WSI_TOKEN_PROTOCOL is null\n", __func__);
/*
* no protocol name to work from,
* no protocol name to work from, if we don't already have one
* default to first protocol
*/
if (wsi->protocol) {
p = (char *)wsi->protocol->name;
goto identify_protocol;
}
/* no choice but to use the default protocol */
n = 0;
wsi->protocol = &wsi->vhost->protocols[0];
goto check_extensions;
@ -334,6 +342,8 @@ bad_conn_format:
goto bail2;
}
identify_protocol:
#if defined(LWS_WITH_HTTP_PROXY)
lws_strncpy(wsi->ws->actual_protocol, p,
sizeof(wsi->ws->actual_protocol));