From 60e1b644554171f3232df023d8e38af7bb2acdd4 Mon Sep 17 00:00:00 2001 From: cpq Date: Thu, 24 Dec 2020 17:01:49 +0000 Subject: [PATCH] Fix https://github.com/cesanta/mongoose/issues/1030 --- mongoose.c | 7 +++++++ src/http.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/mongoose.c b/mongoose.c index 55720d2c..787f4cc4 100644 --- a/mongoose.c +++ b/mongoose.c @@ -592,6 +592,13 @@ int mg_http_parse(const char *s, size_t len, struct mg_http_message *hm) { hm->message.len = req_len; } + // The 204 (No content) responses also have 0 body length + if (hm->body.len == (size_t) ~0 && is_response && + mg_vcasecmp(&hm->uri, "204") == 0) { + hm->body.len = 0; + hm->message.len = req_len; + } + return req_len; } diff --git a/src/http.c b/src/http.c index 7f608836..76f639d0 100644 --- a/src/http.c +++ b/src/http.c @@ -193,6 +193,13 @@ int mg_http_parse(const char *s, size_t len, struct mg_http_message *hm) { hm->message.len = req_len; } + // The 204 (No content) responses also have 0 body length + if (hm->body.len == (size_t) ~0 && is_response && + mg_vcasecmp(&hm->uri, "204") == 0) { + hm->body.len = 0; + hm->message.len = req_len; + } + return req_len; }