http: Check the HTTP response code, and bail if not 200.
* guix/build/http.scm (http-fetch): Check RESP's code; error out when it's not 200.
This commit is contained in:
parent
7bdd1f0e3c
commit
e722af7522
|
@ -17,8 +17,9 @@
|
|||
;;; along with Guix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (guix build http)
|
||||
#:use-module (web client)
|
||||
#:use-module (web uri)
|
||||
#:use-module (web client)
|
||||
#:use-module (web response)
|
||||
#:use-module (rnrs io ports)
|
||||
#:use-module (srfi srfi-11)
|
||||
#:export (http-fetch))
|
||||
|
@ -83,8 +84,14 @@ which is not available during bootstrap."
|
|||
((connection)
|
||||
(open-connection-for-uri uri))
|
||||
((resp bv)
|
||||
(http-get uri #:port connection #:decode-body? #f)))
|
||||
(http-get uri #:port connection #:decode-body? #f))
|
||||
((code)
|
||||
(response-code resp)))
|
||||
(if (= 200 code)
|
||||
(begin
|
||||
(call-with-output-file file
|
||||
(lambda (p)
|
||||
(put-bytevector p bv))))
|
||||
(put-bytevector p bv)))
|
||||
file)
|
||||
(error "download failed" url
|
||||
code (response-reason-phrase resp)))))
|
||||
|
|
Loading…
Reference in New Issue