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; }