From 4270c6cce6ea27e2b5a1f015bd2dc5f9f5c4f9d7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 31 Jan 2011 23:45:45 -0500 Subject: [PATCH] io.sockets.secure.unix: fix socket shutdown handling to make http.client work with https://www.google.com --- basis/io/sockets/secure/unix/unix.factor | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/basis/io/sockets/secure/unix/unix.factor b/basis/io/sockets/secure/unix/unix.factor index c856ef2bc8..4fe3b35721 100644 --- a/basis/io/sockets/secure/unix/unix.factor +++ b/basis/io/sockets/secure/unix/unix.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2010, Slava Pestov, Elie CHAFTARI. +! Copyright (C) 2007, 2011, Slava Pestov, Elie CHAFTARI. ! See http://factorcode.org/license.txt for BSD license. USING: accessors unix byte-arrays kernel sequences namespaces math math.order combinators init alien alien.c-types @@ -15,14 +15,18 @@ M: openssl ssl-supported? t ; M: ssl-handle handle-fd file>> handle-fd ; -: syscall-error ( r -- * ) - ERR_get_error dup zero? [ - drop +: syscall-error ( handle r -- event ) + nip + ERR_get_error [ { { -1 [ errno ECONNRESET = [ premature-close ] [ (io-error) ] if ] } - { 0 [ premature-close ] } + ! OpenSSL docs say this it is an error condition for + ! a server to not send a close notify, but web + ! servers in the wild don't seem to do this, for + ! example https://www.google.com. + { 0 [ f ] } } case - ] [ nip (ssl-error) ] if ; + ] [ nip (ssl-error) ] if-zero ; : check-accept-response ( handle r -- event ) over handle>> over SSL_get_error