}
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;
}
}
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;
}
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
"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;
}
protocol_name[n] = '\0';
if (*p)
p++;
+ while (*p == ' ')
+ p++;
lwsl_info("checking %s\n", protocol_name);