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

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

Issue 9302024: Add client for background testing of HTTP pipelining. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use enum for test cases Created 8 years, 10 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 self.AuthDigestHandler, 371 self.AuthDigestHandler,
372 self.SlowServerHandler, 372 self.SlowServerHandler,
373 self.ChunkedServerHandler, 373 self.ChunkedServerHandler,
374 self.ContentTypeHandler, 374 self.ContentTypeHandler,
375 self.NoContentHandler, 375 self.NoContentHandler,
376 self.ServerRedirectHandler, 376 self.ServerRedirectHandler,
377 self.ClientRedirectHandler, 377 self.ClientRedirectHandler,
378 self.MultipartHandler, 378 self.MultipartHandler,
379 self.MultipartSlowHandler, 379 self.MultipartSlowHandler,
380 self.GetSSLSessionCacheHandler, 380 self.GetSSLSessionCacheHandler,
381 self.CloseSocketHandler,
381 self.DefaultResponseHandler] 382 self.DefaultResponseHandler]
382 post_handlers = [ 383 post_handlers = [
383 self.EchoTitleHandler, 384 self.EchoTitleHandler,
384 self.EchoHandler, 385 self.EchoHandler,
385 self.DeviceManagementHandler, 386 self.DeviceManagementHandler,
386 self.PostOnlyFileHandler] + get_handlers 387 self.PostOnlyFileHandler] + get_handlers
387 put_handlers = [ 388 put_handlers = [
388 self.EchoTitleHandler, 389 self.EchoTitleHandler,
389 self.EchoHandler] + get_handlers 390 self.EchoHandler] + get_handlers
390 head_handlers = [ 391 head_handlers = [
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 self.send_header('Content-Type', 'text/plain') 1421 self.send_header('Content-Type', 'text/plain')
1421 self.end_headers() 1422 self.end_headers()
1422 try: 1423 try:
1423 for (action, sessionID) in self.server.session_cache.log: 1424 for (action, sessionID) in self.server.session_cache.log:
1424 self.wfile.write('%s\t%s\n' % (action, sessionID.encode('hex'))) 1425 self.wfile.write('%s\t%s\n' % (action, sessionID.encode('hex')))
1425 except AttributeError, e: 1426 except AttributeError, e:
1426 self.wfile.write('Pass --https-record-resume in order to use' + 1427 self.wfile.write('Pass --https-record-resume in order to use' +
1427 ' this request') 1428 ' this request')
1428 return True 1429 return True
1429 1430
1431 def CloseSocketHandler(self):
1432 """Closes the socket without sending anything."""
1433
1434 if not self._ShouldHandleRequest('/close-socket'):
1435 return False
1436
1437 self.wfile.close()
1438 return True
1439
1430 def DefaultResponseHandler(self): 1440 def DefaultResponseHandler(self):
1431 """This is the catch-all response handler for requests that aren't handled 1441 """This is the catch-all response handler for requests that aren't handled
1432 by one of the special handlers above. 1442 by one of the special handlers above.
1433 Note that we specify the content-length as without it the https connection 1443 Note that we specify the content-length as without it the https connection
1434 is not closed properly (and the browser keeps expecting data).""" 1444 is not closed properly (and the browser keeps expecting data)."""
1435 1445
1436 contents = "Default response given for path: " + self.path 1446 contents = "Default response given for path: " + self.path
1437 self.send_response(200) 1447 self.send_response(200)
1438 self.send_header('Content-Type', 'text/html') 1448 self.send_header('Content-Type', 'text/html')
1439 self.send_header('Content-Length', len(contents)) 1449 self.send_header('Content-Length', len(contents))
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 'random key if none is specified on the command ' 2015 'random key if none is specified on the command '
2006 'line.') 2016 'line.')
2007 option_parser.add_option('', '--policy-user', default='user@example.com', 2017 option_parser.add_option('', '--policy-user', default='user@example.com',
2008 dest='policy_user', 2018 dest='policy_user',
2009 help='Specify the user name the server should ' 2019 help='Specify the user name the server should '
2010 'report back to the client as the user owning the ' 2020 'report back to the client as the user owning the '
2011 'token used for making the policy request.') 2021 'token used for making the policy request.')
2012 options, args = option_parser.parse_args() 2022 options, args = option_parser.parse_args()
2013 2023
2014 sys.exit(main(options, args)) 2024 sys.exit(main(options, args))
OLDNEW
« chrome/browser/net/http_pipelining_compatibility_client.cc ('K') | « net/base/net_error_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698