mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 12:46:22 +01:00
Fix reset on http_request without network connection (#2474)
* Fix reset problem when http_request is sent without network connection (#2501) * Fix format
This commit is contained in:
parent
85461a752a
commit
d7ad155885
@ -3,6 +3,7 @@
|
||||
#include "http_request.h"
|
||||
#include "esphome/core/macros.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/components/network/util.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace http_request {
|
||||
@ -28,6 +29,13 @@ void HttpRequestComponent::set_url(std::string url) {
|
||||
}
|
||||
|
||||
void HttpRequestComponent::send(const std::vector<HttpRequestResponseTrigger *> &response_triggers) {
|
||||
if (!network::is_connected()) {
|
||||
this->client_.end();
|
||||
this->status_set_warning();
|
||||
ESP_LOGW(TAG, "HTTP Request failed; Not connected to network");
|
||||
return;
|
||||
}
|
||||
|
||||
bool begin_status = false;
|
||||
const String url = this->url_.c_str();
|
||||
#ifdef USE_ESP32
|
||||
|
Loading…
Reference in New Issue
Block a user