diff options
| author | cce <devnull@localhost> | 2006-03-05 18:10:49 +0000 |
|---|---|---|
| committer | cce <devnull@localhost> | 2006-03-05 18:10:49 +0000 |
| commit | a608db52d74ef32c320fc3f8fe90f3999a316464 (patch) | |
| tree | 2d601b5fcc1876c68e29d2597ab4689cef0c58b5 /paste/httpserver.py | |
| parent | dd773fe825717fc753ba282222efbfb0af57d6cf (diff) | |
| download | paste-a608db52d74ef32c320fc3f8fe90f3999a316464.tar.gz | |
There are class of unavoidable socket errors that occur when
users click STOP or close their browsers during a SSL connection;
unfortunately pyOpenSSL didn't subclass socket.error for these
classes -- so we put in a work-around.
Diffstat (limited to 'paste/httpserver.py')
| -rwxr-xr-x | paste/httpserver.py | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/paste/httpserver.py b/paste/httpserver.py index 0930ced..fb9f793 100755 --- a/paste/httpserver.py +++ b/paste/httpserver.py @@ -226,22 +226,6 @@ class WSGIHandlerMixin: self.wsgi_write_chunk("Internal Server Error\n") raise -class WSGIHandler(WSGIHandlerMixin, BaseHTTPRequestHandler): - """ - A WSGI handler that overrides POST, GET and HEAD to delegate - requests to the server's ``wsgi_application``. - """ - server_version = 'PasteWSGIServer/' + __version__ - do_POST = do_GET = do_HEAD = do_DELETE = do_PUT = do_TRACE = \ - WSGIHandlerMixin.wsgi_execute - - def handle(self): - # don't bother logging disconnects while handling a request - try: - BaseHTTPRequestHandler.handle(self) - except socket.error, exce: - self.wsgi_connection_drop(exce) - # # SSL Functionality # @@ -250,10 +234,12 @@ class WSGIHandler(WSGIHandlerMixin, BaseHTTPRequestHandler): # try: from OpenSSL import SSL + SocketErrors = (socket.error, SSL.ZeroReturnError, SSL.SysCallError) except ImportError: # Do not require pyOpenSSL to be installed, but disable SSL # functionality in that case. SSL = None + SocketErrors = (socket.error,) class SecureHTTPServer(HTTPServer): def __init__(self, server_address, RequestHandlerClass, ssl_context=None): @@ -306,6 +292,22 @@ else: conn = _ConnFixer(conn) return (conn,info) +class WSGIHandler(WSGIHandlerMixin, BaseHTTPRequestHandler): + """ + A WSGI handler that overrides POST, GET and HEAD to delegate + requests to the server's ``wsgi_application``. + """ + server_version = 'PasteWSGIServer/' + __version__ + do_POST = do_GET = do_HEAD = do_DELETE = do_PUT = do_TRACE = \ + WSGIHandlerMixin.wsgi_execute + + def handle(self): + # don't bother logging disconnects while handling a request + try: + BaseHTTPRequestHandler.handle(self) + except SocketErrors, exce: + self.wsgi_connection_drop(exce) + class WSGIServer(ThreadingMixIn, SecureHTTPServer): daemon_threads = False |
