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

LWS_ILLEGAL_HTTP_CONTENT_LEN implies connection:close

If no content-length is coming, we just can't do
http/1.1 keep-alive.
This commit is contained in:
Andy Green 2018-06-16 13:23:06 +08:00
parent d84aebd43a
commit 1eb4ac4b41
2 changed files with 12 additions and 4 deletions

View file

@ -1024,7 +1024,7 @@ lws_create_vhost(struct lws_context *context,
return vh;
bail1:
lws_vhost_destroy(vh, NULL, NULL);
lws_vhost_destroy(vh);
return NULL;

View file

@ -149,9 +149,17 @@ lws_add_http_common_headers(struct lws *wsi, unsigned int code,
(int)strlen(content_type), p, end))
return 1;
if (content_len != LWS_ILLEGAL_HTTP_CONTENT_LEN &&
lws_add_http_header_content_length(wsi, content_len, p, end))
return 1;
if (content_len != LWS_ILLEGAL_HTTP_CONTENT_LEN) {
if (lws_add_http_header_content_length(wsi, content_len, p, end))
return 1;
} else {
if (lws_add_http_header_by_token(wsi, WSI_TOKEN_CONNECTION,
(unsigned char *)"close", 5,
p, end))
return 1;
wsi->http.connection_type = HTTP_CONNECTION_CLOSE;
}
return 0;
}