Fix HTTPRequestComponent::get_string return value (#2987)

Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
This commit is contained in:
Martin 2022-01-03 19:40:05 +01:00 committed by GitHub
parent f849d45bb6
commit dce3713f12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -115,8 +115,11 @@ void HttpRequestComponent::close() {
} }
const char *HttpRequestComponent::get_string() { const char *HttpRequestComponent::get_string() {
static const String STR = this->client_.getString(); // The static variable is here because HTTPClient::getString() returns a String on ESP32, and we need something to
return STR.c_str(); // to keep a buffer alive.
static std::string str;
str = this->client_.getString().c_str();
return str.c_str();
} }
} // namespace http_request } // namespace http_request