Tweak behaviour when the response body is a procedure
Newer versions of Guile Fibers will now use chunked encoding when a procedure is used (and no content length is set). This is good, but not always what is wanted, and there's also an issue with the port encoding. This commit switches to responding with a string/bytevector when more appropriate, plus explicitly setting the port encoding where that's needed.
This commit is contained in:
parent
3ba8418656
commit
0ce5af2c59
2 changed files with 29 additions and 28 deletions
|
|
@ -278,8 +278,9 @@
|
|||
(list (build-response
|
||||
#:code 200
|
||||
#:headers '((content-type . (text/plain))))
|
||||
(call-with-output-string
|
||||
(lambda (port)
|
||||
(write-metrics registry port)))))))
|
||||
(write-metrics registry port))))))))
|
||||
|
||||
(define (render-derivation derivation-file-name)
|
||||
(letpar& ((derivation
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@
|
|||
#:code 200
|
||||
#:headers '((content-type . (application/x-nix-archive
|
||||
(charset . "ISO-8859-1")))))
|
||||
(call-with-output-bytevector
|
||||
(lambda (port)
|
||||
(write-file-tree
|
||||
file-name
|
||||
|
|
@ -122,7 +123,7 @@
|
|||
(bytevector-length derivation-bytevector)))
|
||||
#:file-port
|
||||
(lambda (file)
|
||||
(open-bytevector-input-port derivation-bytevector))))))))
|
||||
(open-bytevector-input-port derivation-bytevector)))))))))
|
||||
(not-found (request-uri request))))
|
||||
|
||||
(define (render-lzip-nar request
|
||||
|
|
@ -137,9 +138,12 @@
|
|||
(lambda (data)
|
||||
(list (build-response
|
||||
#:code 200
|
||||
#:headers '((content-type . (application/x-nix-archive
|
||||
(charset . "ISO-8859-1")))))
|
||||
#:headers `((content-type . (application/x-nix-archive
|
||||
(charset . "ISO-8859-1")))
|
||||
(content-length . ,(bytevector-length data))))
|
||||
(lambda (port)
|
||||
;; TODO: This should probably be handled by guile-fibers
|
||||
(set-port-encoding! port "ISO-8859-1")
|
||||
(put-bytevector port data)))))
|
||||
(not-found (request-uri request))))
|
||||
|
||||
|
|
@ -188,11 +192,9 @@
|
|||
(lambda (file)
|
||||
(open-bytevector-input-port derivation-bytevector)))
|
||||
(get-bytevector)))))
|
||||
(lambda (port)
|
||||
(display (narinfo-string derivation-file-name
|
||||
(narinfo-string derivation-file-name
|
||||
nar-bytevector
|
||||
derivation-references)
|
||||
port))))))))
|
||||
derivation-references)))))))
|
||||
(and=> (parallel-via-thread-pool-channel
|
||||
(with-thread-postgresql-connection
|
||||
(lambda (conn)
|
||||
|
|
@ -204,14 +206,12 @@
|
|||
(list (build-response
|
||||
#:code 200
|
||||
#:headers '((content-type . (application/x-narinfo))))
|
||||
(lambda (port)
|
||||
(display (derivation-source-file-narinfo-string store-path
|
||||
(derivation-source-file-narinfo-string store-path
|
||||
compression
|
||||
compressed-size
|
||||
hash-algorithm
|
||||
hash
|
||||
uncompressed-size)
|
||||
port))))))
|
||||
uncompressed-size)))))
|
||||
(not-found (request-uri request))))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue