From 2060f3a645ed04ccc343a9c1445c692f5430e40a Mon Sep 17 00:00:00 2001 From: jim Date: Wed, 18 Oct 2023 15:50:35 +0800 Subject: [PATCH] esp_http_client: Fix reset errno to 0 before call esp_transport_read Closes https://github.com/espressif/esp-idf/issues/9020 --- components/esp_http_client/esp_http_client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c index d996cc9486d..64bb57173c0 100644 --- a/components/esp_http_client/esp_http_client.c +++ b/components/esp_http_client/esp_http_client.c @@ -1106,7 +1106,7 @@ static int esp_http_client_get_data(esp_http_client_handle_t client) esp_http_buffer_t *res_buffer = client->response->buffer; ESP_LOGD(TAG, "data_process=%"PRId64", content_length=%"PRId64, client->response->data_process, client->response->content_length); - + errno = 0; int rlen = esp_transport_read(client->transport, res_buffer->data, client->buffer_size_rx, client->timeout_ms); if (rlen >= 0) { // When tls error is ESP_TLS_ERR_SSL_WANT_READ (-0x6900), esp_trasnport_read returns ERR_TCP_TRANSPORT_CONNECTION_TIMEOUT (0x0). @@ -1345,6 +1345,7 @@ int64_t esp_http_client_fetch_headers(esp_http_client_handle_t client) client->response->status_code = -1; while (client->state < HTTP_STATE_RES_COMPLETE_HEADER) { + errno = 0; buffer->len = esp_transport_read(client->transport, buffer->data, client->buffer_size_rx, client->timeout_ms); if (buffer->len <= 0) { if (buffer->len == ERR_TCP_TRANSPORT_CONNECTION_TIMEOUT) {