From e917345e058365479888560e09e7c0906401c262 Mon Sep 17 00:00:00 2001 From: Andrew Canaday Date: Wed, 6 Aug 2014 08:58:23 -0400 Subject: [PATCH] Reset hdr_parsing_completed for WSI_STATE_HTTP: 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/handshake.c b/lib/handshake.c index 421494a2..b1c7d99d 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -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;