Merge remote-tracking branch 'base/master'

This commit is contained in:
Marcelo Glezer 2015-02-05 11:29:53 -03:00
commit 5cbdd21a4b
2 changed files with 7 additions and 5 deletions

View File

@ -996,7 +996,7 @@ class HTTPHandler(ProtocolHandler):
include_body=False include_body=False
) )
break break
except (tcp.NetLibDisconnect, http.HttpErrorConnClosed), v: except (tcp.NetLibError, http.HttpErrorConnClosed), v:
self.c.log( self.c.log(
"error in server communication: %s" % repr(v), "error in server communication: %s" % repr(v),
level="debug" level="debug"
@ -1043,7 +1043,7 @@ class HTTPHandler(ProtocolHandler):
self.c.client_conn.rfile, self.c.client_conn.rfile,
body_size_limit=self.c.config.body_size_limit body_size_limit=self.c.config.body_size_limit
) )
except tcp.NetLibDisconnect: except tcp.NetLibError:
# don't throw an error for disconnects that happen # don't throw an error for disconnects that happen
# before/between requests. # before/between requests.
return False return False
@ -1141,7 +1141,7 @@ class HTTPHandler(ProtocolHandler):
message = repr(error) message = repr(error)
message_debug = None message_debug = None
if isinstance(error, tcp.NetLibDisconnect): if isinstance(error, tcp.NetLibError):
message = None message = None
message_debug = "TCP connection closed unexpectedly." message_debug = "TCP connection closed unexpectedly."
elif "tlsv1 alert unknown ca" in message: elif "tlsv1 alert unknown ca" in message:

View File

@ -3,6 +3,7 @@ import select
import socket import socket
from .primitives import ProtocolHandler from .primitives import ProtocolHandler
from netlib.utils import cleanBin from netlib.utils import cleanBin
from netlib.tcp import NetLibError
class TCPHandler(ProtocolHandler): class TCPHandler(ProtocolHandler):
@ -76,7 +77,8 @@ class TCPHandler(ProtocolHandler):
), ),
"info" "info"
) )
dst.connection.send(contents) # Do not use dst.connection.send here, which may raise OpenSSL-specific errors.
dst.send(contents)
else: else:
# socket.socket.send supports raw bytearrays/memoryviews # socket.socket.send supports raw bytearrays/memoryviews
if self.log: if self.log:
@ -87,6 +89,6 @@ class TCPHandler(ProtocolHandler):
"info" "info"
) )
dst.connection.send(buf[:size]) dst.connection.send(buf[:size])
except socket.error as e: except (socket.error, NetLibError) as e:
self.c.log("TCP connection closed unexpectedly.", "debug") self.c.log("TCP connection closed unexpectedly.", "debug")
return return