From 588d6558e7150a8ed41a1e0a7d0cf22af48ec15c Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Thu, 21 Feb 2019 13:51:40 +0100 Subject: [PATCH] Emit isLast onData cb if we have no data --- src/HttpContext.h | 4 ++++ src/HttpParser.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/HttpContext.h b/src/HttpContext.h index ea6147d..03d883a 100644 --- a/src/HttpContext.h +++ b/src/HttpContext.h @@ -174,10 +174,14 @@ private: std::terminate(); } + /* If we have not responded and we have a data handler, we need to timeout to enfore client sending the data */ + + /* Continue parsing */ return s; }, [httpResponseData](void *user, std::string_view data, bool fin) -> void * { + /* We always get an empty chunk even if there is no data */ if (httpResponseData->inStream) { httpResponseData->inStream(data, fin); diff --git a/src/HttpParser.h b/src/HttpParser.h index c19e33f..4237953 100644 --- a/src/HttpParser.h +++ b/src/HttpParser.h @@ -174,6 +174,9 @@ private: length -= emittable; consumedTotal += emittable; } + } else { + /* Still emit an empty data chunk to signal no data */ + dataHandler(user, {}, true); } if (CONSUME_MINIMALLY) {