]> granicus.if.org Git - esp-idf/commitdiff
esp_http_client: Fix infinite loop on esp_http_client_fetch_headers
authorDamian Reboredo <reboredodamian@hotmail.com>
Tue, 9 Oct 2018 11:55:19 +0000 (08:55 -0300)
committerMahavir Jain <mahavir@espressif.com>
Thu, 8 Nov 2018 10:27:11 +0000 (15:57 +0530)
error must also be returned if esp_tls_conn_read return 0 because socket  was closed

Merges https://github.com/espressif/esp-idf/pull/2534

components/esp_http_client/esp_http_client.c

index 81e54b7e06dfa1f8468dc0729b18a1f9500fd184..6a0580deef7c74e8032354a79a1c45bfca2ca138 100644 (file)
@@ -894,7 +894,7 @@ int esp_http_client_fetch_headers(esp_http_client_handle_t client)
 
     while (client->state < HTTP_STATE_RES_COMPLETE_HEADER) {
         buffer->len = esp_transport_read(client->transport, buffer->data, client->buffer_size, client->timeout_ms);
-        if (buffer->len < 0) {
+        if (buffer->len <= 0) {
             return ESP_FAIL;
         }
         http_parser_execute(client->parser, client->parser_settings, buffer->data, buffer->len);