Reset hdr_parsing_completed for WSI_STATE_HTTP:
authorAndrew Canaday <andrew.canaday@nytimes.com>
Wed, 6 Aug 2014 12:58:23 +0000 (08:58 -0400)
committerAndy Green <andy.green@linaro.org>
Thu, 7 Aug 2014 04:13:28 +0000 (12:13 +0800)
This fixes a bug where a client issues two GET requests on the same connection
(keep-alive). If the second request is split into two reads, the
hdr_parsing_complete flag gets us into trouble by ending the request read two
early and giving us bogus data.

lib/handshake.c

index 421494a..b1c7d99 100644 (file)
@@ -68,6 +68,8 @@ libwebsocket_read(struct libwebsocket_context *context,
        switch (wsi->state) {
 http_new:
        case WSI_STATE_HTTP:
+               wsi->hdr_parsing_completed = 0;
+               /* fallthru */
        case WSI_STATE_HTTP_ISSUING_FILE:
                wsi->state = WSI_STATE_HTTP_HEADERS;
                wsi->u.hdr.parser_state = WSI_TOKEN_NAME_PART;