Skip to content

Commit

Permalink
esp_http_client: Fix reset errno to 0 before call esp_transport_read
Browse files Browse the repository at this point in the history
Closes #9020
  • Loading branch information
ESP-YJM authored and mahavirj committed Feb 29, 2024
1 parent ba14fc2 commit 2060f3a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/esp_http_client/esp_http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2060f3a

Please sign in to comment.