esp_http_client: Add helper API to read larger data chunks from HTTP Stream

pull/5000/head
Shubham Kulkarni 2020-03-12 19:12:27 +05:30
rodzic 6af3456ca3
commit 4858184e19
2 zmienionych plików z 27 dodań i 0 usunięć

Wyświetl plik

@ -1315,3 +1315,16 @@ void esp_http_client_add_auth(esp_http_client_handle_t client)
ESP_LOGW(TAG, "This request requires authentication, but does not provide header information for that");
}
}
int esp_http_client_read_response(esp_http_client_handle_t client, char *buffer, int len)
{
int read_len = 0;
while (read_len < len) {
int data_read = esp_http_client_read(client, buffer + read_len, len - read_len);
if (data_read <= 0) {
return read_len;
}
read_len += data_read;
}
return read_len;
}

Wyświetl plik

@ -497,6 +497,20 @@ void esp_http_client_add_auth(esp_http_client_handle_t client);
*/
bool esp_http_client_is_complete_data_received(esp_http_client_handle_t client);
/**
* @brief 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.
*
* @param[in] client The esp_http_client handle
* @param buffer The buffer
* @param[in] len The buffer length
*
* @return
* - Length of data was read
*/
int esp_http_client_read_response(esp_http_client_handle_t client, char *buffer, int len);
#ifdef __cplusplus
}
#endif