download: 'tls-wrap' treats premature TLS termination as EOF.
This is a backport of Guile commit 076276c4f580368b4106316a77752d69c8f1494a. * guix/build/download.scm (tls-wrap)[read!]: Wrap 'get-bytevector-n!' call in 'catch' and handle 'error/premature-termination' GnuTLS errors.master
parent
1ab03fb745
commit
43937666ba
|
@ -305,10 +305,22 @@ host name without trailing dot."
|
||||||
|
|
||||||
(let ((record (session-record-port session)))
|
(let ((record (session-record-port session)))
|
||||||
(define (read! bv start count)
|
(define (read! bv start count)
|
||||||
(let ((read (get-bytevector-n! record bv start count)))
|
(define read
|
||||||
(if (eof-object? read)
|
(catch 'gnutls-error
|
||||||
0
|
(lambda ()
|
||||||
read)))
|
(get-bytevector-n! record bv start count))
|
||||||
|
(lambda (key err proc . rest)
|
||||||
|
;; When responding to "Connection: close" requests, some
|
||||||
|
;; servers close the connection abruptly after sending the
|
||||||
|
;; response body, without doing a proper TLS connection
|
||||||
|
;; termination. Treat it as EOF.
|
||||||
|
(if (eq? err error/premature-termination)
|
||||||
|
the-eof-object
|
||||||
|
(apply throw key err proc rest)))))
|
||||||
|
|
||||||
|
(if (eof-object? read)
|
||||||
|
0
|
||||||
|
read))
|
||||||
(define (write! bv start count)
|
(define (write! bv start count)
|
||||||
(put-bytevector record bv start count)
|
(put-bytevector record bv start count)
|
||||||
(force-output record)
|
(force-output record)
|
||||||
|
|
Reference in New Issue