Skip to content
Snippets Groups Projects
Unverified Commit 05f38ca8 authored by Christopher Baines's avatar Christopher Baines
Browse files

http-client: Accept #:open-connection in http-fetch.

So that an alternative procedure can be passed in, perhaps to perform
connection caching.

* guix/http-client.scm (http-fetch): Add an #:open-connection keyword
argument.
parent 7b812f7c
No related branches found
No related tags found
No related merge requests found
...@@ -75,6 +75,7 @@ (define-condition-type &http-get-error &error ...@@ -75,6 +75,7 @@ (define-condition-type &http-get-error &error
(define* (http-fetch uri #:key port (text? #f) (buffered? #t) (define* (http-fetch uri #:key port (text? #f) (buffered? #t)
(open-connection guix:open-connection-for-uri)
(keep-alive? #f) (keep-alive? #f)
(verify-certificate? #t) (verify-certificate? #t)
(headers '((user-agent . "GNU Guile"))) (headers '((user-agent . "GNU Guile")))
...@@ -97,10 +98,10 @@ (define* (http-fetch uri #:key port (text? #f) (buffered? #t) ...@@ -97,10 +98,10 @@ (define* (http-fetch uri #:key port (text? #f) (buffered? #t)
(let loop ((uri (if (string? uri) (let loop ((uri (if (string? uri)
(string->uri uri) (string->uri uri)
uri))) uri)))
(let ((port (or port (guix:open-connection-for-uri uri (let ((port (or port (open-connection uri
#:verify-certificate? #:verify-certificate?
verify-certificate? verify-certificate?
#:timeout timeout))) #:timeout timeout)))
(headers (match (uri-userinfo uri) (headers (match (uri-userinfo uri)
((? string? str) ((? string? str)
(cons (cons 'Authorization (cons (cons 'Authorization
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment