mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
h1 ws client: produce CONNECTION
This commit is contained in:
parent
7b9e6c70f7
commit
db827733c3
3 changed files with 12 additions and 9 deletions
|
@ -1536,7 +1536,7 @@ lws_buflist_aware_consume(struct lws *wsi, struct lws_tokens *ebuf, int used,
|
|||
|
||||
|
||||
char *
|
||||
lws_generate_client_ws_handshake(struct lws *wsi, char *p);
|
||||
lws_generate_client_ws_handshake(struct lws *wsi, char *p, const char *conn1);
|
||||
int
|
||||
lws_client_ws_upgrade(struct lws *wsi, const char **cce);
|
||||
int
|
||||
|
|
|
@ -1067,9 +1067,6 @@ lws_generate_client_handshake(struct lws *wsi, char *pkt)
|
|||
p += sprintf(p, "Pragma: no-cache\x0d\x0a"
|
||||
"Cache-Control: no-cache\x0d\x0a");
|
||||
|
||||
if (!wsi->client_pipeline)
|
||||
p += sprintf(p, "connection: close\x0d\x0a");
|
||||
|
||||
p += sprintf(p, "Host: %s\x0d\x0a",
|
||||
lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_HOST));
|
||||
|
||||
|
@ -1085,9 +1082,15 @@ lws_generate_client_handshake(struct lws *wsi, char *pkt)
|
|||
_WSI_TOKEN_CLIENT_ORIGIN));
|
||||
}
|
||||
#if defined(LWS_ROLE_WS)
|
||||
if (wsi->do_ws)
|
||||
p = lws_generate_client_ws_handshake(wsi, p);
|
||||
if (wsi->do_ws) {
|
||||
const char *conn1 = "";
|
||||
if (!wsi->client_pipeline)
|
||||
conn1 = "close, ";
|
||||
p = lws_generate_client_ws_handshake(wsi, p, conn1);
|
||||
} else
|
||||
#endif
|
||||
if (!wsi->client_pipeline)
|
||||
p += sprintf(p, "connection: close\x0d\x0a");
|
||||
|
||||
/* give userland a chance to append, eg, cookies */
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ lws_ws_handshake_client(struct lws *wsi, unsigned char **buf, size_t len)
|
|||
#endif
|
||||
|
||||
char *
|
||||
lws_generate_client_ws_handshake(struct lws *wsi, char *p)
|
||||
lws_generate_client_ws_handshake(struct lws *wsi, char *p, const char *conn1)
|
||||
{
|
||||
char buf[128], hash[20], key_b64[40];
|
||||
int n;
|
||||
|
@ -136,8 +136,8 @@ lws_generate_client_ws_handshake(struct lws *wsi, char *p)
|
|||
lws_b64_encode_string(hash, 16, key_b64, sizeof(key_b64));
|
||||
|
||||
p += sprintf(p, "Upgrade: websocket\x0d\x0a"
|
||||
"Connection: Upgrade\x0d\x0a"
|
||||
"Sec-WebSocket-Key: ");
|
||||
"Connection: %sUpgrade\x0d\x0a"
|
||||
"Sec-WebSocket-Key: ", conn1);
|
||||
strcpy(p, key_b64);
|
||||
p += strlen(key_b64);
|
||||
p += sprintf(p, "\x0d\x0a");
|
||||
|
|
Loading…
Add table
Reference in a new issue