diff options
author | Ludovic Courtès <ludo@gnu.org> | 2020-03-06 23:04:12 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2020-03-06 23:04:12 +0100 |
commit | 076276c4f580368b4106316a77752d69c8f1494a (patch) | |
tree | 9ff79d3e401dbd4c0f1911c27af93c58c6facc4c | |
parent | 8a25546a9458b8416d80bb80f925d0c1f11ec197 (diff) | |
download | guile-076276c4f580368b4106316a77752d69c8f1494a.tar.gz |
web: Client treats TLS "premature termination" error as EOF.
Fixes <https://bugs.gnu.org/39800>.
Reported by <franco.rcr@gmail.com>.
* module/web/client.scm (tls-wrap)[read!]: Catch 'gnutls-error around
'get-bytevector-some' call.
-rw-r--r-- | module/web/client.scm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/module/web/client.scm b/module/web/client.scm index 67d926f8a..769f3ecfa 100644 --- a/module/web/client.scm +++ b/module/web/client.scm @@ -243,7 +243,18 @@ host name without trailing dot." ;; underlying socket. (let ((record (session-record-port session))) (define (read! bv start count) - (define read-bv (get-bytevector-some record)) + (define read-bv + (catch 'gnutls-error + (lambda () + (get-bytevector-some record)) + (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-bv) 0 ; read! returns 0 on eof-object (let ((read-bv-len (bytevector-length read-bv))) |