diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c index 916a65e381..a29d7999e3 100644 --- a/components/esp_http_client/esp_http_client.c +++ b/components/esp_http_client/esp_http_client.c @@ -904,6 +904,15 @@ error: return ret; } +int esp_http_client_get_errno(esp_http_client_handle_t client) +{ + if (!client) { + ESP_LOGE(TAG, "Invalid client handle"); + return -1; + } + return esp_transport_get_errno(client->transport); +} + esp_err_t esp_http_client_set_method(esp_http_client_handle_t client, esp_http_client_method_t method) { client->connection_info.method = method; diff --git a/components/esp_http_client/include/esp_http_client.h b/components/esp_http_client/include/esp_http_client.h index 8f8c0b4c09..0545c56883 100644 --- a/components/esp_http_client/include/esp_http_client.h +++ b/components/esp_http_client/include/esp_http_client.h @@ -344,6 +344,17 @@ esp_err_t esp_http_client_set_password(esp_http_client_handle_t client, const ch */ esp_err_t esp_http_client_set_authtype(esp_http_client_handle_t client, esp_http_client_auth_type_t auth_type); +/** + * @brief Get HTTP client session errno + * + * @param[in] client The esp_http_client handle + * + * @return + * - (-1) if invalid argument + * - errno + */ +int esp_http_client_get_errno(esp_http_client_handle_t client); + /** * @brief Set http request method *