http keepalive needs to reinit some header union state
authorCarl Stehle <droid@appception.com>
Sat, 16 Aug 2014 02:17:59 +0000 (10:17 +0800)
committerAndy Green <andy.green@linaro.org>
Sat, 16 Aug 2014 02:17:59 +0000 (10:17 +0800)
AG moved the code to the keepalive loop location

lib/handshake.c

index b1c7d99..d81c1d2 100644 (file)
@@ -173,17 +173,23 @@ read_ok:
 
 http_complete:
        lwsl_debug("libwebsocket_read: http_complete\n");
-       /* Handle keep-alives, by preparing for a new request: */
+
+       /* Did the client want to keep the HTTP connection going? */
+
        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;
-               /* We might be streaming HTTP content, so leave the connection open.*/
+
+               /* 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;