From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id mJONKBUW/l8DHAAA0tVLHw (envelope-from ) for ; Tue, 12 Jan 2021 21:35:17 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id CNJgJBUW/l/DNAAAB5/wlQ (envelope-from ) for ; Tue, 12 Jan 2021 21:35:17 +0000 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 1EF15940355 for ; Tue, 12 Jan 2021 21:35:15 +0000 (UTC) Received: from localhost ([::1]:42558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzRJp-0006ol-Og for larch@yhetil.org; Tue, 12 Jan 2021 16:35:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzRJe-0006o0-7Q for bug-guix@gnu.org; Tue, 12 Jan 2021 16:35:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:50163) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzRJd-0002pE-Uy for bug-guix@gnu.org; Tue, 12 Jan 2021 16:35:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kzRJd-00046K-R5 for bug-guix@gnu.org; Tue, 12 Jan 2021 16:35:01 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#45174: =?UTF-8?Q?=E2=80=98guix_?= =?UTF-8?Q?substitute=E2=80=99_?= =?UTF-8?Q?doesn=E2=80=99t?= handle HTTP redirects Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 12 Jan 2021 21:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45174 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Julien Lepiller , Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 45174-submit@debbugs.gnu.org id=B45174.161048724515697 (code B ref 45174); Tue, 12 Jan 2021 21:35:01 +0000 Received: (at 45174) by debbugs.gnu.org; 12 Jan 2021 21:34:05 +0000 Received: from localhost ([127.0.0.1]:33476 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kzRIj-000456-9l for submit@debbugs.gnu.org; Tue, 12 Jan 2021 16:34:05 -0500 Received: from world.peace.net ([64.112.178.59]:39494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kzRIg-00044Z-34 for 45174@debbugs.gnu.org; Tue, 12 Jan 2021 16:34:04 -0500 Received: from mhw by world.peace.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kzRIX-0006RT-Dr; Tue, 12 Jan 2021 16:33:53 -0500 From: Mark H Weaver In-Reply-To: <20210112181155.05b7992d@tachikoma.lepiller.eu> References: <87a6uk8ydv.fsf@inria.fr> <20210112181155.05b7992d@tachikoma.lepiller.eu> Date: Tue, 12 Jan 2021 16:32:39 -0500 Message-ID: <87pn294z8t.fsf@netris.org> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 45174@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.36 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: 1EF15940355 X-Spam-Score: -2.36 X-Migadu-Scanner: scn0.migadu.com X-TUID: PHjpgB2lvpyh Hi Julien, Julien Lepiller writes: > Here is a patch to fix that issue. Since ci.guix.info now returns 200, > it's difficult to test the patch. [...] [...] > From f20e01f2a8df538519660772a7431b53d650d64f Mon Sep 17 00:00:00 2001 > From: Julien Lepiller > Date: Tue, 12 Jan 2021 18:07:25 +0100 > Subject: [PATCH] substitute: Follow narinfo redirections. > > * guix/scripts/substitute.scm (fetch-narinfos): Follow redirections. > --- > guix/scripts/substitute.scm | 38 +++++++++++++++++++++++++++---------- > 1 file changed, 28 insertions(+), 10 deletions(-) > > diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm > index e53de8c304..790168091e 100755 > --- a/guix/scripts/substitute.scm > +++ b/guix/scripts/substitute.scm > @@ -663,18 +663,36 @@ port to it, or, if connection failed, print a warning and return #f. Pass [...] > + ((301 302 303 307 308) ; redirect > + (let* ((uri (response-location response)) > + (new-request (build-request > + uri #:headers '((User-Agent . "GNU Guile"))))) > + (if len > + (get-bytevector-n port len) > + (read-to-eof port)) > + (append > + (http-multiple-get uri > + handle-narinfo-response '() > + (list new-request) > + #:open-connection > + open-connection-for-uri/cached > + #:verify-certificate? #f) > + result))) Granted, it's been almost six years since I first implemented proper HTTP redirects for Guix, but as I vaguely recall the URI in the response may be a relative URI or have some missing components, so in the general case it must be interpreted relative to the previous URI in accordance with RFC 3986 section 5.2. A proper implementation should use 'resolve-uri-reference' from (guix build download). Here's the original commit that added that function, and used it to fix HTTP redirection support in (guix http-client): https://git.savannah.gnu.org/cgit/guix.git/commit/?id=04dec194d8e460831ec0695a944d9c7313affea2 Also, keep in mind that multiple redirects may occur, so a proper implementation requires some kind of loop. I haven't looked closely enough at your code above to know whether that case is handled correctly. See the relevant code in (guix http-client) for hints. Anyway, thanks for working on it! Regards, Mark