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.
This commit is contained in:
		
							parent
							
								
									f3b20baa4d
								
							
						
					
					
						commit
						ccdf7b8006
					
				
					 1 changed files with 8 additions and 5 deletions
				
			
		| 
						 | 
					@ -37,7 +37,8 @@
 | 
				
			||||||
  #:use-module ((guix build utils) #:select (mkdir-p dump-port))
 | 
					  #:use-module ((guix build utils) #:select (mkdir-p dump-port))
 | 
				
			||||||
  #:use-module ((guix build download)
 | 
					  #:use-module ((guix build download)
 | 
				
			||||||
                #:select ((open-connection-for-uri
 | 
					                #:select ((open-connection-for-uri
 | 
				
			||||||
                           . guix:open-connection-for-uri)))
 | 
					                           . guix:open-connection-for-uri)
 | 
				
			||||||
 | 
					                          resolve-uri-reference))
 | 
				
			||||||
  #:use-module (guix progress)
 | 
					  #:use-module (guix progress)
 | 
				
			||||||
  #:use-module (ice-9 rdelim)
 | 
					  #:use-module (ice-9 rdelim)
 | 
				
			||||||
  #:use-module (ice-9 regex)
 | 
					  #:use-module (ice-9 regex)
 | 
				
			||||||
| 
						 | 
					@ -155,10 +156,12 @@ indicates that PATH is unavailable at CACHE-URL."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define (narinfo-request cache-url path)
 | 
					(define (narinfo-request cache-url path)
 | 
				
			||||||
  "Return an HTTP request for the narinfo of PATH at CACHE-URL."
 | 
					  "Return an HTTP request for the narinfo of PATH at CACHE-URL."
 | 
				
			||||||
  (let ((url (string-append cache-url "/" (store-path-hash-part path)
 | 
					  (let* ((base (string->uri cache-url))
 | 
				
			||||||
                            ".narinfo"))
 | 
					         (ref (build-relative-ref
 | 
				
			||||||
        (headers '((User-Agent . "GNU Guile"))))
 | 
					               #:path (string-append (store-path-hash-part path) ".narinfo")))
 | 
				
			||||||
    (build-request (string->uri url) #:method 'GET #:headers headers)))
 | 
					         (url (resolve-uri-reference ref base))
 | 
				
			||||||
 | 
					         (headers '((User-Agent . "GNU Guile"))))
 | 
				
			||||||
 | 
					    (build-request url #:method 'GET #:headers headers)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define (narinfo-from-file file url)
 | 
					(define (narinfo-from-file file url)
 | 
				
			||||||
  "Attempt to read a narinfo from FILE, using URL as the cache URL.  Return #f
 | 
					  "Attempt to read a narinfo from FILE, using URL as the cache URL.  Return #f
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue