diff options
author | Leo Famulari <leo@famulari.name> | 2016-03-21 12:22:31 -0400 |
---|---|---|
committer | Leo Famulari <leo@famulari.name> | 2016-03-21 12:22:31 -0400 |
commit | 09ec508a4c14d1bc09622d98f796548d79ab0552 (patch) | |
tree | 86cc5a2a67d35ad796bfa33d67869d670d65822e /guix/http-client.scm | |
parent | 2dbed47f5c09347c9af42c5f5bacfccbc1ab4aff (diff) | |
parent | 71cafa0472a15f2234e24d3c6d8019ebb38685b0 (diff) |
Merge branch 'master' into core-updates
Diffstat (limited to 'guix/http-client.scm')
-rw-r--r-- | guix/http-client.scm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/guix/http-client.scm b/guix/http-client.scm index 2161856c63..97a1e26d3e 100644 --- a/guix/http-client.scm +++ b/guix/http-client.scm @@ -222,11 +222,14 @@ or if EOF is reached." (module-define! (resolve-module '(web client)) 'shutdown (const #f)) -(define* (http-fetch uri #:key port (text? #f) (buffered? #t)) +(define* (http-fetch uri #:key port (text? #f) (buffered? #t) + keep-alive?) "Return an input port containing the data at URI, and the expected number of bytes available or #f. If TEXT? is true, the data at URI is considered to be textual. Follow any HTTP redirection. When BUFFERED? is #f, return an -unbuffered port, suitable for use in `filtered-port'. +unbuffered port, suitable for use in `filtered-port'. When KEEP-ALIVE? is +true, send a 'Connection: keep-alive' HTTP header, in which case PORT may be +reused for future HTTP requests. Raise an '&http-get-error' condition if downloading fails." (let loop ((uri (if (string? uri) @@ -240,14 +243,16 @@ Raise an '&http-get-error' condition if downloading fails." (base64-encode (string->utf8 str)))))) (_ '())))) - (unless buffered? + (unless (or buffered? (not (file-port? port))) (setvbuf port _IONBF)) (let*-values (((resp data) ;; Try hard to use the API du jour to get an input port. (if (guile-version>? "2.0.7") (http-get uri #:streaming? #t #:port port + #:keep-alive? #t #:headers auth-header) ; 2.0.9+ (http-get* uri #:decode-body? text? ; 2.0.7 + #:keep-alive? #t #:port port #:headers auth-header))) ((code) (response-code resp))) |