summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-13 13:27:44 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-13 13:27:44 +0000
commit6b46031bc0d3071f6fdbd2c42ee8916454997662 (patch)
treec5dcf3a45f05c05d5ff519e8bd0362e5af3e59f3
parent171416b18e75a2de585fd3932a8c0883e9d19b05 (diff)
downloadchromium_src-6b46031bc0d3071f6fdbd2c42ee8916454997662.zip
chromium_src-6b46031bc0d3071f6fdbd2c42ee8916454997662.tar.gz
chromium_src-6b46031bc0d3071f6fdbd2c42ee8916454997662.tar.bz2
chrome.experimental.downloads.download works for non-GET methods.
This wasn't working because ResourceDispatcherHost::BeginDownload was overriding the method. I traced through all callers of BeginDownload and confirmed that the method did not need to be set. BUG=110044 TEST=DownloadsApiTest.Downloads [the downloadPost test case] Review URL: http://codereview.chromium.org/9148070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117637 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/test/data/extensions/api_test/downloads/test.js9
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host.cc1
-rwxr-xr-xnet/tools/testserver/testserver.py17
3 files changed, 22 insertions, 5 deletions
diff --git a/chrome/test/data/extensions/api_test/downloads/test.js b/chrome/test/data/extensions/api_test/downloads/test.js
index 8db4ed5..0a1368c 100644
--- a/chrome/test/data/extensions/api_test/downloads/test.js
+++ b/chrome/test/data/extensions/api_test/downloads/test.js
@@ -116,6 +116,15 @@ chrome.test.getConfig(function(testConfig) {
chrome.test.assertEq(getNextId(), id);
}));
},
+ function downloadPost() {
+ downloads.download(
+ {'url': getURL('files/post/downloads/a_zip_file.js'),
+ 'method': 'POST',
+ 'body': 'WOOHOO'},
+ chrome.test.callbackPass(function(id) {
+ chrome.test.assertEq(getNextId(), id);
+ }));
+ },
function downloadHeader() {
downloads.download(
{'url': SAFE_FAST_URL,
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc
index bc83325..daf0bd4 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc
@@ -896,7 +896,6 @@ void ResourceDispatcherHost::BeginDownload(
const GURL& url = request->original_url();
const net::URLRequestContext* request_context = context.request_context();
request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec());
- request->set_method("GET");
request->set_context(request_context);
request->set_load_flags(request->load_flags() |
net::LOAD_IS_DOWNLOAD | net::LOAD_DISABLE_CACHE);
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 35a08c4..b116e2e 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -382,7 +382,8 @@ class TestPageHandler(BasePageHandler):
post_handlers = [
self.EchoTitleHandler,
self.EchoHandler,
- self.DeviceManagementHandler] + get_handlers
+ self.DeviceManagementHandler,
+ self.PostOnlyFileHandler] + get_handlers
put_handlers = [
self.EchoTitleHandler,
self.EchoHandler] + get_handlers
@@ -904,15 +905,23 @@ class TestPageHandler(BasePageHandler):
def FileHandler(self):
"""This handler sends the contents of the requested file. Wow, it's like
a real webserver!"""
-
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):
+ """This handler sends the contents of the requested file on a POST."""
+ prefix = self.server.file_root_url + '/post/'
+ if not self.path.startswith(prefix):
+ return False
+ self.ReadRequestBody()
+ return self._FileHandlerHelper(prefix)
+ def _FileHandlerHelper(self, prefix):
_, _, url_path, _, query, _ = urlparse.urlparse(self.path)
sub_path = url_path[len(prefix):]
entries = sub_path.split('/')