Subject: Re: bug#53923: ‘http-fetch’ is unable to fetch <https://repology.org/api/v1/project/emacs:modus-themes>

From: Ludovic Courtès <[email-masked]>
Date: Wed, 16 Feb 2022 15:42:43 +0100

Hi,

Xinglu Chen <[email-masked]> skribis:

> scheme@(guile-user)> ,use(guix http-client)
> scheme@(guile-user)> (http-fetch "https://repology.org/api/v1/project/emacs:modus-themes")
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Bad Read-Header-Line header: #<eof>
>
>
> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
> scheme@(guile-user) [1]> ,bt
> In guix/http-client.scm:
>    120:21  5 (http-fetch _ #:port _ #:text? _ #:buffered? _ # _ # _ # …)
> In web/client.scm:
>    530:24  4 (http-request _ #:body _ #:verify-certificate? _ #:port …)
> In web/response.scm:
>    198:31  3 (read-response #<input-output: string 7f7bb290c0e0>)
> In web/http.scm:
>   1188:15  2 (read-response-line _)
>     250:2  1 (read-header-line _)
> In ice-9/boot-9.scm:
>   1685:16  0 (raise-exception _ #:continuable? _)
>
>
> The URL opens just fine in Icecat.  ‘http-request’ from (web client) is
> able to handle it as well.

It works if you strip the ‘User-Agent’ header that ‘http-fetch’ provides
by default:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(guix http-client)
scheme@(guile-user)> (http-fetch "https://repology.org/api/v1/project/emacs:modus-themes" #:headers '())
$13 = #<input: file 7fdd94cb5930>
$14 = 1342
scheme@(guile-user)> ,use(rnrs io ports)
scheme@(guile-user)> (get-string-all $13)
--8<---------------cut here---------------end--------------->8---

Thanks,
Ludo’.