Subject: bug#44906: Substitute requests fail if URL has trailing slash

From: Hartmut Goebel <[email-masked]>
Date: Fri, 27 Nov 2020 22:19:45 +0100

If the substitute-URL ends with a slash, api requests fail.

Expected behavior:

Substitute-URLs with and without trailing slash should behave the same.
This is especially true for substitute-URLs with empty path
("http://server") and path "/" (http://server/") - for which the RFCs
explicitly state to be equivalent.

According to RFC 7230, sec 2.7.3 "http and https URI Normalization and
Comparison" [1]:

   […] an empty
   path component is equivalent to an absolute path of "/", so the
   normal form is to provide a path of "/" instead.

[1] https://tools.ietf.org/html/rfc7230#section-2.7.3

How to reproduce:

no trailing slash:

$ guix weather --substitute-urls="https://ci.guix.gnu.org" gcc-toolchain
…
https://ci.guix.gnu.org
  100.0% substitutes available (3 out of 3)
…

Trailing slash:

$ guix weather --substitute-urls="https://ci.guix.gnu.org/" gcc-toolchain
…
https://ci.guix.gnu.org/
  0.0% substitutes available (0 out of 3)
…
  'https://ci.guix.gnu.org//api/queue?nr=1000' returned 400 ("Bad Request")

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | [email-masked]               |
| www.crazy-compilers.com | compilers which you thought are impossible |