Tcl Source Code

View Ticket
Login
Ticket UUID: 3610253
Title: CopyChunk does not drain decompressor(s)
Type: Bug Version: current: 8.6.0
Submitter: kaitzschu Created on: 2013-04-07 20:42:10
Subsystem: 29. http Package Assigned To: patthoyts
Priority: 5 Medium Severity: Minor
Status: Pending Last Modified: 2022-09-11 16:36:35
Resolution: Fixed Closed By: nobody
    Closed on:
Description:
When retrieving a file from chunked+gzip enabled server (SourceForge project web) I got constantly truncated result. File size was always an exact multiple of 64k bytes and was missing the tail. It seems that http::CopyChunk trusts there can't be more data left on decompression buffer than one /stream get/ can return and does only one round of gets (using /add -finalize/). Attached patch (agains core.tcl.tk version of file) fixed the problem for me, but I'm not quite sure if the encoder chaining (the reason to foreach streams?) has been taken into account correctly.

As a side note, MAX_BUFFER_SIZE has been declared as 65536 but is being referred as "65k" elsewhere in the file http.tcl.
User Comments: kjnash added on 2022-09-11 16:36:35:

I could not find a suitable URL that uses chunked encoding and gzip.

However, the test http11-2.1 does exactly what we need, and it was a matter of finding a file size that triggered the bug - this is now test http11-2.1.1.

The patch provided by kaitzschu fixes the bug. This patch is now applied in commit [3cee774ebf] of branch http-bugfixes-2022H2. However, I have no expertise in the use of channels, and I would appreciate a review of this code.

The ticket reports "File size was always an exact multiple of 64k bytes and was missing the tail." I have changed the size of the chunks sent by the server tests/httpd11.tcl from 512 bytes to 671 bytes, in the hope that making the size not equal to a power of 2 would improve the tests. No other test failures were found.


kaitzschu added on 2013-04-09 17:24:06:
Either unrelated or fix does not apply, version 106daecfcabb5f8314f1196ab9e6cb2e25be1b53 (with date 2013-04-08 20:29:44) from core.tcl.tk has the same problem, downloaded file is still missing tail without patching http::CopyChunk.

dkf added on 2013-04-08 14:58:58:
I wonder if this is related to 3603553 (which is/will be fixed in 8.6.1)

kaitzschu added on 2013-04-08 12:01:12:
A comment to my side note: "65k" appears in file tclZlib.c, not in http.tcl.

kaitzschu added on 2013-04-08 03:42:16:

File Added - 462391: http.CopyChunk.not.draining.everything.diff

Attachments: