Commit 9ed95475 authored by Jacob Priddy's avatar Jacob Priddy 👌

Add fix for GET request as well

parent c7e37549
Pipeline #12694 passed with stages
in 1 minute and 15 seconds
......@@ -166,16 +166,22 @@ int door_http_get(door_http_client_handle_t client, const char* path, door_http_
esp_http_client_set_url(handle, path);
esp_http_client_set_method(handle, HTTP_METHOD_GET);
esp_err_t err = esp_http_client_perform(handle);
if (err != ESP_OK)
{
ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err));
return DOOR_HTTP_ERR_FAIL;
}
// Bug in the framework, have to retry until it works
// https://github.com/espressif/esp-idf/issues/2684
for (int tries = 0; tries < 5; ++tries) {
esp_err_t err = esp_http_client_perform(handle);
int status_code = esp_http_client_get_status_code(handle);
ESP_LOGI(TAG, "Status code from GET call: %d", status_code);
return status_code;
if (err == ESP_OK)
{
int status_code = esp_http_client_get_status_code(handle);
ESP_LOGI(TAG, "Status code from GET call: %d", status_code);
return status_code;
}
ESP_LOGE(TAG, "Error perform http request %s. Retrying...", esp_err_to_name(err));
esp_http_client_close(handle);
}
return DOOR_HTTP_ERR_FAIL;
}
int door_http_post(
......@@ -194,11 +200,13 @@ int door_http_post(
}
current_request_callbacks = callbacks;
esp_http_client_set_url(handle, path);
esp_http_client_set_method(handle, HTTP_METHOD_POST);
esp_http_client_set_post_field(client, data, strlen(data));
// Bug in the framework, have to retry until it works
// https://github.com/espressif/esp-idf/issues/2684
for (int tries = 0; tries < 5; ++tries) {
esp_http_client_set_url(handle, path);
esp_http_client_set_method(handle, HTTP_METHOD_POST);
esp_http_client_set_post_field(client, data, strlen(data));
esp_err_t err = esp_http_client_perform(handle);
if (err == ESP_OK)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment