http-client: Backport Guile fix for 'read-chunk-header'.
Fixes the wrong-type-arg exception initially reported at <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19976#5> by Ricardo Wurmus <rekado@elephly.net>. * guix/http-client.scm (read-chunk-header): Backport Guile commit 53b8d5f.
This commit is contained in:
parent
dd8d6d6547
commit
15d5ca1356
|
@ -25,6 +25,7 @@
|
||||||
#:use-module (srfi srfi-11)
|
#:use-module (srfi srfi-11)
|
||||||
#:use-module (srfi srfi-34)
|
#:use-module (srfi srfi-34)
|
||||||
#:use-module (srfi srfi-35)
|
#:use-module (srfi srfi-35)
|
||||||
|
#:use-module (ice-9 match)
|
||||||
#:use-module (rnrs io ports)
|
#:use-module (rnrs io ports)
|
||||||
#:use-module (rnrs bytevectors)
|
#:use-module (rnrs bytevectors)
|
||||||
#:use-module (guix ui)
|
#:use-module (guix ui)
|
||||||
|
@ -66,7 +67,8 @@
|
||||||
|
|
||||||
(when-guile<=2.0.5-or-otherwise-broken
|
(when-guile<=2.0.5-or-otherwise-broken
|
||||||
;; Backport of Guile commits 312e79f8 ("Add HTTP Chunked Encoding support to
|
;; Backport of Guile commits 312e79f8 ("Add HTTP Chunked Encoding support to
|
||||||
;; web modules.") and 00d3ecf2 ("http: Do not buffer HTTP chunks.")
|
;; web modules."), 00d3ecf2 ("http: Do not buffer HTTP chunks."), and 53b8d5f
|
||||||
|
;; ("web: Gracefully handle premature EOF when reading chunk header.")
|
||||||
|
|
||||||
(use-modules (ice-9 rdelim))
|
(use-modules (ice-9 rdelim))
|
||||||
|
|
||||||
|
@ -75,14 +77,21 @@
|
||||||
|
|
||||||
;; Chunked Responses
|
;; Chunked Responses
|
||||||
(define (read-chunk-header port)
|
(define (read-chunk-header port)
|
||||||
(let* ((str (read-line port))
|
"Read a chunk header from PORT and return the size in bytes of the
|
||||||
(extension-start (string-index str (lambda (c) (or (char=? c #\;)
|
upcoming chunk."
|
||||||
(char=? c #\return)))))
|
(match (read-line port)
|
||||||
(size (string->number (if extension-start ; unnecessary?
|
((? eof-object?)
|
||||||
(substring str 0 extension-start)
|
;; Connection closed prematurely: there's nothing left to read.
|
||||||
str)
|
0)
|
||||||
16)))
|
(str
|
||||||
size))
|
(let ((extension-start (string-index str
|
||||||
|
(lambda (c)
|
||||||
|
(or (char=? c #\;)
|
||||||
|
(char=? c #\return))))))
|
||||||
|
(string->number (if extension-start ; unnecessary?
|
||||||
|
(substring str 0 extension-start)
|
||||||
|
str)
|
||||||
|
16)))))
|
||||||
|
|
||||||
(define* (make-chunked-input-port port #:key (keep-alive? #f))
|
(define* (make-chunked-input-port port #:key (keep-alive? #f))
|
||||||
"Returns a new port which translates HTTP chunked transfer encoded
|
"Returns a new port which translates HTTP chunked transfer encoded
|
||||||
|
|
Loading…
Reference in New Issue