Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: net/tools/testserver/testserver.py

Issue 11299307: Handle broken pipe errors in Python testserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/ppapi/ppapi_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/testserver.py
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 9c5468df88cc24fec554b7b513679d5d6bd14f64..4f97587504500ab8879742bd9b55f06613cca510 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -113,6 +113,27 @@ class ClientRestrictingServerMixIn:
return client_address[0] == self.server_address[0]
+class BrokenPipeHandlerMixIn:
+ """Allows the server to deal with "broken pipe" errors (which happen if the
+ browser quits with outstanding requests, like for the favicon). This mix-in
+ requires the class to derive from SocketServer.BaseServer and not override its
+ handle_error() method. """
+
+ def handle_error(self, request, client_address):
+ value = sys.exc_info()[1]
+ if isinstance(value, socket.error):
+ err = value.args[0]
+ if sys.platform in ('win32', 'cygwin'):
+ # "An established connection was aborted by the software in your host."
+ pipe_err = 10053
+ else:
+ pipe_err = errno.EPIPE
+ if err == pipe_err:
+ print "testserver.py: Broken pipe"
+ return
+ SocketServer.BaseServer.handle_error(self, request, client_address)
+
+
class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
"""This is a specialization of BaseHTTPServer to allow it
to be exited cleanly (by setting its "stop" member to True)."""
@@ -125,13 +146,17 @@ class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
self.socket.close()
-class HTTPServer(ClientRestrictingServerMixIn, StoppableHTTPServer):
+class HTTPServer(ClientRestrictingServerMixIn,
+ BrokenPipeHandlerMixIn,
+ StoppableHTTPServer):
"""This is a specialization of StoppableHTTPServer that adds client
verification."""
pass
-class OCSPServer(ClientRestrictingServerMixIn, BaseHTTPServer.HTTPServer):
+class OCSPServer(ClientRestrictingServerMixIn,
+ BrokenPipeHandlerMixIn,
+ BaseHTTPServer.HTTPServer):
"""This is a specialization of HTTPServer that serves an
OCSP response"""
@@ -147,6 +172,7 @@ class OCSPServer(ClientRestrictingServerMixIn, BaseHTTPServer.HTTPServer):
class HTTPSServer(tlslite.api.TLSSocketServerMixIn,
ClientRestrictingServerMixIn,
+ BrokenPipeHandlerMixIn,
StoppableHTTPServer):
"""This is a specialization of StoppableHTTPServer that add https support and
client verification."""
@@ -198,7 +224,9 @@ class HTTPSServer(tlslite.api.TLSSocketServerMixIn,
return False
-class SyncHTTPServer(ClientRestrictingServerMixIn, StoppableHTTPServer):
+class SyncHTTPServer(ClientRestrictingServerMixIn,
+ BrokenPipeHandlerMixIn,
+ StoppableHTTPServer):
"""An HTTP server that handles sync commands."""
def __init__(self, server_address, xmpp_port, request_handler_class):
« no previous file with comments | « chrome/test/ppapi/ppapi_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698