def wrap(self, sock):
"""
Forced to overide since older cherrypy versions don't support
self.context. Once we require a version >= 3.2.3. This method
can be removed.
:param sock: Current socket.
:type sock: socket.socket
"""
try:
s = self.context.wrap_socket(sock, do_handshake_on_connect=True,
server_side=True)
# Copied from cherrypy/wsgiserver/ssl_builtin.py.
except ssl.SSLError:
e = sys.exc_info()[1]
if e.errno == ssl.SSL_ERROR_EOF:
# This is almost certainly due to the cherrypy engine
# 'pinging' the socket to assert it's connectable;
# the 'ping' isn't SSL.
return None, {}
elif e.errno == ssl.SSL_ERROR_SSL:
if e.args[1].endswith('http request'):
# The client is speaking HTTP to an HTTPS server.
raise wsgiserver.NoSSLError
elif e.args[1].endswith('unknown protocol'):
# The client is speaking some non-HTTP protocol.
# Drop the conn.
return None, {}
raise
return s, self.get_environ(s)
评论列表
文章目录