unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Christopher Baines <mail@cbaines.net>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guile-devel@gnu.org
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	[thread overview]
Message-ID: <875ykd6r9w.fsf@cbaines.net> (raw)
In-Reply-To: <87o7y5fbjg.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1779 bytes --]


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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]

      reply	other threads:[~2022-07-04 11:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30 18:15 [PATCH 1/2] web: Handle ending CRLF (\r\n) for chunked input and output ports Christopher Baines
2022-06-30 18:15 ` [PATCH 2/2] web: Don't hide missing data in the chunked input port Christopher Baines
2022-07-04  9:54 ` [PATCH 1/2] web: Handle ending CRLF (\r\n) for chunked input and output ports Ludovic Courtès
2022-07-04 11:37   ` Christopher Baines [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875ykd6r9w.fsf@cbaines.net \
    --to=mail@cbaines.net \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).