[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
06/35: http-client: Accept '#:headers' in 'http-fetched/cached'.
From: |
guix-commits |
Subject: |
06/35: http-client: Accept '#:headers' in 'http-fetched/cached'. |
Date: |
Sat, 21 May 2022 19:43:04 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 00a5a07bb2af8b46169944ba772ad46d4e6e9172
Author: Philip McGrath <philip@philipmcgrath.com>
AuthorDate: Wed May 18 14:10:53 2022 -0400
http-client: Accept '#:headers' in 'http-fetched/cached'.
Callers can supply alternative headers as with 'http-fetch'.
* guix/http-client.scm (http-fetch/cached): Add '#:headers' argument.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
guix/http-client.scm | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/guix/http-client.scm b/guix/http-client.scm
index a367c41afa..699f5dfd57 100644
--- a/guix/http-client.scm
+++ b/guix/http-client.scm
@@ -296,6 +296,7 @@ returning."
#f #f base64url-alphabet))))
(define* (http-fetch/cached uri #:key (ttl (%http-cache-ttl)) text?
+ (headers '((user-agent . "GNU Guile")))
(write-cache dump-port)
(cache-miss (const #t))
(log-port (current-error-port))
@@ -307,6 +308,9 @@ Call WRITE-CACHE with the HTTP input port and the cache
output port to write
the data to cache. Call CACHE-MISS with URI just before fetching data from
URI.
+HEADERS is an alist of extra HTTP headers, to which cache-related headers are
+added automatically as appropriate.
+
TIMEOUT specifies the timeout in seconds for connection establishment.
Write information about redirects to LOG-PORT."
@@ -316,12 +320,12 @@ Write information about redirects to LOG-PORT."
(and cache-port
(stat:mtime (stat cache-port))))
- (define headers
- `((user-agent . "GNU Guile")
- ,@(if cache-time
- `((if-modified-since
- . ,(time-utc->date (make-time time-utc 0 cache-time))))
- '())))
+ (define extended-headers
+ (if cache-time
+ `((if-modified-since
+ . ,(time-utc->date (make-time time-utc 0 cache-time)))
+ ,@headers)
+ headers))
;; Update the cache and return an input port.
(guard (c ((http-get-error? c)
@@ -332,7 +336,8 @@ Write information about redirects to LOG-PORT."
(raise c))))
(let ((port (http-fetch uri #:text? text?
#:log-port log-port
- #:headers headers #:timeout timeout)))
+ #:headers extended-headers
+ #:timeout timeout)))
(cache-miss uri)
(mkdir-p (dirname file))
(when cache-port
- 14/35: gnu: Add elm-url., (continued)
- 14/35: gnu: Add elm-url., guix-commits, 2022/05/21
- 12/35: gnu: Add elm-svg., guix-commits, 2022/05/21
- 35/35: news: Add entry for 'guix import elm'., guix-commits, 2022/05/21
- 16/35: gnu: Add elm-bytes., guix-commits, 2022/05/21
- 32/35: gnu: Add elm-ryannhg-date-format., guix-commits, 2022/05/21
- 15/35: gnu: Add elm-browser., guix-commits, 2022/05/21
- 19/35: gnu: Add elm-parser., guix-commits, 2022/05/21
- 25/35: gnu: Add elm-random., guix-commits, 2022/05/21
- 22/35: gnu: elm: Support 'elm reactor'., guix-commits, 2022/05/21
- 08/35: import: json: Accept '#:http-fetch' in 'json-fetch'., guix-commits, 2022/05/21
- 06/35: http-client: Accept '#:headers' in 'http-fetched/cached'.,
guix-commits <=
- 29/35: gnu: Add elm-justinmimbs-date., guix-commits, 2022/05/21
- 20/35: gnu: Add elm-project-metadata-utils., guix-commits, 2022/05/21
- 23/35: gnu: Add elm-todomvc., guix-commits, 2022/05/21
- 27/35: gnu: Add elm-danhandrea-elm-date-format., guix-commits, 2022/05/21
- 33/35: gnu: Add elm-terezka-intervals., guix-commits, 2022/05/21
- 21/35: gnu: Add elm-explorations-markdown., guix-commits, 2022/05/21
- 30/35: gnu: Add elm-justinmimbs-time-extra., guix-commits, 2022/05/21
- 18/35: gnu: Add elm-http., guix-commits, 2022/05/21
- 11/35: gnu: Add elm-html., guix-commits, 2022/05/21
- 01/35: gnu: elm-compiler: Update to 0.19.1., guix-commits, 2022/05/21