io.sockets.secure.unix: fix socket shutdown handling to make http.client work with https://www.google.com

db4
Slava Pestov 2011-01-31 23:45:45 -05:00
parent cc06c4e51f
commit 4270c6cce6
1 changed files with 10 additions and 6 deletions

View File

@ -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