diff options
author | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 23:29:37 +0000 |
---|---|---|
committer | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 23:29:37 +0000 |
commit | 62b907f417cfe14edadbba814d294535a3c0e87c (patch) | |
tree | 478706da520aa6102e43eec720a540c9a0e071b0 /net | |
parent | 980fe85bf5ca523ba6030091fb80e52bd0da5967 (diff) | |
download | chromium_src-62b907f417cfe14edadbba814d294535a3c0e87c.zip chromium_src-62b907f417cfe14edadbba814d294535a3c0e87c.tar.gz chromium_src-62b907f417cfe14edadbba814d294535a3c0e87c.tar.bz2 |
Retry r121912 downloads.onChanged
http://codereview.chromium.org/8203005/
Review URL: http://codereview.chromium.org/9395021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121966 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rwxr-xr-x | net/tools/testserver/testserver.py | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py index 12882b5..f280333 100755 --- a/net/tools/testserver/testserver.py +++ b/net/tools/testserver/testserver.py @@ -909,9 +909,6 @@ class TestPageHandler(BasePageHandler): prefix = self.server.file_root_url if not self.path.startswith(prefix): return False - # Consume a request body if present. - if self.command == 'POST' or self.command == 'PUT' : - self.ReadRequestBody() return self._FileHandlerHelper(prefix) def PostOnlyFileHandler(self): @@ -919,12 +916,33 @@ class TestPageHandler(BasePageHandler): prefix = urlparse.urljoin(self.server.file_root_url, 'post/') if not self.path.startswith(prefix): return False - self.ReadRequestBody() return self._FileHandlerHelper(prefix) def _FileHandlerHelper(self, prefix): - old_protocol_version = self.protocol_version + request_body = '' + if self.command == 'POST' or self.command == 'PUT': + # Consume a request body if present. + request_body = self.ReadRequestBody() + _, _, url_path, _, query, _ = urlparse.urlparse(self.path) + query_dict = cgi.parse_qs(query) + + expected_body = query_dict.get('expected_body', []) + if expected_body and request_body not in expected_body: + self.send_response(404) + self.end_headers() + self.wfile.write('') + return True + + expected_headers = query_dict.get('expected_headers', []) + for expected_header in expected_headers: + header_name, expected_value = expected_header.split(':') + if self.headers.getheader(header_name) != expected_value: + self.send_response(404) + self.end_headers() + self.wfile.write('') + return True + sub_path = url_path[len(prefix):] entries = sub_path.split('/') file_path = os.path.join(self.server.data_dir, *entries) @@ -942,6 +960,8 @@ class TestPageHandler(BasePageHandler): data = self._ReplaceFileData(data, query) + old_protocol_version = self.protocol_version + # If file.mock-http-headers exists, it contains the headers we # should send. Read them in and parse them. headers_path = file_path + '.mock-http-headers' |