Fix getString() freeze on empty responses (#4317)

This commit is contained in:
wadim 2020-10-01 14:36:23 +02:00 committed by GitHub
parent a9cb7c6d6f
commit aa529eb5a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -921,13 +921,16 @@ String HTTPClient::getString(void)
{
StreamString sstring;
if(_size) {
if(_size > 0) {
// try to reserve needed memmory
if(!sstring.reserve((_size + 1))) {
log_d("not enough memory to reserve a string! need: %d", (_size + 1));
return "";
}
}
else {
return "";
}
writeToStream(&sstring);
return sstring;