summaryrefslogtreecommitdiff
path: root/guix/substitutes.scm
diff options
context:
space:
mode:
authorHartmut Goebel <h.goebel@crazy-compilers.com>2021-07-08 00:45:41 +0200
committerHartmut Goebel <h.goebel@crazy-compilers.com>2021-07-16 19:36:11 +0200
commitccdf7b8006bd5173cd8ff7d2fe732fc171d38f5d (patch)
tree580aee1af00db61eb6ea86f4b7d3e8d34fc8520c /guix/substitutes.scm
parentf3b20baa4d1375d053bcadd9b804f52556142656 (diff)
substitutes: Properly construct URLs.
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.
Diffstat (limited to 'guix/substitutes.scm')
-rw-r--r--guix/substitutes.scm13
1 files 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