http-client: Add #:keep-alive? parameter.
* guix/http-client.scm (http-fetch): Add #:keep-alive? parameter and pass it to 'http-get' or 'http-get*'.
This commit is contained in:
parent
cc27dbcf4a
commit
d262a0f36b
|
@ -222,11 +222,14 @@ or if EOF is reached."
|
||||||
(module-define! (resolve-module '(web client))
|
(module-define! (resolve-module '(web client))
|
||||||
'shutdown (const #f))
|
'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
|
"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
|
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
|
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."
|
Raise an '&http-get-error' condition if downloading fails."
|
||||||
(let loop ((uri (if (string? uri)
|
(let loop ((uri (if (string? uri)
|
||||||
|
@ -246,8 +249,10 @@ Raise an '&http-get-error' condition if downloading fails."
|
||||||
;; Try hard to use the API du jour to get an input port.
|
;; Try hard to use the API du jour to get an input port.
|
||||||
(if (guile-version>? "2.0.7")
|
(if (guile-version>? "2.0.7")
|
||||||
(http-get uri #:streaming? #t #:port port
|
(http-get uri #:streaming? #t #:port port
|
||||||
|
#:keep-alive? #t
|
||||||
#:headers auth-header) ; 2.0.9+
|
#:headers auth-header) ; 2.0.9+
|
||||||
(http-get* uri #:decode-body? text? ; 2.0.7
|
(http-get* uri #:decode-body? text? ; 2.0.7
|
||||||
|
#:keep-alive? #t
|
||||||
#:port port #:headers auth-header)))
|
#:port port #:headers auth-header)))
|
||||||
((code)
|
((code)
|
||||||
(response-code resp)))
|
(response-code resp)))
|
||||||
|
|
Loading…
Reference in New Issue