Unverified Commit cb25fe8c authored by Wojtek Kaniewski's avatar Wojtek Kaniewski Committed by GitHub

Don't clear headers on redirect (#5973)

Current implementation clears _headers when request was sent. If the
user added custom request headers, they will be lost and the redirected
request will not contain them. This commit changes the scope of cleanup
so that the headers survive redirects but don't survive connection
reuse.
parent f5b04b91
...@@ -200,6 +200,7 @@ bool HTTPClient::begin(String url, const char* CAcert) ...@@ -200,6 +200,7 @@ bool HTTPClient::begin(String url, const char* CAcert)
end(); end();
} }
clear();
_port = 443; _port = 443;
if (!beginInternal(url, "https")) { if (!beginInternal(url, "https")) {
return false; return false;
...@@ -226,6 +227,7 @@ bool HTTPClient::begin(String url) ...@@ -226,6 +227,7 @@ bool HTTPClient::begin(String url)
end(); end();
} }
clear();
_port = 80; _port = 80;
if (!beginInternal(url, "http")) { if (!beginInternal(url, "http")) {
return begin(url, (const char*)NULL); return begin(url, (const char*)NULL);
...@@ -243,7 +245,6 @@ bool HTTPClient::begin(String url) ...@@ -243,7 +245,6 @@ bool HTTPClient::begin(String url)
bool HTTPClient::beginInternal(String url, const char* expectedProtocol) bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
{ {
log_v("url: %s", url.c_str()); log_v("url: %s", url.c_str());
clear();
// check for : (http: or https: // check for : (http: or https:
int index = url.indexOf(':'); int index = url.indexOf(':');
...@@ -1212,8 +1213,8 @@ int HTTPClient::handleHeaderResponse() ...@@ -1212,8 +1213,8 @@ int HTTPClient::handleHeaderResponse()
return HTTPC_ERROR_NOT_CONNECTED; return HTTPC_ERROR_NOT_CONNECTED;
} }
clear(); _returnCode = 0;
_size = -1;
_canReuse = _reuse; _canReuse = _reuse;
String transferEncoding; String transferEncoding;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment