mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 09:09:10 -04:00
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.
This commit is contained in:
parent
c5865270b5
commit
c0590f5b50
@ -1587,6 +1587,8 @@ static int http_client_prepare_first_line(esp_http_client_handle_t client, int w
|
||||
client->connection_info.method != HTTP_METHOD_DELETE);
|
||||
if (write_len != 0 || length_required) {
|
||||
http_header_set_format(client->request->headers, "Content-Length", "%d", write_len);
|
||||
} else {
|
||||
http_header_delete(client->request->headers, "Content-Length");
|
||||
}
|
||||
} else {
|
||||
esp_http_client_set_header(client, "Transfer-Encoding", "chunked");
|
||||
|
Loading…
x
Reference in New Issue
Block a user