summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqinmin@chromium.org <qinmin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-10 04:18:20 +0000
committerqinmin@chromium.org <qinmin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-10 04:18:20 +0000
commit173f8e20d4b58db5d45dab905307b6ed1b072b85 (patch)
treeeac1a90b586ba8d68ebed1dfc1e61bb8027b21b2
parent9e70a74ab916161a471c026fed7d0ad41a2eeb8f (diff)
downloadchromium_src-173f8e20d4b58db5d45dab905307b6ed1b072b85.zip
chromium_src-173f8e20d4b58db5d45dab905307b6ed1b072b85.tar.gz
chromium_src-173f8e20d4b58db5d45dab905307b6ed1b072b85.tar.bz2
fix a problem that android cannot download files with basic authentication
Android download manager does not support authentication headers. This change adds a call to check if a url request contains authentication headers. If so, we fallback to chrome download path instead of using the download manager. BUG=159687 Review URL: https://chromiumcodereview.appspot.com/13609002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193318 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/android/intercept_download_resource_throttle.cc3
-rw-r--r--net/http/http_network_transaction.cc3
-rw-r--r--net/http/http_response_info.cc10
-rw-r--r--net/http/http_response_info.h3
4 files changed, 18 insertions, 1 deletions
diff --git a/chrome/browser/android/intercept_download_resource_throttle.cc b/chrome/browser/android/intercept_download_resource_throttle.cc
index 8f71890..331b392 100644
--- a/chrome/browser/android/intercept_download_resource_throttle.cc
+++ b/chrome/browser/android/intercept_download_resource_throttle.cc
@@ -34,7 +34,8 @@ void InterceptDownloadResourceThrottle::WillProcessResponse(bool* defer) {
}
void InterceptDownloadResourceThrottle::ProcessDownloadRequest() {
- if (request_->method() != net::HttpRequestHeaders::kGetMethod)
+ if (request_->method() != net::HttpRequestHeaders::kGetMethod ||
+ request_->response_info().did_use_http_auth)
return;
content::DownloadControllerAndroid::Get()->CreateGETDownload(
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 467eb94..417da19 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -774,6 +774,9 @@ void HttpNetworkTransaction::BuildRequestHeaders(bool using_proxy) {
&request_headers_);
request_headers_.MergeFrom(request_->extra_headers);
+ response_.did_use_http_auth =
+ request_headers_.HasHeader(HttpRequestHeaders::kAuthorization) ||
+ request_headers_.HasHeader(HttpRequestHeaders::kProxyAuthorization);
}
int HttpNetworkTransaction::DoInitRequestBody() {
diff --git a/net/http/http_response_info.cc b/net/http/http_response_info.cc
index e50a46f..a4d672d 100644
--- a/net/http/http_response_info.cc
+++ b/net/http/http_response_info.cc
@@ -84,6 +84,9 @@ enum {
// This bit is set if the response info has connection info.
RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18,
+ // This bit is set if the request has http authentication.
+ RESPONSE_INFO_USE_HTTP_AUTHENTICATION = 1 << 19,
+
// TODO(darin): Add other bits to indicate alternate request methods.
// For now, we don't support storing those.
};
@@ -94,6 +97,7 @@ HttpResponseInfo::HttpResponseInfo()
was_fetched_via_spdy(false),
was_npn_negotiated(false),
was_fetched_via_proxy(false),
+ did_use_http_auth(false),
connection_info(CONNECTION_INFO_UNKNOWN) {
}
@@ -103,6 +107,7 @@ HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs)
was_fetched_via_spdy(rhs.was_fetched_via_spdy),
was_npn_negotiated(rhs.was_npn_negotiated),
was_fetched_via_proxy(rhs.was_fetched_via_proxy),
+ did_use_http_auth(rhs.did_use_http_auth),
socket_address(rhs.socket_address),
npn_negotiated_protocol(rhs.npn_negotiated_protocol),
connection_info(rhs.connection_info),
@@ -125,6 +130,7 @@ HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) {
was_fetched_via_spdy = rhs.was_fetched_via_spdy;
was_npn_negotiated = rhs.was_npn_negotiated;
was_fetched_via_proxy = rhs.was_fetched_via_proxy;
+ did_use_http_auth = rhs.did_use_http_auth;
socket_address = rhs.socket_address;
npn_negotiated_protocol = rhs.npn_negotiated_protocol;
request_time = rhs.request_time;
@@ -243,6 +249,8 @@ bool HttpResponseInfo::InitFromPickle(const Pickle& pickle,
*response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0;
+ did_use_http_auth = (flags & RESPONSE_INFO_USE_HTTP_AUTHENTICATION) != 0;
+
return true;
}
@@ -272,6 +280,8 @@ void HttpResponseInfo::Persist(Pickle* pickle,
flags |= RESPONSE_INFO_WAS_PROXY;
if (connection_info != CONNECTION_INFO_UNKNOWN)
flags |= RESPONSE_INFO_HAS_CONNECTION_INFO;
+ if (did_use_http_auth)
+ flags |= RESPONSE_INFO_USE_HTTP_AUTHENTICATION;
pickle->WriteInt(flags);
pickle->WriteInt64(request_time.ToInternalValue());
diff --git a/net/http/http_response_info.h b/net/http/http_response_info.h
index c82dd07..dedecbd 100644
--- a/net/http/http_response_info.h
+++ b/net/http/http_response_info.h
@@ -75,6 +75,9 @@ class NET_EXPORT HttpResponseInfo {
// transparent proxy may have been involved.
bool was_fetched_via_proxy;
+ // Whether the request use http proxy or server authentication.
+ bool did_use_http_auth;
+
// Remote address of the socket which fetched this resource.
//
// NOTE: If the response was served from the cache (was_cached is true),