mirror of
https://github.com/esphome/esphome.git
synced 2025-02-21 20:38:16 +00: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 "http_request.h"
|
||||||
#include "esphome/core/macros.h"
|
#include "esphome/core/macros.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include "esphome/components/network/util.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace http_request {
|
namespace http_request {
|
||||||
@ -28,6 +29,13 @@ void HttpRequestComponent::set_url(std::string url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HttpRequestComponent::send(const std::vector<HttpRequestResponseTrigger *> &response_triggers) {
|
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;
|
bool begin_status = false;
|
||||||
const String url = this->url_.c_str();
|
const String url = this->url_.c_str();
|
||||||
#ifdef USE_ESP32
|
#ifdef USE_ESP32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user