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

Side by Side Diff: net/tools/testserver/testserver.py

Issue 8044003: Fix a crash when loading a multipart html page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort Created 9 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/extensions/user_script_slave.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """This is a simple HTTP/FTP/SYNC/TCP/UDP/ server used for testing Chrome. 6 """This is a simple HTTP/FTP/SYNC/TCP/UDP/ server used for testing Chrome.
7 7
8 It supports several test URLs, as specified by the handlers in TestPageHandler. 8 It supports several test URLs, as specified by the handlers in TestPageHandler.
9 By default, it listens on an ephemeral port and sends the port number back to 9 By default, it listens on an ephemeral port and sends the port number back to
10 the originating process over a pipe. The originating process can specify an 10 the originating process over a pipe. The originating process can specify an
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 self.SetCookieHandler, 336 self.SetCookieHandler,
337 self.AuthBasicHandler, 337 self.AuthBasicHandler,
338 self.AuthDigestHandler, 338 self.AuthDigestHandler,
339 self.SlowServerHandler, 339 self.SlowServerHandler,
340 self.ChunkedServerHandler, 340 self.ChunkedServerHandler,
341 self.ContentTypeHandler, 341 self.ContentTypeHandler,
342 self.NoContentHandler, 342 self.NoContentHandler,
343 self.ServerRedirectHandler, 343 self.ServerRedirectHandler,
344 self.ClientRedirectHandler, 344 self.ClientRedirectHandler,
345 self.MultipartHandler, 345 self.MultipartHandler,
346 self.MultipartSlowHandler,
346 self.DefaultResponseHandler] 347 self.DefaultResponseHandler]
347 post_handlers = [ 348 post_handlers = [
348 self.EchoTitleHandler, 349 self.EchoTitleHandler,
349 self.EchoAllHandler, 350 self.EchoAllHandler,
350 self.EchoHandler, 351 self.EchoHandler,
351 self.DeviceManagementHandler] + get_handlers 352 self.DeviceManagementHandler] + get_handlers
352 put_handlers = [ 353 put_handlers = [
353 self.EchoTitleHandler, 354 self.EchoTitleHandler,
354 self.EchoAllHandler, 355 self.EchoAllHandler,
355 self.EchoHandler] + get_handlers 356 self.EchoHandler] + get_handlers
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 1304
1304 for i in xrange(num_frames): 1305 for i in xrange(num_frames):
1305 self.wfile.write('--' + bound + '\r\n') 1306 self.wfile.write('--' + bound + '\r\n')
1306 self.wfile.write('Content-type: text/html\r\n\r\n') 1307 self.wfile.write('Content-type: text/html\r\n\r\n')
1307 self.wfile.write('<title>page ' + str(i) + '</title>') 1308 self.wfile.write('<title>page ' + str(i) + '</title>')
1308 self.wfile.write('page ' + str(i)) 1309 self.wfile.write('page ' + str(i))
1309 1310
1310 self.wfile.write('--' + bound + '--') 1311 self.wfile.write('--' + bound + '--')
1311 return True 1312 return True
1312 1313
1314 def MultipartSlowHandler(self):
1315 """Send a multipart response (3 text/html pages) with a slight delay
1316 between each page. This is similar to how some pages show status using
1317 multipart."""
1318 test_name = "/multipart-slow"
eroman 2011/09/27 00:56:41 nit: for consistency use single quotemarks through
1319 if not self._ShouldHandleRequest(test_name):
1320 return False
1321
1322 num_frames = 3
1323 bound = '12345'
1324 self.send_response(200)
1325 self.send_header('Content-type',
1326 'multipart/x-mixed-replace;boundary=' + bound)
1327 self.end_headers()
1328
1329 for i in xrange(num_frames):
1330 self.wfile.write('--' + bound + '\r\n')
1331 self.wfile.write('Content-type: text/html\r\n\r\n')
1332 time.sleep(0.25)
1333 if i == 2:
1334 self.wfile.write('<title>PASS</title>')
1335 else:
1336 self.wfile.write('<title>page ' + str(i) + '</title>')
1337 self.wfile.write('page ' + str(i) + '<!-- ' + ('x' * 2048) + '-->')
1338
1339 self.wfile.write('--' + bound + '--')
1340 return True
1341
1313 def DefaultResponseHandler(self): 1342 def DefaultResponseHandler(self):
1314 """This is the catch-all response handler for requests that aren't handled 1343 """This is the catch-all response handler for requests that aren't handled
1315 by one of the special handlers above. 1344 by one of the special handlers above.
1316 Note that we specify the content-length as without it the https connection 1345 Note that we specify the content-length as without it the https connection
1317 is not closed properly (and the browser keeps expecting data).""" 1346 is not closed properly (and the browser keeps expecting data)."""
1318 1347
1319 contents = "Default response given for path: " + self.path 1348 contents = "Default response given for path: " + self.path
1320 self.send_response(200) 1349 self.send_response(200)
1321 self.send_header('Content-type', 'text/html') 1350 self.send_header('Content-type', 'text/html')
1322 self.send_header("Content-Length", len(contents)) 1351 self.send_header("Content-Length", len(contents))
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 'random key if none is specified on the command ' 1909 'random key if none is specified on the command '
1881 'line.') 1910 'line.')
1882 option_parser.add_option('', '--policy-user', default='user@example.com', 1911 option_parser.add_option('', '--policy-user', default='user@example.com',
1883 dest='policy_user', 1912 dest='policy_user',
1884 help='Specify the user name the server should ' 1913 help='Specify the user name the server should '
1885 'report back to the client as the user owning the ' 1914 'report back to the client as the user owning the '
1886 'token used for making the policy request.') 1915 'token used for making the policy request.')
1887 options, args = option_parser.parse_args() 1916 options, args = option_parser.parse_args()
1888 1917
1889 sys.exit(main(options, args)) 1918 sys.exit(main(options, args))
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/user_script_slave.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698