Fix HTTPClient crash on GET() for url with redirects

Fixes: https://github.com/espressif/arduino-esp32/issues/4931
This commit is contained in:
me-no-dev 2021-03-16 21:28:19 +02:00
parent d362e1ee1a
commit a451c9ef0d

View File

@ -109,6 +109,12 @@ HTTPClient::~HTTPClient()
if(_currentHeaders) {
delete[] _currentHeaders;
}
if(_tcpDeprecated) {
_tcpDeprecated.reset(nullptr);
}
if(_transportTraits) {
_transportTraits.reset(nullptr);
}
}
void HTTPClient::clear()
@ -284,7 +290,7 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
}
_host = the_host;
_uri = url;
log_d("host: %s port: %d url: %s", _host.c_str(), _port, _uri.c_str());
log_d("protocol: %s, host: %s port: %d url: %s", _protocol.c_str(), _host.c_str(), _port, _uri.c_str());
return true;
}
@ -376,13 +382,12 @@ void HTTPClient::disconnect(bool preserveClient)
}
if(_reuse && _canReuse) {
log_d("tcp keep open for reuse\n");
log_d("tcp keep open for reuse");
} else {
log_d("tcp stop\n");
log_d("tcp stop");
_client->stop();
if(!preserveClient) {
_client = nullptr;
}
#ifdef HTTPCLIENT_1_1_COMPATIBLE
if(_tcpDeprecated) {
_transportTraits.reset(nullptr);
@ -390,6 +395,7 @@ void HTTPClient::disconnect(bool preserveClient)
}
#endif
}
}
} else {
log_d("tcp is closed\n");
}