Skip to content

Commit c0590f5

Browse files
committed
fix(esp_http_client): Fix invalid content length header
In case a request with no content is sent after one with the content length header set the header of the previous request is sent with the subsequent one. For instance, an empty GET request after a PUT request will still indicate the non-zero content length of the previous request. This is fixed by clearing the content length header when it shouldn't be set.
1 parent c586527 commit c0590f5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

components/esp_http_client/esp_http_client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,8 @@ static int http_client_prepare_first_line(esp_http_client_handle_t client, int w
15871587
client->connection_info.method != HTTP_METHOD_DELETE);
15881588
if (write_len != 0 || length_required) {
15891589
http_header_set_format(client->request->headers, "Content-Length", "%d", write_len);
1590+
} else {
1591+
http_header_delete(client->request->headers, "Content-Length");
15901592
}
15911593
} else {
15921594
esp_http_client_set_header(client, "Transfer-Encoding", "chunked");

0 commit comments

Comments
 (0)