Subject: Re: bug#19439: guix download fails with "bad qstring header component"

From: [email-masked] (Ludovic Courtès)
Date: Fri, 26 Dec 2014 23:27:19 +0100

rekado <[email-masked]> skribis:

> $ ./pre-inst-env guix download http://icedtea.wildebeest.org/hg/icepick/archive/15425b469aea.tar.gz
> starting download of `/tmp/guix-file.zrKNcT' from `http://icedtea.wildebeest.org/hg/icepick/archive/15425b469aea.tar.gz'...
> ERROR: Bad qstring header component: 1200667312.0

Indeed.  The HTTP headers here look like this:

--8<---------------cut here---------------start------------->8---
Date: Fri, 26 Dec 2014 22:10:49 GMT
Server: Apache/2.2.22 (Debian)
ETag: 1200667312.0
--8<---------------cut here---------------end--------------->8---

For details, this can be reproduced like this:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(web client)
scheme@(guile-user)> (http-get "http://icedtea.wildebeest.org/hg/icepick/archive/15425b469aea.tar.gz")
web/http.scm:854:12: In procedure parse-entity-tag:
web/http.scm:854:12: Bad qstring header component: 1200667312.0

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In web/client.scm:
    228:8  4 (request "http://icedtea.wildebeest.org/hg/icepick/archive/15425b469aea.tar.gz" #:body #f #:port #<input-output: s…> …)
In web/response.scm:
    199:6  3 (read-response #<input-output: socket 13>)
In web/http.scm:
   218:33  2 (lp ((server . "Apache/2.2.22 (Debian)") (date . #<date nanosecond: 0 second: 3 minute: 14 hour: 22 day: 26 mont…>)))
   188:11  1 (read-header #<input-output: socket 13>)
   854:12  0 (parse-entity-tag "1200667312.0")
--8<---------------cut here---------------end--------------->8---

And indeed, Section 14.19 of
<http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html> says that the
‘ETag’ header has type ‘entity-tag’.

‘parse-entity-tag’ is written like this:

--8<---------------cut here---------------start------------->8---
(define (parse-entity-tag val)
  (if (string-prefix? "W/" val)
      (cons (parse-qstring val 2) #f)
      (cons (parse-qstring val) #t)))
--8<---------------cut here---------------end--------------->8---

Section 3.11 at <http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html>
confirms the above definition for ‘entity-tag’.

Lastly, ‘quoted-string’ in
<http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html> is defined as a
string surrounded by double quotes, basically.

So, in short, I think Apache httpd is returning an invalid ETag header,
and Guile’s HTTP client is right in rejecting it.

Having said that doesn’t help much though.  I’m not sure how frequent
this is, and whether/how this could be worked around.  Ideas?

Thanks,
Ludo’.