[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] web: Handle ending CRLF (\r\n) for chunked input and out
From: |
Christopher Baines |
Subject: |
Re: [PATCH 1/2] web: Handle ending CRLF (\r\n) for chunked input and output ports. |
Date: |
Mon, 04 Jul 2022 12:37:05 +0100 |
User-agent: |
mu4e 1.6.10; emacs 28.1 |
Ludovic Courtès <ludo@gnu.org> writes:
> Christopher Baines <mail@cbaines.net> skribis:
>
>> The chunked transfer encoding specifies the chunked body ends with
>> CRLF. This is in addition to the CRLF at the end of the last chunk, so
>> there should be CRLF twice at the end of the chunked body:
>>
>> https://datatracker.ietf.org/doc/html/rfc2616#section-3.6.1
>>
>> * module/web/http.scm (make-chunked-input-port): Read two extra bytes at
>> the end of the chunked input.
>> (make-chunked-output-port): Write the missing \r\n when closing the
>> port.
>> * test-suite/tests/web-http.test (chunked encoding): Add missing \r\n to
>> test data.
>
> [...]
>
>> This port is of limited use if it cannot be used reliably. Rather than
>> behaving as if the input has finished when it ends unexpectedly, instead
>> raise an exception.
>>
>> * module/web/http.scm (make-chunked-input-port): Raise an exception on
>> premature termination.
>> (&chunked-input-ended-prematurely): New exception type.
>> (chunked-input-ended-prematurely-error?): New procedure.
>> * test-suite/tests/web-http.test (pass-if-named-exception): Rename to
>> pass-if-named-exception.
>> (pass-if-named-exception): New syntax.
>> ("Exception on premature chunk end"): New test for this behaviour.
>
> Applied, thanks!
Awesome :)
> Are there servers out there where you would hit this bug? We were
> “lucky” not to notice before I guess.
I'm unsure. I think I first hit this on the make-chunked-input-port side
with the Guix Build Coordinator. I can't remember the details, but I was
doing some testing with curl at least, and that behaved differently:
https://git.cbaines.net/guix/build-coordinator/commit/?id=3ee79ba7b683275ef066f4d61b1ce50b64bd19ac
signature.asc
Description: PGP signature