From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0DPaEpY3hWLiMgEAbAwnHQ (envelope-from ) for ; Wed, 18 May 2022 20:14:46 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id MJvbEpY3hWKKNgAA9RJhRA (envelope-from ) for ; Wed, 18 May 2022 20:14:46 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 05EA43FC19 for ; Wed, 18 May 2022 20:14:46 +0200 (CEST) Received: from localhost ([::1]:37956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrOC5-0000nU-6P for larch@yhetil.org; Wed, 18 May 2022 14:14:45 -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 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1652897686; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=hBgSEJ58Zdr4r33zt9FIFcJt1zauWUSnAuRcMyblxlg=; b=aEZDrLbm18NxowGleSy5GDihtrp98DY2fXnvsi7srgMBu6P6ne0miIAt/LtWVOu7NNeh+m Dn83qQ7xbxSPJeGlY+y9wWvwLHEK9+QU1oPX3p4zitJtHG2VSxh90+ZcmwKWHAbLpVDmAG 9cnRrtSf/KOFcLf5CJYW/TCwvu4vUr7lCcZf2MQlzWTEZIF5ri1SkiAMGertBbI7ynQLgY DPH/S9XB992tDZrQl3D2dv/GjSGqFkNbQzxhiUxGllrI5suYuB2ZLnX5thO2jQC8CeL1wh EZdwowX8+AkgUPxCrYoiupI1whJl6YuJ4shbnw2mIfPPGJso9AXFNJBbLTni7Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1652897686; a=rsa-sha256; cv=none; b=l1Zb6mzlwQx9GvOx5fxFL+6HvWF3/zvXU78Y9zSKNoHr55QGyXZ9r8RxWr1aW9LUTZVXxk P/g8K8NcXMIr2StBLVmoz5AdHYUuHR85Idnih+7lklGNO8NknIyi1STSIkqr2mKb+L/MRF BmQJpuS1lAiwy4FGWyd5aJMh52EHcaQwOp+Ff312SuCaTOsnsOQZCgULI9ikBXF4ZtixJt 7CQx6PD0NkOayfTQC3wT/QmFUXM5+Nw3/XiwzVwUyD0PoPD1fCoWUoFcCRyELB1fqZWalN mPsRhZ5FJ2Io6PmpTs+6r/NmnotwDuJslcp3KSH866ETWJLDKqQYHa+yRKPnvQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=VhlelX5e; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 2.96 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=VhlelX5e; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 05EA43FC19 X-Spam-Score: 2.96 X-Migadu-Scanner: scn0.migadu.com X-TUID: ag7ChIiF7PeP 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