提交 6f23cd59 编写于 作者: M me-no-dev

Make sure that HTTPClient disconnects from the old server if redirecting to new one

Fixes: https://github.com/espressif/arduino-esp32/issues/4763
上级 ad4cf146
......@@ -269,13 +269,20 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
// get port
index = host.indexOf(':');
String the_host;
if(index >= 0) {
_host = host.substring(0, index); // hostname
the_host = host.substring(0, index); // hostname
host.remove(0, (index + 1)); // remove hostname + :
_port = host.toInt(); // get port
} else {
_host = host;
the_host = host;
}
if(_host != the_host && connected()){
log_d("switching host from '%s' to '%s'. disconnecting first", _host.c_str(), the_host.c_str());
_canReuse = false;
disconnect(true);
}
_host = the_host;
_uri = url;
log_d("host: %s port: %d url: %s", _host.c_str(), _port, _uri.c_str());
return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册