Details
Description
Method QHttpNetworkReplyPrivate::gunzipBodyPartially returns error code incorrectly for example in the following scenario:
Entering the do-while loop with following values:
- inflateStrm.avail_in = 15000
- inflateStrm.avail_out = CHUNK (16384)
zlib's inflate call uncompresses the 15000 input bytes to exactly 16384 bytes thus filling the buffer.
The while condition (inflateStrm.avail_out == 0) in this case so new do-loop is started with inflateStrm.avail_in = 0. Now when inflate is called it returns Z_BUF_ERROR because there is no input data.
This causes inflate to fail and the method report error to caller which results dropped connection. Thus it seems that compressed http gets might fail anytime!
My fix suggestion is to change the while condition check to this:
} while (inflateStrm.avail_out == 0 && inflateStrm.avail_in > 0)
Thus when the buffer fills exactly and there is no more input we just return with OK result.
More information about this in http://www.zlib.net/zlib_how.html.
Attachments
Issue Links
- relates to
-
QTBUG-13191 Refactor Qt HTTP code to support DEFLATE and to remove header reading
- Closed