mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_http_client: Fix when receive FIN, close the connection in internal.
Closes https://github.com/espressif/esp-idf/issues/7036
This commit is contained in:
parent
e1c978a03b
commit
02367b44ef
@ -596,6 +596,9 @@ static const esp_err_msg_t esp_err_msg_table[] = {
|
||||
# endif
|
||||
# ifdef ESP_ERR_HTTP_EAGAIN
|
||||
ERR_TBL_IT(ESP_ERR_HTTP_EAGAIN), /* 28679 0x7007 Mapping of errno EAGAIN to esp_err_t */
|
||||
# endif
|
||||
# ifdef ESP_ERR_HTTP_CONNECTION_CLOSED
|
||||
ERR_TBL_IT(ESP_ERR_HTTP_CONNECTION_CLOSED), /* 28680 0x7008 Read FIN from peer and the connection closed */
|
||||
# endif
|
||||
// components/esp-tls/esp_tls_errors.h
|
||||
# ifdef ESP_ERR_ESP_TLS_BASE
|
||||
|
@ -1052,6 +1052,11 @@ esp_err_t esp_http_client_perform(esp_http_client_handle_t client)
|
||||
if (client->is_async && errno == EAGAIN) {
|
||||
return ESP_ERR_HTTP_EAGAIN;
|
||||
}
|
||||
if (esp_tls_get_and_clear_last_error(esp_transport_get_error_handle(client->transport), NULL, NULL) == ESP_ERR_ESP_TLS_TCP_CLOSED_FIN) {
|
||||
ESP_LOGW(TAG, "Close connection due to FIN received");
|
||||
esp_http_client_close(client);
|
||||
return ESP_ERR_HTTP_CONNECTION_CLOSED;
|
||||
}
|
||||
return ESP_ERR_HTTP_FETCH_HEADER;
|
||||
}
|
||||
/* falls through */
|
||||
|
@ -167,6 +167,7 @@ typedef enum {
|
||||
#define ESP_ERR_HTTP_INVALID_TRANSPORT (ESP_ERR_HTTP_BASE + 5) /*!< There are no transport support for the input scheme */
|
||||
#define ESP_ERR_HTTP_CONNECTING (ESP_ERR_HTTP_BASE + 6) /*!< HTTP connection hasn't been established yet */
|
||||
#define ESP_ERR_HTTP_EAGAIN (ESP_ERR_HTTP_BASE + 7) /*!< Mapping of errno EAGAIN to esp_err_t */
|
||||
#define ESP_ERR_HTTP_CONNECTION_CLOSED (ESP_ERR_HTTP_BASE + 8) /*!< Read FIN from peer and the connection closed */
|
||||
|
||||
/**
|
||||
* @brief Start a HTTP session
|
||||
|
Loading…
Reference in New Issue
Block a user