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

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

Issue 155897: Add support to URLRequest for deferring redirects.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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
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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 return True 563 return True
564 564
565 def FileHandler(self): 565 def FileHandler(self):
566 """This handler sends the contents of the requested file. Wow, it's like 566 """This handler sends the contents of the requested file. Wow, it's like
567 a real webserver!""" 567 a real webserver!"""
568 568
569 prefix = self.server.file_root_url 569 prefix = self.server.file_root_url
570 if not self.path.startswith(prefix): 570 if not self.path.startswith(prefix):
571 return False 571 return False
572 572
573 # Consume a request body if present.
574 if self.command == 'POST':
575 self.rfile.read(int(self.headers.getheader('content-length')))
576
573 file = self.path[len(prefix):] 577 file = self.path[len(prefix):]
574 entries = file.split('/'); 578 entries = file.split('/');
575 path = os.path.join(self.server.data_dir, *entries) 579 path = os.path.join(self.server.data_dir, *entries)
576 if os.path.isdir(path): 580 if os.path.isdir(path):
577 path = os.path.join(path, 'index.html') 581 path = os.path.join(path, 'index.html')
578 582
579 if not os.path.isfile(path): 583 if not os.path.isfile(path):
580 print "File not found " + file + " full path:" + path 584 print "File not found " + file + " full path:" + path
581 self.send_error(404) 585 self.send_error(404)
582 return True 586 return True
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 help='Directory from which to read the files') 1108 help='Directory from which to read the files')
1105 option_parser.add_option('', '--https', dest='cert', 1109 option_parser.add_option('', '--https', dest='cert',
1106 help='Specify that https should be used, specify ' 1110 help='Specify that https should be used, specify '
1107 'the path to the cert containing the private key ' 1111 'the path to the cert containing the private key '
1108 'the server should use') 1112 'the server should use')
1109 option_parser.add_option('', '--file-root-url', default='/files/', 1113 option_parser.add_option('', '--file-root-url', default='/files/',
1110 help='Specify a root URL for files served.') 1114 help='Specify a root URL for files served.')
1111 options, args = option_parser.parse_args() 1115 options, args = option_parser.parse_args()
1112 1116
1113 sys.exit(main(options, args)) 1117 sys.exit(main(options, args))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698