|
@@ -7280,24 +7280,16 @@ static int send_websocket_handshake(struct mg_connection *conn)
|
|
SHA1Final((unsigned char *)sha, &sha_ctx);
|
|
SHA1Final((unsigned char *)sha, &sha_ctx);
|
|
base64_encode((unsigned char *)sha, sizeof(sha), b64_sha);
|
|
base64_encode((unsigned char *)sha, sizeof(sha), b64_sha);
|
|
mg_printf(conn,
|
|
mg_printf(conn,
|
|
- "%s%s%s",
|
|
|
|
"HTTP/1.1 101 Switching Protocols\r\n"
|
|
"HTTP/1.1 101 Switching Protocols\r\n"
|
|
"Upgrade: websocket\r\n"
|
|
"Upgrade: websocket\r\n"
|
|
"Connection: Upgrade\r\n"
|
|
"Connection: Upgrade\r\n"
|
|
- "Sec-WebSocket-Accept: ",
|
|
|
|
- b64_sha,
|
|
|
|
- "\r\n");
|
|
|
|
|
|
+ "Sec-WebSocket-Accept: %s\r\n",
|
|
|
|
+ b64_sha);
|
|
protocol = mg_get_header(conn, "Sec-WebSocket-Protocol");
|
|
protocol = mg_get_header(conn, "Sec-WebSocket-Protocol");
|
|
if (protocol) {
|
|
if (protocol) {
|
|
- mg_printf(conn,
|
|
|
|
- "%s%s%s",
|
|
|
|
- "Sec-WebSocket-Protocol:",
|
|
|
|
- protocol,
|
|
|
|
- "\r\n\r\n");
|
|
|
|
|
|
+ mg_printf(conn, "Sec-WebSocket-Protocol: %s\r\n\r\n", protocol);
|
|
} else {
|
|
} else {
|
|
- mg_printf(conn,
|
|
|
|
- "%s",
|
|
|
|
- "\r\n");
|
|
|
|
|
|
+ mg_printf(conn, "%s", "\r\n");
|
|
}
|
|
}
|
|
|
|
|
|
return 1;
|
|
return 1;
|