diff options
author | Christopher Baines <mail@cbaines.net> | 2023-05-08 16:05:05 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2023-05-08 19:47:30 +0100 |
commit | 0ee9ce1b3755706cf5e283e4612b68581c4be37e (patch) | |
tree | e142898ddc5e47a7a20c346ccee08623e0a6c58a /guix-build-coordinator/utils.scm | |
parent | dd68c838e992075f338d349d413c8b98a4395c7d (diff) | |
download | build-coordinator-0ee9ce1b3755706cf5e283e4612b68581c4be37e.tar build-coordinator-0ee9ce1b3755706cf5e283e4612b68581c4be37e.tar.gz |
Stop using chunked transfers for file uploads
As the amount of data to upload is known, this is unnecessary complexity and
overhead.
Diffstat (limited to 'guix-build-coordinator/utils.scm')
-rw-r--r-- | guix-build-coordinator/utils.scm | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 2fe7948..7f4bf0c 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -304,7 +304,9 @@ (setvbuf ret 'block buffering) ret)) -(define* (call-with-streaming-http-request uri callback +(define* (call-with-streaming-http-request uri + content-length + callback #:key (headers '()) (method 'PUT)) (with-port-timeouts @@ -316,8 +318,10 @@ #:method method #:version '(1 . 1) #:headers `((connection close) - (Transfer-Encoding . "chunked") + (content-length . ,content-length) (Content-Type . "application/octet-stream") + ;; read-request-body/patch looks for this header + (Stream-Body . "true") ,@headers) #:port port))) @@ -325,26 +329,19 @@ (setvbuf port 'block (expt 2 13)) (with-exception-handler (lambda (exp) - (simple-format #t "error: PUT ~A: ~A\n" (uri-path uri) exp) + (simple-format #t "error: ~A ~A: ~A\n" + method (uri-path uri) exp) (close-port port) (raise-exception exp)) (lambda () (let ((request (write-request request port))) - (let* ((chunked-output-port - (make-chunked-output-port* - port - #:buffering (expt 2 12) - #:keep-alive? #t))) - - (set-port-encoding! chunked-output-port "ISO-8859-1") - (callback chunked-output-port) - (close-port chunked-output-port) - - (let ((response (read-response port))) - (let ((body (read-response-body response))) - (close-port port) - (values response - body))))))))))) + (callback port) + + (let ((response (read-response port))) + (let ((body (read-response-body response))) + (close-port port) + (values response + body)))))))))) (define (find-missing-substitutes-for-output store substitute-urls output) (if (valid-path? store output) |