From debbugs-submit-bounces@debbugs.gnu.org Wed May 18 14:12:44 2022 Received: (at 55030) by debbugs.gnu.org; 18 May 2022 18:12:44 +0000 Received: from localhost ([127.0.0.1]:33494 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nrOA8-0006JV-2A for submit@debbugs.gnu.org; Wed, 18 May 2022 14:12:44 -0400 Received: from mail-vk1-f171.google.com ([209.85.221.171]:36580) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nrOA6-0006J0-1n for 55030@debbugs.gnu.org; Wed, 18 May 2022 14:12:42 -0400 Received: by mail-vk1-f171.google.com with SMTP id 125so1577813vkw.3 for <55030@debbugs.gnu.org>; Wed, 18 May 2022 11:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hBgSEJ58Zdr4r33zt9FIFcJt1zauWUSnAuRcMyblxlg=; b=VhlelX5eqhUrrjLCvTNdAs8VUAFatykwEzQzFrgXIi5la2Ys15IwGnIkEwOx7NpyLG nQDGEdYAgbblSkMQkI1ocs0YTfmGBQD8tCJQngENmOVI0vkNx5PEGVHMTzA7URNkbmEl 3XH7+zVwiYxsM6nsr4Xmg+Mxx7YkchgNwFpIFN0MEoi9Y1mDGlOEtYLntRQQZBAslVjo Jvg0YtGVpwwP4GAzs7VPSN6cS3hu5XXDGIczY8izYoxzCXzr5Xpb9QnN/CXG/F3K+fBU ZxLmJzsy6i6YVB6xLhqU+8e5x4IaJsz08rHrsrvEdtfuR6KLSb9r/2DuDcHoN6UxwZ33 9x8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hBgSEJ58Zdr4r33zt9FIFcJt1zauWUSnAuRcMyblxlg=; b=rdR19ZKqoxGu/pEbelSV8niV64hiAnTiOn7dG1mSwX8OE65O8MSTWjvViJxOUxVM61 aHuAvDurYHX2SLWYL8DYVSdghJzGxKOXVx8bA8Z6hwgxx+Ss2gsLnZJ4BBPfX+asI9y7 th+ye1UJKq6y4oTKV6t4EobFIpuPs+hPgjkObGF+3HtnpDs0lozymX9UtTNWRRwtcfYV g4cTtwmpADzOEo522keRHgD5ZubLe84OzKTVe2cpZX/x13tvay8lXUv0nV/jYHjFGP/K nkve9UcNoILxYkaY6/vAH5vc2Z6fUbTgNHwdOtWx82Sy3VA1P9fLsSbQLTKaT7W0kAA1 0Ydw== X-Gm-Message-State: AOAM530Oe4lRvxGTZo9ne6KHaYKhvzyupEZ6hgf7TLKv+yvHrDoYViBg AvZnXhX30aWV8NyX5s/+IVGf1fkxUR7V60Ll X-Google-Smtp-Source: ABdhPJzC6vq7xeeA6JGDc0GxVgiQpZfJ9BybnN5KKufTy5iGIviapfnRg5t49zaLawcCqrB3kTFybQ== X-Received: by 2002:a05:6122:221f:b0:343:f3d4:87cb with SMTP id bb31-20020a056122221f00b00343f3d487cbmr449532vkb.13.1652897556611; Wed, 18 May 2022 11:12:36 -0700 (PDT) Received: from localhost (c-73-125-98-51.hsd1.fl.comcast.net. [73.125.98.51]) by smtp.gmail.com with UTF8SMTPSA id v145-20020a1f2f97000000b003571658b813sm132940vkv.10.2022.05.18.11.12.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 11:12:36 -0700 (PDT) From: Philip McGrath To: 55030@debbugs.gnu.org Subject: [PATCH v2 08/34] import: json: Accept '#:http-fetch' in 'json-fetch'. Date: Wed, 18 May 2022 14:10:55 -0400 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: <20220419232736.272970-1-philip@philipmcgrath.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.6 (/) X-Debbugs-Envelope-To: 55030 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= , Philip McGrath X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) For example, supplying 'http-fetch/cached' would enable caching. * guix/import/json.scm (json-fetch): Add '#:http-fetch' argument. --- 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..ae00ee929e 100644 --- a/guix/import/json.scm +++ b/guix/import/json.scm @@ -35,13 +35,16 @@ (define-module (guix import json) json->scheme-file)) (define* (json-fetch url + #:key + (http-fetch http-fetch) ;; Note: many websites returns 403 if we omit a ;; 'User-Agent' header. - #:key (headers `((user-agent . "GNU Guile") - (Accept . "application/json")))) + (headers `((user-agent . "GNU Guile") + (Accept . "application/json")))) "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 called to perform the request: for example, to +enable caching, supply 'http-fetch/cached'." (guard (c ((and (http-get-error? c) (let ((error (http-get-error-code c))) (or (= 403 error) -- 2.32.0