From 78228ed5cb42972da8015fc91190274a727dee0b Mon Sep 17 00:00:00 2001 From: Andrew Canaday Date: Sat, 19 Jul 2014 07:01:10 +0800 Subject: [PATCH] Keep-alive: disable timeout and let TCP ka kill. This is required for streaming HTTP connections. Not sure if there's a more graceful way to handle this (maybe resetting the timeout in the 'send'-side code? --- lib/handshake.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/handshake.c b/lib/handshake.c index 95e518189..421494a25 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -173,9 +173,11 @@ http_complete: lwsl_debug("libwebsocket_read: http_complete\n"); /* Handle keep-alives, by preparing for a new request: */ if (wsi->u.http.connection_type == HTTP_CONNECTION_KEEP_ALIVE) { + lwsl_debug("libwebsocket_read: keep-alive\n"); wsi->state = WSI_STATE_HTTP; wsi->mode = LWS_CONNMODE_HTTP_SERVING; - lwsl_debug("libwebsocket_read: keep-alive\n"); + /* We might be streaming HTTP content, so leave the connection open.*/ + libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0); if (lws_allocate_header_table(wsi)) goto bail;