protect against errors in chunking or gunziping... without this there can be hangs

This commit is contained in:
Jay McCarthy 2014-05-08 09:46:45 -06:00
parent 718cbd4c41
commit fc8075245a

View File

@ -192,9 +192,13 @@
(loop bs)))))
(define-values (in out) (make-pipe PIPE-SIZE))
(define chunk-t
(thread
(λ ()
(http-pipe-chunk (http-conn-from hc) out)
(http-pipe-chunk (http-conn-from hc) out))))
(thread
(λ ()
(thread-wait chunk-t)
(when close?
(http-conn-close! hc))
(close-output-port out)))
@ -237,9 +241,13 @@
(cond
[(and (memq 'gzip decodes) (regexp-member #rx#"^(?i:Content-Encoding: +gzip)$" headers))
(define-values (in out) (make-pipe PIPE-SIZE))
(define gunzip-t
(thread
(λ ()
(gunzip-through-ports raw-response-port out)
(gunzip-through-ports raw-response-port out))))
(thread
(λ ()
(thread-wait gunzip-t)
(close-output-port out)))
in]
[else