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

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

Issue 4664009: All SSL UI tests work with ephemeral ports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows compile Created 10 years, 1 month 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
« net/test/test_server.cc ('K') | « net/test/test_server.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) 2006-2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2010 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 server used for testing Chrome. 6 """This is a simple HTTP 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 It defaults to living on localhost:8888. 9 It defaults to living on localhost:8888.
10 It can use https if you specify the flag --https=CERT where CERT is the path 10 It can use https if you specify the flag --https=CERT where CERT is the path
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 self.server.waitForDownload = False 569 self.server.waitForDownload = False
570 self.send_response(200) 570 self.send_response(200)
571 self.send_header('Content-type', 'text/html') 571 self.send_header('Content-type', 'text/html')
572 self.send_header('Cache-Control', 'max-age=0') 572 self.send_header('Cache-Control', 'max-age=0')
573 self.end_headers() 573 self.end_headers()
574 return True 574 return True
575 575
576 def _ReplaceFileData(self, data, query_parameters): 576 def _ReplaceFileData(self, data, query_parameters):
577 """Replaces matching substrings in a file. 577 """Replaces matching substrings in a file.
578 578
579 If the 'replace_orig' and 'replace_new' URL query parameters are present, 579 If the 'replace_text' URL query parameter is present, it is expected to be
580 a new string is returned with all occasions of the 'replace_orig' value 580 of the form old_text:new_text, which indicates that any old_text strings in
581 replaced by the 'replace_new' value. 581 the file are replaced with new_text. Multiple 'replace_text' parameters may
582 be specified.
582 583
583 If the parameters are not present, |data| is returned. 584 If the parameters are not present, |data| is returned.
584 """ 585 """
585 query_dict = cgi.parse_qs(query_parameters) 586 query_dict = cgi.parse_qs(query_parameters)
586 orig_values = query_dict.get('replace_orig', []) 587 replace_text_values = query_dict.get('replace_text', [])
587 new_values = query_dict.get('replace_new', []) 588 # TODO(cbentzel): Do all string substitutions in one pass? There are
akalin 2010/11/11 05:20:54 i don't think doing it in one pass is worth it; i
Paweł Hajdan Jr. 2010/11/11 10:40:45 Yeah.
cbentzel 2010/11/11 15:34:09 Done.
588 if not orig_values or not new_values: 589 # not many tests which require multiple string substitutions.
589 return data 590 for replace_text_value in replace_text_values:
590 orig_value = orig_values[0] 591 replace_text_args = replace_text_value.split(':')
591 new_value = new_values[0] 592 if len(replace_text_args) != 2:
akalin 2010/11/11 05:20:54 add warning here?
Paweł Hajdan Jr. 2010/11/11 10:40:45 Just make it explode with an exception, to make su
cbentzel 2010/11/11 15:34:09 Done.
592 return data.replace(orig_value, new_value) 593 continue
594 old_text_b64, new_text_b64 = replace_text_args
595 old_text = base64.urlsafe_b64decode(old_text_b64)
596 new_text = base64.urlsafe_b64decode(new_text_b64)
597 data = data.replace(old_text, new_text)
598 return data
593 599
594 def FileHandler(self): 600 def FileHandler(self):
595 """This handler sends the contents of the requested file. Wow, it's like 601 """This handler sends the contents of the requested file. Wow, it's like
596 a real webserver!""" 602 a real webserver!"""
597 603
598 prefix = self.server.file_root_url 604 prefix = self.server.file_root_url
599 if not self.path.startswith(prefix): 605 if not self.path.startswith(prefix):
600 return False 606 return False
601 607
602 # Consume a request body if present. 608 # Consume a request body if present.
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 'option may appear multiple times, indicating ' 1280 'option may appear multiple times, indicating '
1275 'multiple algorithms should be enabled.'); 1281 'multiple algorithms should be enabled.');
1276 option_parser.add_option('', '--file-root-url', default='/files/', 1282 option_parser.add_option('', '--file-root-url', default='/files/',
1277 help='Specify a root URL for files served.') 1283 help='Specify a root URL for files served.')
1278 option_parser.add_option('', '--startup-pipe', type='int', 1284 option_parser.add_option('', '--startup-pipe', type='int',
1279 dest='startup_pipe', 1285 dest='startup_pipe',
1280 help='File handle of pipe to parent process') 1286 help='File handle of pipe to parent process')
1281 options, args = option_parser.parse_args() 1287 options, args = option_parser.parse_args()
1282 1288
1283 sys.exit(main(options, args)) 1289 sys.exit(main(options, args))
OLDNEW
« net/test/test_server.cc ('K') | « net/test/test_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698