Skip to content

Commit cb25fe8

Browse files
authored
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.
1 parent f5b04b9 commit cb25fe8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: libraries/HTTPClient/src/HTTPClient.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ bool HTTPClient::begin(String url, const char* CAcert)
200200
end();
201201
}
202202

203+
clear();
203204
_port = 443;
204205
if (!beginInternal(url, "https")) {
205206
return false;
@@ -226,6 +227,7 @@ bool HTTPClient::begin(String url)
226227
end();
227228
}
228229

230+
clear();
229231
_port = 80;
230232
if (!beginInternal(url, "http")) {
231233
return begin(url, (const char*)NULL);
@@ -243,7 +245,6 @@ bool HTTPClient::begin(String url)
243245
bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
244246
{
245247
log_v("url: %s", url.c_str());
246-
clear();
247248

248249
// check for : (http: or https:
249250
int index = url.indexOf(':');
@@ -1212,8 +1213,8 @@ int HTTPClient::handleHeaderResponse()
12121213
return HTTPC_ERROR_NOT_CONNECTED;
12131214
}
12141215

1215-
clear();
1216-
1216+
_returnCode = 0;
1217+
_size = -1;
12171218
_canReuse = _reuse;
12181219

12191220
String transferEncoding;

0 commit comments

Comments
 (0)