aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/utils.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-05-08 16:05:05 +0100
committerChristopher Baines <mail@cbaines.net>2023-05-08 19:47:30 +0100
commit0ee9ce1b3755706cf5e283e4612b68581c4be37e (patch)
treee142898ddc5e47a7a20c346ccee08623e0a6c58a /guix-build-coordinator/utils.scm
parentdd68c838e992075f338d349d413c8b98a4395c7d (diff)
downloadbuild-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.scm33
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)