http-client: Provide 'User-Agent' header by default.

* guix/http-client.scm (http-fetch): Add #:headers parameter and honor
it.  Rename 'auth-header' to 'headers'.
* guix/import/github.scm (json-fetch*): Add comment about required
User-Agent.
This commit is contained in:
Ludovic Courtès 2017-01-13 18:22:53 +01:00
parent 4cd5ec801b
commit 608a50b66c
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 15 additions and 12 deletions

View file

@ -36,6 +36,7 @@
(guard (c ((and (http-get-error? c)
(= 404 (http-get-error-code c)))
#f)) ;"expected" if package is unknown
;; Note: github.com returns 403 if we omit a 'User-Agent' header.
(let* ((port (http-fetch url))
(result (json->scm port)))
(close-port port)