Minor optimization in HTTP requests.

--HG--
branch : dev
This commit is contained in:
Martín Lucas Golini
2019-05-08 22:06:08 -03:00
parent f028f7b2b9
commit 39ec343096
2 changed files with 11 additions and 4 deletions
+8
View File
@@ -730,6 +730,14 @@ Http::Response Http::downloadRequest(const Http::Request& request, IOStream& wri
break;
}
}
// If the response is compressed and the stream ended means that we received
// the message. So we can skip the socket receive call.
if ( ( compressed && NULL != inflateStream && !inflateStream->isOpen() ) ||
( contentLength > 0 && contentLength == currentTotalBytes )
) {
break;
}
}
}
+3 -4
View File
@@ -106,10 +106,9 @@ ios_size IOStreamInflate::write(const char * buffer, ios_size length) {
int rc = inflate(&zstr, Z_NO_FLUSH);
if (rc == Z_STREAM_END) {
ios_size ret = mStream.write( (const char*)mBuffer.data, mBuffer.size - zstr.avail_out);
length = mStream.write( (const char*)mBuffer.data, mBuffer.size - zstr.avail_out);
if (ret == 0)
return 0;
mLocalStream->state = rc;
break;
}
@@ -156,7 +155,7 @@ ios_size IOStreamInflate::getSize() {
}
bool IOStreamInflate::isOpen() {
return mStream.isOpen();
return mStream.isOpen() && mLocalStream->state != Z_STREAM_END;
}
const Compression::Mode& IOStreamInflate::getMode() const {