From 33988f9b5876e4b44cabe1997a91eb604931c1ca Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 22 Jan 2018 10:46:34 +0100 Subject: publish: Restore gzip compression in cache-less mode. Fixes . Regression introduced in 297e04d66010ada31a40f40143d81bf6b62affcc. Reported by Christopher Baines . * guix/scripts/publish.scm (nar-response-port): Add 'compression' parameter and honor it. (http-write): Get 'x-nar-compression' from the initial RESPONSE. --- guix/scripts/publish.scm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'guix/scripts/publish.scm') diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index 1673fb9f33..b5dfdab32f 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm @@ -672,10 +672,10 @@ (define-syntax-rule (swallow-zlib-error exp ...) exp ...) (const #f))) -(define (nar-response-port response) +(define (nar-response-port response compression) "Return a port on which to write the body of RESPONSE, the response of a /nar request, according to COMPRESSION." - (match (assoc-ref (response-headers response) 'x-nar-compression) + (match compression (($ 'gzip level) ;; Note: We cannot used chunked encoding here because ;; 'make-gzip-output-port' wants a file port. @@ -697,11 +697,13 @@ (define (http-write server client response body) (call-with-new-thread (lambda () (set-thread-name "publish nar") - (let* ((response (write-response (sans-content-length response) - client)) - (port (begin - (force-output client) - (nar-response-port response)))) + (let* ((compression (assoc-ref (response-headers response) + 'x-nar-compression)) + (response (write-response (sans-content-length response) + client)) + (port (begin + (force-output client) + (nar-response-port response compression)))) ;; XXX: Given our ugly workaround for in ;; 'render-nar', BODY here is just the file name of the store item. ;; We call 'write-file' from here because we know that's the only -- cgit v1.2.3