guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/02: import: github: Catch HTTP 403 error during fetch.


From: Ludovic Courtès
Subject: 01/02: import: github: Catch HTTP 403 error during fetch.
Date: Thu, 19 Jan 2017 17:03:10 +0000 (UTC)

civodul pushed a commit to branch master
in repository guix.

commit d18b79fed895b9ca5cdb3a9a68c8e02bdaef30d8
Author: Mathieu OTHACEHE <address@hidden>
Date:   Tue Jan 17 09:17:30 2017 +0100

    import: github: Catch HTTP 403 error during fetch.
    
    * guix/import/github.scm (json-fetch*): Catch 403 HTTP error that may be
      raised if a github token has not been set.
    
    Signed-off-by: Mathieu OTHACEHE <address@hidden>
    Signed-off-by: Ludovic Courtès <address@hidden>
---
 guix/import/github.scm |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/guix/import/github.scm b/guix/import/github.scm
index df5a6b0..1e0bb53 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -32,10 +32,13 @@
 
 (define (json-fetch* url)
   "Return a representation of the JSON resource URL (a list or hash table), or
-#f if URL returns 404."
+#f if URL returns 403 or 404."
   (guard (c ((and (http-get-error? c)
-                  (= 404 (http-get-error-code c)))
-             #f))                       ;"expected" if package is unknown
+                  (let ((error (http-get-error-code c)))
+                    (or (= 403 error)
+                        (= 404 error))))
+             #f))     ;; "expected" if there is an authentification error 
(403),
+                      ;; or if package is unknown (404).
     ;; Note: github.com returns 403 if we omit a 'User-Agent' header.
     (let* ((port   (http-fetch url))
            (result (json->scm port)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]