unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Hartmut Goebel <h.goebel@crazy-compilers.com>
To: 44906@debbugs.gnu.org, 49483@debbugs.gnu.org
Subject: [bug#49483] [PATCH 2/3] substitutes: Properly construct URLs.
Date: Fri,  9 Jul 2021 10:38:39 +0200	[thread overview]
Message-ID: <26c8bb31c4d468e770e35cd743aca736f5ccd093.1625819848.git.h.goebel@crazy-compilers.com> (raw)
In-Reply-To: <d9544a84ebfc8a7bf3bc628aa15ab8c81b4a7bbd.1625819848.git.h.goebel@crazy-compilers.com>

Use relative URIs and "resolve-uri-reference" (which implements the algorithm
specified in RFC 3986 section 5.2.2) for building the URL, instead of just
appending strings. This avoids issued if the cache-url ends with a slash.

* guix/substitutes.scm (narinfo-request): Use resolve-uri-reference for
  constructing the url.
---
 guix/substitutes.scm | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/guix/substitutes.scm b/guix/substitutes.scm
index 4987cda165..a5c554acff 100644
--- a/guix/substitutes.scm
+++ b/guix/substitutes.scm
@@ -37,7 +37,8 @@
   #:use-module ((guix build utils) #:select (mkdir-p dump-port))
   #:use-module ((guix build download)
                 #:select ((open-connection-for-uri
-                           . guix:open-connection-for-uri)))
+                           . guix:open-connection-for-uri)
+                          resolve-uri-reference))
   #:use-module (guix progress)
   #:use-module (ice-9 rdelim)
   #:use-module (ice-9 regex)
@@ -155,10 +156,12 @@ indicates that PATH is unavailable at CACHE-URL."
 
 (define (narinfo-request cache-url path)
   "Return an HTTP request for the narinfo of PATH at CACHE-URL."
-  (let ((url (string-append cache-url "/" (store-path-hash-part path)
-                            ".narinfo"))
-        (headers '((User-Agent . "GNU Guile"))))
-    (build-request (string->uri url) #:method 'GET #:headers headers)))
+  (let* ((base (string->uri cache-url))
+         (ref (build-relative-ref
+               #:path (string-append (store-path-hash-part path) ".narinfo")))
+         (url (resolve-uri-reference ref base))
+         (headers '((User-Agent . "GNU Guile"))))
+    (build-request url #:method 'GET #:headers headers)))
 
 (define (narinfo-from-file file url)
   "Attempt to read a narinfo from FILE, using URL as the cache URL.  Return #f
-- 
2.30.2





  reply	other threads:[~2021-07-09  8:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09  8:38 [bug#49482] [PATCH 1/3] substitute: Fix handling of short option "-h" Hartmut Goebel
2021-07-09  8:38 ` Hartmut Goebel [this message]
2021-07-09  8:38 ` [bug#49482] [PATCH 3/3] ci: Properly construct URLs Hartmut Goebel
2021-07-15  7:35   ` Mathieu Othacehe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26c8bb31c4d468e770e35cd743aca736f5ccd093.1625819848.git.h.goebel@crazy-compilers.com \
    --to=h.goebel@crazy-compilers.com \
    --cc=44906@debbugs.gnu.org \
    --cc=49483@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).