diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-04-01 00:41:55 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-04-01 00:41:55 +0200 |
commit | ef8c03407dce8d6ebdfcf53318ac9a09b5ee8461 (patch) | |
tree | aa4573cd0261ca0912d9ad9d819f87486fcbf756 /guix | |
parent | fdfd3d5d9c647876a0d7422b25fde1a6b8e9e654 (diff) | |
download | gnu-guix-ef8c03407dce8d6ebdfcf53318ac9a09b5ee8461.tar gnu-guix-ef8c03407dce8d6ebdfcf53318ac9a09b5ee8461.tar.gz |
gnu-maintenance: Adjust `http-fetch' to the various Guile versions.
* guix/gnu-maintenance.scm (http-fetch): Try #:streaming? #t, or
'http-get*', or 'http-get' as a last resort. Check whether DATA is
#f, a string, or an input port.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/gnu-maintenance.scm | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm index 979678d076..89e7f25589 100644 --- a/guix/gnu-maintenance.scm +++ b/guix/gnu-maintenance.scm @@ -66,12 +66,18 @@ (define (http-fetch uri) "Return an input port containing the textual data at URI, a string." (let*-values (((resp data) - (http-get (string->uri uri))) + (let ((uri (string->uri uri))) + ;; Try hard to use the API du jour to get an input port. + (if (version>? "2.0.7" (version)) + (if (defined? 'http-get*) + (http-get* uri) + (http-get uri)) ; old Guile, returns a string + (http-get uri #:streaming? #t)))) ; 2.0.8 or later ((code) (response-code resp))) (case code ((200) - (cond ((string<=? (version) "2.0.5") + (cond ((not data) (begin ;; XXX: Guile 2.0.5 and earlier did not support chunked transfer ;; encoding, which is required when fetching %PACKAGE-LIST-URL @@ -85,9 +91,10 @@ (response-transfer-encoding resp)) (error "download failed; use a newer Guile" uri resp))) - ((string<=? (version) "2.0.7") + ((string? data) ; old `http-get' returns a string (open-input-string data)) - (else data))) + (else ; input port + data))) (else (error "download failed" uri code (response-reason-phrase resp)))))) |