File tree 1 file changed +10
-15
lines changed
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)
919
919
*/
920
920
String HTTPClient::getString (void )
921
921
{
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;
933
927
}
934
928
935
- writeToStream (&sstring);
936
- return sstring;
929
+ return " " ;
937
930
}
938
931
939
932
/* *
@@ -1441,8 +1434,10 @@ bool HTTPClient::setURL(const String& url)
1441
1434
_port = (_protocol == " https" ? 443 : 80 );
1442
1435
}
1443
1436
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 ;
1446
1441
disconnect (true );
1447
1442
return beginInternal (url, _protocol.c_str ());
1448
1443
}
You can’t perform that action at this time.
0 commit comments