Fix handling of chunked response headers
This commit is contained in:
parent
2d1859a984
commit
abee614423
|
@ -116,23 +116,17 @@
|
||||||
((response-output bresp) to-chunker)
|
((response-output bresp) to-chunker)
|
||||||
(close-output-port to-chunker))))
|
(close-output-port to-chunker))))
|
||||||
(define buffer (make-bytes 1024))
|
(define buffer (make-bytes 1024))
|
||||||
(define total-size
|
(let loop ()
|
||||||
(let loop ([total-size 0])
|
(define bytes-read-or-eof
|
||||||
(define bytes-read-or-eof
|
(read-bytes-avail! buffer from-servlet))
|
||||||
(read-bytes-avail! buffer from-servlet))
|
(unless (eof-object? bytes-read-or-eof)
|
||||||
(if (eof-object? bytes-read-or-eof)
|
(fprintf to-client "~a\r\n" (number->string bytes-read-or-eof 16))
|
||||||
total-size
|
(write-bytes buffer to-client 0 bytes-read-or-eof)
|
||||||
(begin
|
(fprintf to-client "\r\n")
|
||||||
(fprintf to-client "~a\r\n" (number->string bytes-read-or-eof 16))
|
(loop)))
|
||||||
(write-bytes buffer to-client 0 bytes-read-or-eof)
|
|
||||||
(fprintf to-client "\r\n")
|
|
||||||
(loop (+ total-size bytes-read-or-eof))))))
|
|
||||||
(thread-wait to-chunker-t)
|
(thread-wait to-chunker-t)
|
||||||
(fprintf to-client "0\r\n")
|
(fprintf to-client "0\r\n")
|
||||||
(print-headers
|
(fprintf to-client "\r\n")
|
||||||
to-client
|
|
||||||
(list (header #"Content-Length"
|
|
||||||
(string->bytes/utf-8 (number->string total-size)))))
|
|
||||||
(flush-output to-client))
|
(flush-output to-client))
|
||||||
|
|
||||||
; seconds->gmt-string : Nat -> String
|
; seconds->gmt-string : Nat -> String
|
||||||
|
|
Loading…
Reference in New Issue
Block a user