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

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

Issue 9307006: Fix PostOnlyFileHandler in testserver.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove debugging cruft 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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/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 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 prefix = self.server.file_root_url 908 prefix = self.server.file_root_url
909 if not self.path.startswith(prefix): 909 if not self.path.startswith(prefix):
910 return False 910 return False
911 # Consume a request body if present. 911 # Consume a request body if present.
912 if self.command == 'POST' or self.command == 'PUT' : 912 if self.command == 'POST' or self.command == 'PUT' :
913 self.ReadRequestBody() 913 self.ReadRequestBody()
914 return self._FileHandlerHelper(prefix) 914 return self._FileHandlerHelper(prefix)
915 915
916 def PostOnlyFileHandler(self): 916 def PostOnlyFileHandler(self):
917 """This handler sends the contents of the requested file on a POST.""" 917 """This handler sends the contents of the requested file on a POST."""
918 prefix = self.server.file_root_url + '/post/' 918 prefix = urlparse.urljoin(self.server.file_root_url, 'post/')
919 if not self.path.startswith(prefix): 919 if not self.path.startswith(prefix):
920 return False 920 return False
921 self.ReadRequestBody() 921 self.ReadRequestBody()
922 return self._FileHandlerHelper(prefix) 922 return self._FileHandlerHelper(prefix)
923 923
924 def _FileHandlerHelper(self, prefix): 924 def _FileHandlerHelper(self, prefix):
925 _, _, url_path, _, query, _ = urlparse.urlparse(self.path) 925 _, _, url_path, _, query, _ = urlparse.urlparse(self.path)
926 sub_path = url_path[len(prefix):] 926 sub_path = url_path[len(prefix):]
927 entries = sub_path.split('/') 927 entries = sub_path.split('/')
928 file_path = os.path.join(self.server.data_dir, *entries) 928 file_path = os.path.join(self.server.data_dir, *entries)
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 'random key if none is specified on the command ' 2005 'random key if none is specified on the command '
2006 'line.') 2006 'line.')
2007 option_parser.add_option('', '--policy-user', default='user@example.com', 2007 option_parser.add_option('', '--policy-user', default='user@example.com',
2008 dest='policy_user', 2008 dest='policy_user',
2009 help='Specify the user name the server should ' 2009 help='Specify the user name the server should '
2010 'report back to the client as the user owning the ' 2010 'report back to the client as the user owning the '
2011 'token used for making the policy request.') 2011 'token used for making the policy request.')
2012 options, args = option_parser.parse_args() 2012 options, args = option_parser.parse_args()
2013 2013
2014 sys.exit(main(options, args)) 2014 sys.exit(main(options, args))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698