From a2dfaebafc7c4f376db84c5eb1567ea52d188c71 Mon Sep 17 00:00:00 2001 From: Michael Scott Date: Tue, 27 Feb 2018 15:24:04 -0800 Subject: [PATCH] net: http: client: handle empty body for PUT/POST request response In previous version of the HTTP API, commit 8ebaf29927c2 ("net: http: dont timeout on HTTP requests w/o body") fixed handling of HTTP responses without body content. For the new API, let's add a specific fix for when PUT/POST requests are responded to with just the status code. Signed-off-by: Michael Scott --- subsys/net/lib/http/http_client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/subsys/net/lib/http/http_client.c b/subsys/net/lib/http/http_client.c index a0598cd3e6f..c76b6287e53 100644 --- a/subsys/net/lib/http/http_client.c +++ b/subsys/net/lib/http/http_client.c @@ -423,6 +423,13 @@ static int on_headers_complete(struct http_parser *parser) return 1; } + if ((ctx->http.req.method == HTTP_PUT || + ctx->http.req.method == HTTP_POST) + && ctx->http.rsp.content_length == 0) { + NET_DBG("No body expected"); + return 1; + } + NET_DBG("Headers complete"); return 0;