From patchwork Wed May 18 18:10:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip McGrath X-Patchwork-Id: 39481 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DDEE827BBEA; Wed, 18 May 2022 19:14:43 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A63C527BBE9 for ; Wed, 18 May 2022 19:14:43 +0100 (BST) Received: from localhost ([::1]:37956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrOC2-0000nU-S4 for patchwork@mira.cbaines.net; Wed, 18 May 2022 14:14:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrOAU-0007oK-7h for guix-patches@gnu.org; Wed, 18 May 2022 14:13:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nrOAT-0005E4-Us for guix-patches@gnu.org; Wed, 18 May 2022 14:13:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nrOAT-0006MM-Pn for guix-patches@gnu.org; Wed, 18 May 2022 14:13:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55030] [PATCH v2 08/34] import: json: Accept '#:http-fetch' in 'json-fetch'. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 18 May 2022 18:13:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55030 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55030@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Philip McGrath Received: via spool by 55030-submit@debbugs.gnu.org id=B55030.165289756424278 (code B ref 55030); Wed, 18 May 2022 18:13:05 +0000 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 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 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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)