1
0
Fork 0
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:
Andy Green 2018-10-12 05:05:33 +08:00
parent 7b9e6c70f7
commit db827733c3
3 changed files with 12 additions and 9 deletions

View file

@ -1536,7 +1536,7 @@ lws_buflist_aware_consume(struct lws *wsi, struct lws_tokens *ebuf, int used,
char * 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 int
lws_client_ws_upgrade(struct lws *wsi, const char **cce); lws_client_ws_upgrade(struct lws *wsi, const char **cce);
int int

View file

@ -1067,9 +1067,6 @@ lws_generate_client_handshake(struct lws *wsi, char *pkt)
p += sprintf(p, "Pragma: no-cache\x0d\x0a" p += sprintf(p, "Pragma: no-cache\x0d\x0a"
"Cache-Control: 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", p += sprintf(p, "Host: %s\x0d\x0a",
lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_HOST)); 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)); _WSI_TOKEN_CLIENT_ORIGIN));
} }
#if defined(LWS_ROLE_WS) #if defined(LWS_ROLE_WS)
if (wsi->do_ws) if (wsi->do_ws) {
p = lws_generate_client_ws_handshake(wsi, p); const char *conn1 = "";
if (!wsi->client_pipeline)
conn1 = "close, ";
p = lws_generate_client_ws_handshake(wsi, p, conn1);
} else
#endif #endif
if (!wsi->client_pipeline)
p += sprintf(p, "connection: close\x0d\x0a");
/* give userland a chance to append, eg, cookies */ /* give userland a chance to append, eg, cookies */

View file

@ -114,7 +114,7 @@ lws_ws_handshake_client(struct lws *wsi, unsigned char **buf, size_t len)
#endif #endif
char * 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]; char buf[128], hash[20], key_b64[40];
int n; 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)); lws_b64_encode_string(hash, 16, key_b64, sizeof(key_b64));
p += sprintf(p, "Upgrade: websocket\x0d\x0a" p += sprintf(p, "Upgrade: websocket\x0d\x0a"
"Connection: Upgrade\x0d\x0a" "Connection: %sUpgrade\x0d\x0a"
"Sec-WebSocket-Key: "); "Sec-WebSocket-Key: ", conn1);
strcpy(p, key_b64); strcpy(p, key_b64);
p += strlen(key_b64); p += strlen(key_b64);
p += sprintf(p, "\x0d\x0a"); p += sprintf(p, "\x0d\x0a");