From: Xinglu Chen <public@yoctocell.xyz>
To: 53818@debbugs.gnu.org
Cc: Maxime Devos <maximedevos@telenet.be>
Subject: [bug#53818] [PATCH v3 2/7] http-client: Make 'http-fetch/cached' take '#:headers' argument.
Date: Wed, 09 Feb 2022 14:24:25 +0100 [thread overview]
Message-ID: <0ad40732008ce4a9214df154d431741c90e0f128.1644412701.git.public@yoctocell.xyz> (raw)
In-Reply-To: <cover.1644412701.git.public@yoctocell.xyz>
* guix/http-client.scm (http-fetch/cached): Take ‘#:headers’ keyword argument.
---
guix/http-client.scm | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/guix/http-client.scm b/guix/http-client.scm
index 10bc278023..058f09852f 100644
--- a/guix/http-client.scm
+++ b/guix/http-client.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2012, 2015 Free Software Foundation, Inc.
;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2022 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -283,9 +284,11 @@ (define* (http-fetch/cached uri #:key (ttl (%http-cache-ttl)) text?
(write-cache dump-port)
(cache-miss (const #t))
(log-port (current-error-port))
- (timeout 10))
+ (timeout 10)
+ (headers '((user-agent . "GNU Guile"))))
"Like 'http-fetch', return an input port, but cache its contents in
-~/.cache/guix. The cache remains valid for TTL seconds.
+~/.cache/guix. The cache remains valid for TTL seconds. HEADERS is an alist
+of extra HTTP headers. The cache time will automatically be added to HEADERS, so there is no need to specify it.
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
@@ -300,8 +303,8 @@ (define cache-time
(and cache-port
(stat:mtime (stat cache-port))))
- (define headers
- `((user-agent . "GNU Guile")
+ (define headers*
+ `(,@headers
,@(if cache-time
`((if-modified-since
. ,(time-utc->date (make-time time-utc 0 cache-time))))
@@ -316,7 +319,7 @@ (define headers
(raise c))))
(let ((port (http-fetch uri #:text? text?
#:log-port log-port
- #:headers headers #:timeout timeout)))
+ #:headers headers* #:timeout timeout)))
(cache-miss uri)
(mkdir-p (dirname file))
(when cache-port
--
2.34.1
next prev parent reply other threads:[~2022-02-09 13:42 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-06 11:50 [bug#53818] [PATCH 0/3] Add Repology updater Xinglu Chen
2022-02-06 12:41 ` Maxime Devos
2022-02-06 15:17 ` Xinglu Chen
2022-02-06 13:00 ` [bug#53818] [PATCH 1/3] git-download: Export <git-reference> Xinglu Chen
2022-02-06 13:00 ` [bug#53818] [PATCH 2/3] import: Add 'repology' updater Xinglu Chen
2022-02-06 13:11 ` Maxime Devos
2022-02-06 15:18 ` Xinglu Chen
2022-02-06 13:13 ` Maxime Devos
2022-02-06 15:26 ` Xinglu Chen
2022-02-06 13:13 ` Maxime Devos
2022-02-06 13:17 ` Maxime Devos
2022-02-06 15:32 ` Xinglu Chen
2022-02-06 13:18 ` Maxime Devos
2022-02-06 15:34 ` Xinglu Chen
2022-02-06 15:36 ` Maxime Devos
2022-02-06 13:19 ` Maxime Devos
2022-02-06 13:23 ` Maxime Devos
2022-02-06 15:41 ` Xinglu Chen
2022-02-06 13:23 ` Maxime Devos
2022-02-06 15:42 ` Xinglu Chen
2022-02-06 13:00 ` [bug#53818] [PATCH 3/3] gnu: xorg-server-xwayland: Set 'repology-name' property Xinglu Chen
2022-02-06 14:15 ` Maxime Devos
2022-02-07 9:06 ` [bug#53818] [PATCH v2 0/7] Add Repology updater Xinglu Chen
2022-02-07 9:06 ` [bug#53818] [PATCH v2 1/7] upstream: Sort list of updaters Xinglu Chen
2022-02-07 9:06 ` [bug#53818] [PATCH v2 2/7] http-client: Make 'http-fetch/cached' take '#:headers' argument Xinglu Chen
2022-02-07 9:06 ` [bug#53818] [PATCH v2 3/7] http-client: 'http-fetch/cached' accepts a string or a <uri> Xinglu Chen
2022-02-07 9:07 ` [bug#53818] [PATCH v2 4/7] import: json: Make 'json-fetch' take '#:cached?' argument Xinglu Chen
2022-02-07 9:44 ` Maxime Devos
2022-02-07 9:07 ` [bug#53818] [PATCH v2 5/7] import: Add 'repology' updater Xinglu Chen
2022-02-07 9:45 ` Maxime Devos
2022-02-07 9:50 ` Maxime Devos
2022-02-08 12:29 ` Xinglu Chen
2022-02-08 12:49 ` Maxime Devos
2022-02-09 12:54 ` Xinglu Chen
2022-02-07 9:07 ` [bug#53818] [PATCH v2 6/7] gnu: xorg-server-xwayland: Set 'repology-name' property Xinglu Chen
2022-02-07 9:07 ` [bug#53818] [PATCH v2 7/7] gnu: xorg-server-xwayland: Prepare for cross-compilation Xinglu Chen
2022-02-09 13:22 ` [bug#53818] [PATCH v3 0/7] Add Repology updater Xinglu Chen
2022-02-09 13:24 ` [bug#53818] [PATCH v3 1/7] upstream: Sort list of updaters Xinglu Chen
2022-02-09 13:24 ` Xinglu Chen [this message]
2022-02-09 13:24 ` [bug#53818] [PATCH v3 3/7] http-client: 'http-fetch/cached' accepts a string or a <uri> Xinglu Chen
2022-02-09 13:25 ` [bug#53818] [PATCH v3 4/7] import: json: Make 'json-fetch' take '#:http-fetch' argument Xinglu Chen
2022-02-09 13:25 ` [bug#53818] [PATCH v3 5/7] import: Add 'repology' updater Xinglu Chen
2022-02-09 13:25 ` [bug#53818] [PATCH v3 6/7] gnu: xorg-server-xwayland: Set 'repology-name' property Xinglu Chen
2022-02-09 13:25 ` [bug#53818] [PATCH v3 7/7] gnu: xorg-server-xwayland: Prepare for cross-compilation Xinglu Chen
2022-02-08 22:59 ` [bug#53818] [PATCH 0/3] Add Repology updater Ludovic Courtès
2022-02-09 12:52 ` Xinglu Chen
2022-02-09 14:29 ` Nicolas Goaziou
2022-02-10 18:17 ` Xinglu Chen
2022-02-10 19:30 ` Nicolas Goaziou
2022-02-10 20:49 ` Ludovic Courtès
2022-02-14 10:40 ` Nicolas Goaziou
2022-02-14 16:07 ` Maxime Devos
2022-02-14 16:58 ` Ludovic Courtès
2022-02-14 18:42 ` Nicolas Goaziou
2022-02-15 9:57 ` [bug#53818] Improving updaters and ‘guix refresh’ Ludovic Courtès
2022-02-16 12:43 ` Nicolas Goaziou
2022-02-17 10:35 ` Ludovic Courtès
2022-02-17 11:17 ` zimoun
2022-02-18 10:28 ` Nicolas Goaziou
2022-03-03 21:28 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ad40732008ce4a9214df154d431741c90e0f128.1644412701.git.public@yoctocell.xyz \
--to=public@yoctocell.xyz \
--cc=53818@debbugs.gnu.org \
--cc=maximedevos@telenet.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).