net: http_client: Add official null response behavior

Adds an official behavior in response to null response from HTTP
endpoint.

Fixes #42988

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
This commit is contained in:
Georges Oates_Larsen 2022-03-04 11:19:25 -08:00 committed by Maureen Helm
commit 303c42e70a
2 changed files with 25 additions and 5 deletions

View file

@ -396,7 +396,19 @@ static int http_wait_data(int sock, struct http_request *req)
ret = total_received;
if (req->internal.response.cb) {
NET_DBG("Calling callback for closed connection");
NET_DBG("Calling callback for closed connection "
"(NULL HTTP response)");
/* Status code 0 representing a null response */
req->internal.response.http_status_code = 0;
/* Zero out related response metrics */
req->internal.response.processed = 0;
req->internal.response.data_len = 0;
req->internal.response.content_length = 0;
req->internal.response.body_start = NULL;
memset(req->internal.response.http_status, 0,
HTTP_STATUS_STR_SIZE);
req->internal.response.cb(&req->internal.response,
HTTP_DATA_FINAL,