[http_request] Feed watchdog timeout around http request functions (#7786)

This commit is contained in:
Jesse Hills 2024-11-20 13:54:19 +13:00
parent 1ad535d030
commit eb8a2326ad
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A
2 changed files with 8 additions and 0 deletions

View file

@ -104,7 +104,9 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::start(std::string url, std::s
static const size_t HEADER_COUNT = sizeof(header_keys) / sizeof(header_keys[0]); static const size_t HEADER_COUNT = sizeof(header_keys) / sizeof(header_keys[0]);
container->client_.collectHeaders(header_keys, HEADER_COUNT); container->client_.collectHeaders(header_keys, HEADER_COUNT);
App.feed_wdt();
container->status_code = container->client_.sendRequest(method.c_str(), body.c_str()); container->status_code = container->client_.sendRequest(method.c_str(), body.c_str());
App.feed_wdt();
if (container->status_code < 0) { if (container->status_code < 0) {
ESP_LOGW(TAG, "HTTP Request failed; URL: %s; Error: %s", url.c_str(), ESP_LOGW(TAG, "HTTP Request failed; URL: %s; Error: %s", url.c_str(),
HTTPClient::errorToString(container->status_code).c_str()); HTTPClient::errorToString(container->status_code).c_str());

View file

@ -117,8 +117,11 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
return nullptr; return nullptr;
} }
App.feed_wdt();
container->content_length = esp_http_client_fetch_headers(client); container->content_length = esp_http_client_fetch_headers(client);
App.feed_wdt();
container->status_code = esp_http_client_get_status_code(client); container->status_code = esp_http_client_get_status_code(client);
App.feed_wdt();
if (is_success(container->status_code)) { if (is_success(container->status_code)) {
container->duration_ms = millis() - start; container->duration_ms = millis() - start;
return container; return container;
@ -148,8 +151,11 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
return nullptr; return nullptr;
} }
App.feed_wdt();
container->content_length = esp_http_client_fetch_headers(client); container->content_length = esp_http_client_fetch_headers(client);
App.feed_wdt();
container->status_code = esp_http_client_get_status_code(client); container->status_code = esp_http_client_get_status_code(client);
App.feed_wdt();
if (is_success(container->status_code)) { if (is_success(container->status_code)) {
container->duration_ms = millis() - start; container->duration_ms = millis() - start;
return container; return container;