diff options
author | Christopher Baines <mail@cbaines.net> | 2022-06-30 19:15:53 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-07-04 11:22:11 +0200 |
commit | 9a3353a993e8b73312a0005278f12c67cffa9854 (patch) | |
tree | 5b7776d51f03f40ae99d4b144932677f05051ae7 /module/web | |
parent | a84d8f6473979e5967e7eafa0a46ab74e12cc036 (diff) | |
download | guile-9a3353a993e8b73312a0005278f12c67cffa9854.tar.gz |
web: Handle ending CRLF (\r\n) for chunked input and output ports.
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.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'module/web')
-rw-r--r-- | module/web/http.scm | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/module/web/http.scm b/module/web/http.scm index 6af790384..827adad3e 100644 --- a/module/web/http.scm +++ b/module/web/http.scm @@ -1987,6 +1987,7 @@ closed it will also close PORT, unless the KEEP-ALIVE? is true." (cond ((zero? size) (set! finished? #t) + (get-bytevector-n port 2) ; \r\n follows the last chunk num-read) (else (loop to-read num-read))))) @@ -2041,7 +2042,7 @@ KEEP-ALIVE? is true." (put-string port "\r\n")))) (define (close) (flush) - (put-string port "0\r\n") + (put-string port "0\r\n\r\n") (force-output port) (unless keep-alive? (close-port port))) |