raco pkg: GitHub API now requires a User-Agent
Merge to v5.3.4
(cherry picked from commit 9d43fcad3e
)
This commit is contained in:
parent
2fea9c36fc
commit
861ef7f721
|
@ -48,8 +48,6 @@
|
||||||
(for/list ([v (in-list l)])
|
(for/list ([v (in-list l)])
|
||||||
(format "\n ~a" v)))))
|
(format "\n ~a" v)))))
|
||||||
|
|
||||||
(define-logger pkg)
|
|
||||||
|
|
||||||
(define (log-exn x what)
|
(define (log-exn x what)
|
||||||
(log-pkg-error (~a "failure ~a\n"
|
(log-pkg-error (~a "failure ~a\n"
|
||||||
" error: ~s")
|
" error: ~s")
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
net/url
|
net/url
|
||||||
json)
|
json)
|
||||||
|
|
||||||
|
(define-logger pkg)
|
||||||
|
|
||||||
(define (make-parent-directory* p)
|
(define (make-parent-directory* p)
|
||||||
(define parent (path-only p))
|
(define parent (path-only p))
|
||||||
(make-directory* parent))
|
(make-directory* parent))
|
||||||
|
@ -28,9 +30,11 @@
|
||||||
(make-string (+ (- width (string-length col)) 4) #\space))))
|
(make-string (+ (- width (string-length col)) 4) #\space))))
|
||||||
(printf "\n")))
|
(printf "\n")))
|
||||||
|
|
||||||
(define (call/input-url+200 u fun)
|
(define (call/input-url+200 u fun #:headers [headers '()])
|
||||||
#;(printf "\t\tReading ~a\n" (url->string u))
|
#;(printf "\t\tReading ~a\n" (url->string u))
|
||||||
(define-values (ip hs) (get-pure-port/headers u #:redirections 25 #:status? #t))
|
(define-values (ip hs) (get-pure-port/headers u headers
|
||||||
|
#:redirections 25
|
||||||
|
#:status? #t))
|
||||||
(and (string=? "200" (substring hs 9 12))
|
(and (string=? "200" (substring hs 9 12))
|
||||||
(fun ip)))
|
(fun ip)))
|
||||||
|
|
||||||
|
@ -56,10 +60,12 @@
|
||||||
(list "repos" user repo "branches"))
|
(list "repos" user repo "branches"))
|
||||||
query
|
query
|
||||||
#f))
|
#f))
|
||||||
|
(log-pkg-debug "Querying GitHub at ~a" (url->string api-u))
|
||||||
(define api-bs
|
(define api-bs
|
||||||
(call/input-url+200 api-u port->bytes))
|
(call/input-url+200 api-u port->bytes
|
||||||
|
#:headers (list (format "User-Agent: raco-pkg/~a" (version)))))
|
||||||
(unless api-bs
|
(unless api-bs
|
||||||
(error 'package-url->checksum
|
(error 'package-url->checksum
|
||||||
"Could not connect to GitHub"))
|
"Could not connect to GitHub"))
|
||||||
(define branches
|
(define branches
|
||||||
(read-json (open-input-bytes api-bs)))
|
(read-json (open-input-bytes api-bs)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user