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

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

Issue 171099: Merge r21417 to 172.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/172/src/
Patch Set: '' Created 11 years, 4 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
« no previous file with comments | « net/proxy/proxy_script_fetcher.cc ('k') | net/url_request/url_request.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/net/tools/testserver/testserver.py:r14162,15308,16015,16808,21417
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2008 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 return True 562 return True
563 563
564 def FileHandler(self): 564 def FileHandler(self):
565 """This handler sends the contents of the requested file. Wow, it's like 565 """This handler sends the contents of the requested file. Wow, it's like
566 a real webserver!""" 566 a real webserver!"""
567 567
568 prefix = self.server.file_root_url 568 prefix = self.server.file_root_url
569 if not self.path.startswith(prefix): 569 if not self.path.startswith(prefix):
570 return False 570 return False
571 571
572 # Consume a request body if present.
573 if self.command == 'POST':
574 self.rfile.read(int(self.headers.getheader('content-length')))
575
572 file = self.path[len(prefix):] 576 file = self.path[len(prefix):]
573 entries = file.split('/'); 577 entries = file.split('/');
574 path = os.path.join(self.server.data_dir, *entries) 578 path = os.path.join(self.server.data_dir, *entries)
575 if os.path.isdir(path): 579 if os.path.isdir(path):
576 path = os.path.join(path, 'index.html') 580 path = os.path.join(path, 'index.html')
577 581
578 if not os.path.isfile(path): 582 if not os.path.isfile(path):
579 print "File not found " + file + " full path:" + path 583 print "File not found " + file + " full path:" + path
580 self.send_error(404) 584 self.send_error(404)
581 return True 585 return True
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 help='Directory from which to read the files') 1107 help='Directory from which to read the files')
1104 option_parser.add_option('', '--https', dest='cert', 1108 option_parser.add_option('', '--https', dest='cert',
1105 help='Specify that https should be used, specify ' 1109 help='Specify that https should be used, specify '
1106 'the path to the cert containing the private key ' 1110 'the path to the cert containing the private key '
1107 'the server should use') 1111 'the server should use')
1108 option_parser.add_option('', '--file-root-url', default='/files/', 1112 option_parser.add_option('', '--file-root-url', default='/files/',
1109 help='Specify a root URL for files served.') 1113 help='Specify a root URL for files served.')
1110 options, args = option_parser.parse_args() 1114 options, args = option_parser.parse_args()
1111 1115
1112 sys.exit(main(options, args)) 1116 sys.exit(main(options, args))
OLDNEW
« no previous file with comments | « net/proxy/proxy_script_fetcher.cc ('k') | net/url_request/url_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698