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

Unified Diff: net/tools/testserver/testserver.py

Issue 8203005: Implement chrome.experimental.downloads.onChanged (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/downloads/test.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/testserver.py
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index f9177897cc6e17b64a3fa075498365b96f0a7b81..380a217924c2234fffeb3df611a8a81dedb4f8d6 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -908,9 +908,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):
@@ -918,11 +915,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):
+ 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', [])
cbentzel 2012/02/14 00:58:46 Should the expected_body argument be base64 encode
benjhayden 2012/02/14 15:52:11 If somebody has a need for it, they can add it.
+ if expected_body and request_body not in expected_body:
cbentzel 2012/02/13 21:58:01 if request_body not in expected_body: should be su
benjhayden 2012/02/13 22:05:51 There are tests that do not specify expected_body,
cbentzel 2012/02/14 00:58:46 Yeah, my mistake. You could do expected_body
benjhayden 2012/02/14 15:52:11 It doesn't sound like there's a strong preference,
+ 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)
« no previous file with comments | « chrome/test/data/extensions/api_test/downloads/test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698