GNU bug report logs - #53818
[PATCH 0/3] Add Repology updater

Previous Next

Package: guix-patches;

Reported by: Xinglu Chen <public <at> yoctocell.xyz>

Date: Sun, 6 Feb 2022 11:52:02 UTC

Severity: normal

Tags: patch

Full log


Message #131 received at 53818 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 53818 <at> debbugs.gnu.org
Subject: [PATCH v3 4/7] import: json: Make 'json-fetch' take '#:http-fetch'
 argument.
Date: Wed, 09 Feb 2022 14:25:01 +0100
This will let users of the 'json-fetch' procedure use a custom procedure for
fetching the URL, e.g., 'http-fetch/cached'.

* json.scm (json-fetch): Add ‘#:http-fetch’ keyword argument.

Suggested-by: Maxime Devos <maximedevos <at> telenet.be>
---
 guix/import/json.scm | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/guix/import/json.scm b/guix/import/json.scm
index 0c98bb25b8..de7ed60e8d 100644
--- a/guix/import/json.scm
+++ b/guix/import/json.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2015, 2016 Eric Bavier <bavier <at> member.fsf.org>
 ;;; Copyright © 2018, 2019 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2020 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2022 Xinglu Chen <public <at> yoctocell.xyz>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -37,11 +38,13 @@ (define-module (guix import json)
 (define* (json-fetch url
                      ;; Note: many websites returns 403 if we omit a
                      ;; 'User-Agent' header.
-                     #:key (headers `((user-agent . "GNU Guile")
-                                      (Accept . "application/json"))))
+                     #:key
+                     (headers `((user-agent . "GNU Guile")
+                                (Accept . "application/json")))
+                     (http-fetch http-fetch))
   "Return a representation of the JSON resource URL (a list or hash table), or
 #f if URL returns 403 or 404.  HEADERS is a list of HTTP headers to pass in
-the query."
+the query.  HTTP-FETCH is the procedure that is used to fetch the JSON data from URL.  It should take the URL as an argument and HEADERS as a keyword argument, and return an input port for the JSON data."
   (guard (c ((and (http-get-error? c)
                   (let ((error (http-get-error-code c)))
                     (or (= 403 error)
-- 
2.34.1







This bug report was last modified 3 years and 102 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.