mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ESP HTTPS OTA: send POST request body if set
Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com> Closes: https://github.com/espressif/esp-idf/issues/6390 Merges: https://github.com/espressif/esp-idf/pull/6391
This commit is contained in:
parent
7f8541ff47
commit
807bf9688c
@ -104,11 +104,29 @@ static esp_err_t _http_connect(esp_http_client_handle_t http_client)
|
||||
esp_err_t err = ESP_FAIL;
|
||||
int status_code, header_ret;
|
||||
do {
|
||||
err = esp_http_client_open(http_client, 0);
|
||||
char *post_data = NULL;
|
||||
/* Send POST request if body is set.
|
||||
* Note: Sending POST request is not supported if partial_http_download
|
||||
* is enabled
|
||||
*/
|
||||
int post_len = esp_http_client_get_post_field(http_client, &post_data);
|
||||
err = esp_http_client_open(http_client, post_len);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to open HTTP connection: %s", esp_err_to_name(err));
|
||||
return err;
|
||||
}
|
||||
if (post_len) {
|
||||
int write_len = 0;
|
||||
while (post_len > 0) {
|
||||
write_len = esp_http_client_write(http_client, post_data, post_len);
|
||||
if (write_len < 0) {
|
||||
ESP_LOGE(TAG, "Write failed");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
}
|
||||
post_len -= write_len;
|
||||
post_data += write_len;
|
||||
}
|
||||
header_ret = esp_http_client_fetch_headers(http_client);
|
||||
if (header_ret < 0) {
|
||||
return header_ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user