keepalive fix flow now forced closed removed
Since 0d89f3cbed
added recently,
http1.1 keepalive tries to actually keep alive.
Some updates are needed to keepalive flow to solve problems coming from
changes that were hidden until now by keepalive basically closing until
recently. It's not very noticable since clients will retry as close is
the default 1.0 behaviour... anyway this lets me do
wget http://localhost:7681/test.html http://localhost:7681/test.html
using keepalive correctly on the test server.
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
d256194a0c
commit
2627148523
2 changed files with 18 additions and 20 deletions
|
@ -200,27 +200,14 @@ http_complete:
|
|||
lwsl_debug("libwebsocket_read: http_complete\n");
|
||||
|
||||
/* Did the client want to keep the HTTP connection going? */
|
||||
if (lws_http_transaction_completed(wsi))
|
||||
goto bail;
|
||||
|
||||
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;
|
||||
/* If we have more data, loop back around: */
|
||||
if (len)
|
||||
goto http_new;
|
||||
|
||||
/* He asked for it to stay alive indefinitely */
|
||||
libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
|
||||
|
||||
if (lws_allocate_header_table(wsi))
|
||||
goto bail;
|
||||
|
||||
/* If we're (re)starting on headers, need other implied init */
|
||||
wsi->u.hdr.ues = URIES_IDLE;
|
||||
|
||||
/* If we have more data, loop back around: */
|
||||
if (len)
|
||||
goto http_new;
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
||||
bail:
|
||||
lwsl_debug("closing connection at libwebsocket_read bail:\n");
|
||||
|
|
13
lib/server.c
13
lib/server.c
|
@ -649,8 +649,19 @@ int lws_http_transaction_completed(struct libwebsocket *wsi)
|
|||
|
||||
/* otherwise set ourselves up ready to go again */
|
||||
wsi->state = WSI_STATE_HTTP;
|
||||
wsi->mode = LWS_CONNMODE_HTTP_SERVING;
|
||||
wsi->u.http.content_length = 0;
|
||||
|
||||
/* He asked for it to stay alive indefinitely */
|
||||
libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
|
||||
|
||||
if (lws_allocate_header_table(wsi))
|
||||
return 1;
|
||||
|
||||
/* If we're (re)starting on headers, need other implied init */
|
||||
wsi->u.hdr.ues = URIES_IDLE;
|
||||
|
||||
lwsl_info("%s: await new transaction\n", __func__);
|
||||
lwsl_info("%s: keep-alive await new transaction\n", __func__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue