Fix handling of chunked response headers

This commit is contained in:
Jay McCarthy 2014-03-12 08:52:35 -06:00
parent 2d1859a984
commit abee614423

View File

@ -116,23 +116,17 @@
((response-output bresp) to-chunker)
(close-output-port to-chunker))))
(define buffer (make-bytes 1024))
(define total-size
(let loop ([total-size 0])
(let loop ()
(define bytes-read-or-eof
(read-bytes-avail! buffer from-servlet))
(if (eof-object? bytes-read-or-eof)
total-size
(begin
(unless (eof-object? bytes-read-or-eof)
(fprintf to-client "~a\r\n" (number->string bytes-read-or-eof 16))
(write-bytes buffer to-client 0 bytes-read-or-eof)
(fprintf to-client "\r\n")
(loop (+ total-size bytes-read-or-eof))))))
(loop)))
(thread-wait to-chunker-t)
(fprintf to-client "0\r\n")
(print-headers
to-client
(list (header #"Content-Length"
(string->bytes/utf-8 (number->string total-size)))))
(fprintf to-client "\r\n")
(flush-output to-client))
; seconds->gmt-string : Nat -> String