publish: Remove "Guix-Nar-Compression" header from responses.
This was harmless but non-compliant and unnecessary. * guix/scripts/publish.scm <top level>: Rename "Guix-Nar-Compression" to "X-Nar-Compression" as should have always been. (render-nar, nar-response-port): Adjust accordingly. (strip-headers): New procedure. (sans-content-length, with-content-length): Use it.
This commit is contained in:
parent
b0de7fdba6
commit
297e04d660
|
@ -505,10 +505,10 @@ requested using POOL."
|
||||||
stat:size))
|
stat:size))
|
||||||
port))))))
|
port))))))
|
||||||
|
|
||||||
;; XXX: Declare the 'Guix-Compression' HTTP header, which is in fact for
|
;; XXX: Declare the 'X-Nar-Compression' HTTP header, which is in fact for
|
||||||
;; internal consumption: it allows us to pass the compression info to
|
;; internal consumption: it allows us to pass the compression info to
|
||||||
;; 'http-write', as part of the workaround to <http://bugs.gnu.org/21093>.
|
;; 'http-write', as part of the workaround to <http://bugs.gnu.org/21093>.
|
||||||
(declare-header! "Guix-Nar-Compression"
|
(declare-header! "X-Nar-Compression"
|
||||||
(lambda (str)
|
(lambda (str)
|
||||||
(match (call-with-input-string str read)
|
(match (call-with-input-string str read)
|
||||||
(('compression type level)
|
(('compression type level)
|
||||||
|
@ -529,7 +529,7 @@ requested using POOL."
|
||||||
(if (valid-path? store store-path)
|
(if (valid-path? store store-path)
|
||||||
(values `((content-type . (application/x-nix-archive
|
(values `((content-type . (application/x-nix-archive
|
||||||
(charset . "ISO-8859-1")))
|
(charset . "ISO-8859-1")))
|
||||||
(guix-nar-compression . ,compression))
|
(x-nar-compression . ,compression))
|
||||||
;; XXX: We're not returning the actual contents, deferring
|
;; XXX: We're not returning the actual contents, deferring
|
||||||
;; instead to 'http-write'. This is a hack to work around
|
;; instead to 'http-write'. This is a hack to work around
|
||||||
;; <http://bugs.gnu.org/21093>.
|
;; <http://bugs.gnu.org/21093>.
|
||||||
|
@ -638,20 +638,22 @@ example: \"/foo/bar\" yields '(\"foo\" \"bar\")."
|
||||||
(define %http-write
|
(define %http-write
|
||||||
(@@ (web server http) http-write))
|
(@@ (web server http) http-write))
|
||||||
|
|
||||||
|
(define (strip-headers response)
|
||||||
|
"Return RESPONSE's headers minus 'Content-Length' and our internal headers."
|
||||||
|
(fold alist-delete
|
||||||
|
(response-headers response)
|
||||||
|
'(content-length x-raw-file x-nar-compression)))
|
||||||
|
|
||||||
(define (sans-content-length response)
|
(define (sans-content-length response)
|
||||||
"Return RESPONSE without its 'content-length' header."
|
"Return RESPONSE without its 'content-length' header."
|
||||||
(set-field response (response-headers)
|
(set-field response (response-headers)
|
||||||
(alist-delete 'content-length
|
(strip-headers response)))
|
||||||
(response-headers response)
|
|
||||||
eq?)))
|
|
||||||
|
|
||||||
(define (with-content-length response length)
|
(define (with-content-length response length)
|
||||||
"Return RESPONSE with a 'content-length' header set to LENGTH."
|
"Return RESPONSE with a 'content-length' header set to LENGTH."
|
||||||
(set-field response (response-headers)
|
(set-field response (response-headers)
|
||||||
(alist-cons 'content-length length
|
(alist-cons 'content-length length
|
||||||
(fold alist-delete
|
(strip-headers response))))
|
||||||
(response-headers response)
|
|
||||||
'(content-length x-raw-file)))))
|
|
||||||
|
|
||||||
(define-syntax-rule (swallow-EPIPE exp ...)
|
(define-syntax-rule (swallow-EPIPE exp ...)
|
||||||
"Swallow EPIPE errors raised by EXP..."
|
"Swallow EPIPE errors raised by EXP..."
|
||||||
|
@ -673,7 +675,7 @@ example: \"/foo/bar\" yields '(\"foo\" \"bar\")."
|
||||||
(define (nar-response-port response)
|
(define (nar-response-port response)
|
||||||
"Return a port on which to write the body of RESPONSE, the response of a
|
"Return a port on which to write the body of RESPONSE, the response of a
|
||||||
/nar request, according to COMPRESSION."
|
/nar request, according to COMPRESSION."
|
||||||
(match (assoc-ref (response-headers response) 'guix-nar-compression)
|
(match (assoc-ref (response-headers response) 'x-nar-compression)
|
||||||
(($ <compression> 'gzip level)
|
(($ <compression> 'gzip level)
|
||||||
;; Note: We cannot used chunked encoding here because
|
;; Note: We cannot used chunked encoding here because
|
||||||
;; 'make-gzip-output-port' wants a file port.
|
;; 'make-gzip-output-port' wants a file port.
|
||||||
|
|
Loading…
Reference in New Issue