From 2814b5a330ac37d92faa8c321216a9c530308e1d Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Mon, 1 Apr 2024 13:15:57 +0530 Subject: [PATCH] Revert "fix(esp_http_client): Call event_handler after header value is received" This reverts commit 04ac8e43dbaf37e42452fef034606ae3f04e644b. When `http_on_header_event` is called, event_handler is invoked and then the current header key and header value are freed. In the previous approach, `http_on_header_event` was called from `http_on_header_value`, but it lead to an issue where if the value is received in multiple chunks, then the current header key and value were freed and thus header was not processed correctly which might result in connection issues. Calling `http_on_heaher_event` from `http_on_header_field` ensures that the current header field and value are processed properly Fixes https://github.com/espressif/esp-idf/issues/13497 Fixes https://github.com/espressif/esp-idf/issues/13097 --- components/esp_http_client/esp_http_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c index 700bceba5b..372d86e900 100644 --- a/components/esp_http_client/esp_http_client.c +++ b/components/esp_http_client/esp_http_client.c @@ -248,6 +248,7 @@ static int http_on_header_event(esp_http_client_handle_t client) static int http_on_header_field(http_parser *parser, const char *at, size_t length) { esp_http_client_t *client = parser->data; + http_on_header_event(client); http_utils_append_string(&client->current_header_key, at, length); return 0; @@ -268,7 +269,6 @@ static int http_on_header_value(http_parser *parser, const char *at, size_t leng http_utils_append_string(&client->auth_header, at, length); } http_utils_append_string(&client->current_header_value, at, length); - http_on_header_event(client); return 0; }