Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import BaseHTTPServer | 5 import BaseHTTPServer |
| 6 import errno | 6 import errno |
| 7 import json | 7 import json |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| 11 import socket | 11 import socket |
| 12 import SocketServer | 12 import SocketServer |
| 13 import struct | 13 import struct |
| 14 import sys | 14 import sys |
| 15 import warnings | 15 import warnings |
| 16 | 16 |
| 17 import tlslite.errors | |
| 18 | |
| 17 # Ignore deprecation warnings, they make our output more cluttered. | 19 # Ignore deprecation warnings, they make our output more cluttered. |
| 18 warnings.filterwarnings("ignore", category=DeprecationWarning) | 20 warnings.filterwarnings("ignore", category=DeprecationWarning) |
| 19 | 21 |
| 20 if sys.platform == 'win32': | 22 if sys.platform == 'win32': |
| 21 import msvcrt | 23 import msvcrt |
| 22 | 24 |
| 23 # Using debug() seems to cause hangs on XP: see http://crbug.com/64515. | 25 # Using debug() seems to cause hangs on XP: see http://crbug.com/64515. |
| 24 debug_output = sys.stderr | 26 debug_output = sys.stderr |
| 25 def debug(string): | 27 def debug(string): |
| 26 debug_output.write(string + "\n") | 28 debug_output.write(string + "\n") |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 | 66 |
| 65 | 67 |
| 66 class BrokenPipeHandlerMixIn: | 68 class BrokenPipeHandlerMixIn: |
| 67 """Allows the server to deal with "broken pipe" errors (which happen if the | 69 """Allows the server to deal with "broken pipe" errors (which happen if the |
| 68 browser quits with outstanding requests, like for the favicon). This mix-in | 70 browser quits with outstanding requests, like for the favicon). This mix-in |
| 69 requires the class to derive from SocketServer.BaseServer and not override its | 71 requires the class to derive from SocketServer.BaseServer and not override its |
| 70 handle_error() method. """ | 72 handle_error() method. """ |
| 71 | 73 |
| 72 def handle_error(self, request, client_address): | 74 def handle_error(self, request, client_address): |
| 73 value = sys.exc_info()[1] | 75 value = sys.exc_info()[1] |
| 76 if isinstance(value, tlslite.errors.TLSClosedConnectionError): | |
|
davidben
2014/04/08 01:09:19
rsleevi: This is the issue you forwarded to me; to
| |
| 77 print "testserver.py: Closed connection" | |
| 78 return | |
| 74 if isinstance(value, socket.error): | 79 if isinstance(value, socket.error): |
| 75 err = value.args[0] | 80 err = value.args[0] |
| 76 if sys.platform in ('win32', 'cygwin'): | 81 if sys.platform in ('win32', 'cygwin'): |
| 77 # "An established connection was aborted by the software in your host." | 82 # "An established connection was aborted by the software in your host." |
| 78 pipe_err = 10053 | 83 pipe_err = 10053 |
| 79 else: | 84 else: |
| 80 pipe_err = errno.EPIPE | 85 pipe_err = errno.EPIPE |
| 81 if err == pipe_err: | 86 if err == pipe_err: |
| 82 print "testserver.py: Broken pipe" | 87 print "testserver.py: Broken pipe" |
| 83 return | 88 return |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 fd = msvcrt.open_osfhandle(self.options.startup_pipe, 0) | 246 fd = msvcrt.open_osfhandle(self.options.startup_pipe, 0) |
| 242 else: | 247 else: |
| 243 fd = self.options.startup_pipe | 248 fd = self.options.startup_pipe |
| 244 startup_pipe = os.fdopen(fd, "w") | 249 startup_pipe = os.fdopen(fd, "w") |
| 245 # First write the data length as an unsigned 4-byte value. This | 250 # First write the data length as an unsigned 4-byte value. This |
| 246 # is _not_ using network byte ordering since the other end of the | 251 # is _not_ using network byte ordering since the other end of the |
| 247 # pipe is on the same machine. | 252 # pipe is on the same machine. |
| 248 startup_pipe.write(struct.pack('=L', server_data_len)) | 253 startup_pipe.write(struct.pack('=L', server_data_len)) |
| 249 startup_pipe.write(server_data_json) | 254 startup_pipe.write(server_data_json) |
| 250 startup_pipe.close() | 255 startup_pipe.close() |
| OLD | NEW |