Chapter 2. API Reference
• [in] client: The esp_http_client handle
esp_err_t esp_http_client_cleanup(esp_http_client_handle_t client)
This function must be the last function to call for an session. It is the opposite of the esp_http_client_init
function and must be called with the same handle as input that a esp_http_client_init call returned. This might
close all connections this handle has used and possibly has kept open until now. Don’t call this function if
you intend to transfer more files, re-using handles is a key to good performance with esp_http_client.
Return
• ESP_OK
• ESP_FAIL
Parameters
• [in] client: The esp_http_client handle
esp_http_client_transport_t esp_http_client_get_transport_type(esp_http_client_handle_t
client)
Get transport type.
Return
• HTTP_TRANSPORT_UNKNOWN
• HTTP_TRANSPORT_OVER_TCP
• HTTP_TRANSPORT_OVER_SSL
Parameters
• [in] client: The esp_http_client handle
esp_err_t esp_http_client_set_redirection(esp_http_client_handle_t client)
Set redirection URL. When received the 30x code from the server, the client stores the redirect URL provided
by the server. This function will set the current URL to redirect to enable client to execute the redirection
request.
Return
• ESP_OK
• ESP_FAIL
Parameters
• [in] client: The esp_http_client handle
void esp_http_client_add_auth(esp_http_client_handle_t client)
On receiving HTTP Status code 401, this API can be invoked to add authorization information.
Note There is a possibility of receiving body message with redirection status codes, thus make sure to flush
off body data after calling this API.
Parameters
• [in] client: The esp_http_client handle
bool esp_http_client_is_complete_data_received(esp_http_client_handle_t client)
Checks if entire data in the response has been read without any error.
Return
• true
• false
Parameters
• [in] client: The esp_http_client handle
int esp_http_client_read_response(esp_http_client_handle_t client, char *buffer, int len)
Helper API to read larger data chunks This is a helper API which internally calls esp_http_client_read
multiple times till the end of data is reached or till the buffer gets full.
Return
• Length of data was read
Parameters
• [in] client: The esp_http_client handle
• buffer: The buffer
• [in] len: The buffer length
Espressif Systems 565
Submit Document Feedback
Release v4.4