File tree Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -919,21 +919,14 @@ int HTTPClient::writeToStream(Stream * stream)
919919 */
920920String HTTPClient::getString (void )
921921{
922- StreamString sstring;
923-
924- if (_size > 0 ) {
925- // try to reserve needed memmory
926- if (!sstring.reserve ((_size + 1 ))) {
927- log_d (" not enough memory to reserve a string! need: %d" , (_size + 1 ));
928- return " " ;
929- }
930- }
931- else {
932- return " " ;
922+ // _size can be -1 when Server sends no Content-Length header
923+ if (_size != 0 ) {
924+ StreamString sstring;
925+ writeToStream (&sstring);
926+ return sstring;
933927 }
934928
935- writeToStream (&sstring);
936- return sstring;
929+ return " " ;
937930}
938931
939932/* *
@@ -1441,8 +1434,10 @@ bool HTTPClient::setURL(const String& url)
14411434 _port = (_protocol == " https" ? 443 : 80 );
14421435 }
14431436
1444- // disconnect but preserve _client (clear _canReuse so disconnect will close the connection)
1445- _canReuse = false ;
1437+ // disconnect but preserve _client.
1438+ // Also have to keep the connection otherwise it will free some of the memory used by _client
1439+ // and will blow up later when trying to do _client->available() or similar
1440+ _canReuse = true ;
14461441 disconnect (true );
14471442 return beginInternal (url, _protocol.c_str ());
14481443}
You can’t perform that action at this time.
0 commit comments