Fix support for following redirects added by ee88c42c3b
(#4240) (#4385)
This commit is contained in:
parent
d8dca9c73b
commit
ee3bb16c77
@ -919,21 +919,19 @@ int HTTPClient::writeToStream(Stream * stream)
|
|||||||
*/
|
*/
|
||||||
String HTTPClient::getString(void)
|
String HTTPClient::getString(void)
|
||||||
{
|
{
|
||||||
StreamString sstring;
|
// _size can be -1 when Server sends no Content-Length header
|
||||||
|
if(_size > 0 || _size == -1) {
|
||||||
if(_size > 0) {
|
StreamString sstring;
|
||||||
// try to reserve needed memmory
|
// try to reserve needed memory (noop if _size == -1)
|
||||||
if(!sstring.reserve((_size + 1))) {
|
if(sstring.reserve((_size + 1))) {
|
||||||
|
writeToStream(&sstring);
|
||||||
|
return sstring;
|
||||||
|
} else {
|
||||||
log_d("not enough memory to reserve a string! need: %d", (_size + 1));
|
log_d("not enough memory to reserve a string! need: %d", (_size + 1));
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
writeToStream(&sstring);
|
return "";
|
||||||
return sstring;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1441,8 +1439,10 @@ bool HTTPClient::setURL(const String& url)
|
|||||||
_port = (_protocol == "https" ? 443 : 80);
|
_port = (_protocol == "https" ? 443 : 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
// disconnect but preserve _client (clear _canReuse so disconnect will close the connection)
|
// disconnect but preserve _client.
|
||||||
_canReuse = false;
|
// Also have to keep the connection otherwise it will free some of the memory used by _client
|
||||||
|
// and will blow up later when trying to do _client->available() or similar
|
||||||
|
_canReuse = true;
|
||||||
disconnect(true);
|
disconnect(true);
|
||||||
return beginInternal(url, _protocol.c_str());
|
return beginInternal(url, _protocol.c_str());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user