From fc8075245a3237ded23fbd5b0bf46096ba89e830 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Thu, 8 May 2014 09:46:45 -0600 Subject: [PATCH] protect against errors in chunking or gunziping... without this there can be hangs --- racket/collects/net/http-client.rkt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/racket/collects/net/http-client.rkt b/racket/collects/net/http-client.rkt index ee1d8b1598..54d7b628a1 100644 --- a/racket/collects/net/http-client.rkt +++ b/racket/collects/net/http-client.rkt @@ -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)))) (thread (λ () - (http-pipe-chunk (http-conn-from hc) out) + (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)) - (thread + (define gunzip-t + (thread + (λ () + (gunzip-through-ports raw-response-port out)))) + (thread (λ () - (gunzip-through-ports raw-response-port out) + (thread-wait gunzip-t) (close-output-port out))) in] [else