summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-11-25 12:11:15 +0000
committerSteve Block <steveblock@google.com>2010-11-25 16:24:27 +0000
commit9bf5f54cd2daed5b9d96acb5af88a024b90ad32f (patch)
treee8bd2096e90591b36214c7f83e4f73bb4043b987 /WebKit
parent0c918ae77b5edfe59b726ff40a7c86dbc4a94307 (diff)
downloadexternal_webkit-9bf5f54cd2daed5b9d96acb5af88a024b90ad32f.zip
external_webkit-9bf5f54cd2daed5b9d96acb5af88a024b90ad32f.tar.gz
external_webkit-9bf5f54cd2daed5b9d96acb5af88a024b90ad32f.tar.bz2
Fixes WebResourceRequest to correctly set load flags
We now correctly set the cookie load flags and the cache control HTTP headers. Bug: 2889880 Change-Id: I759a3131b73a8fc82432a067a31754fcc566c136
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/WebCoreSupport/WebResourceRequest.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/WebKit/android/WebCoreSupport/WebResourceRequest.cpp b/WebKit/android/WebCoreSupport/WebResourceRequest.cpp
index c3ec562..9b70fce 100644
--- a/WebKit/android/WebCoreSupport/WebResourceRequest.cpp
+++ b/WebKit/android/WebCoreSupport/WebResourceRequest.cpp
@@ -36,10 +36,37 @@ namespace android {
WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceRequest)
{
+ // Set the load flags based on the WebCore request.
+ m_loadFlags = net::LOAD_NORMAL;
+ switch (resourceRequest.cachePolicy()) {
+ case ReloadIgnoringCacheData:
+ m_loadFlags |= net::LOAD_VALIDATE_CACHE;
+ break;
+ case ReturnCacheDataElseLoad:
+ m_loadFlags |= net::LOAD_PREFERRING_CACHE;
+ break;
+ case ReturnCacheDataDontLoad:
+ m_loadFlags |= net::LOAD_ONLY_FROM_CACHE;
+ break;
+ case UseProtocolCachePolicy:
+ break;
+ }
+
+ // TODO: We should consider setting these flags and net::LOAD_DO_NOT_SEND_AUTH_DATA
+ // when FrameLoaderClient::shouldUseCredentialStorage() is false. However,
+ // the required WebKit logic is not yet in place. See Chromium's
+ // FrameLoaderClientImpl::shouldUseCredentialStorage().
+ if (!resourceRequest.allowCookies()) {
+ m_loadFlags |= net::LOAD_DO_NOT_SAVE_COOKIES;
+ m_loadFlags |= net::LOAD_DO_NOT_SEND_COOKIES;
+ }
+
+
// Set the request headers
const HTTPHeaderMap& map = resourceRequest.httpHeaderFields();
for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it) {
const std::string& nameUtf8 = it->first.string().utf8().data();
+ const std::string& valueUtf8 = it->second.utf8().data();
// Skip over referrer headers found in the header map because we already
// pulled it out as a separate parameter. We likewise prune the UA since
@@ -47,17 +74,13 @@ WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceR
if (LowerCaseEqualsASCII(nameUtf8, "referer") || LowerCaseEqualsASCII(nameUtf8, "user-agent"))
continue;
- // The next comment does not match what is happening in code since the load flags are not implemented
- // (http://b/issue?id=2889880)
- // TODO: Check this is correct when load flags are implemented and working.
-
// Skip over "Cache-Control: max-age=0" header if the corresponding
// load flag is already specified. FrameLoader sets both the flag and
// the extra header -- the extra header is redundant since our network
// implementation will add the necessary headers based on load flags.
// See http://code.google.com/p/chromium/issues/detail?id=3434.
- const std::string& valueUtf8 = it->second.utf8().data();
- if (LowerCaseEqualsASCII(nameUtf8, "cache-control") && LowerCaseEqualsASCII(valueUtf8, "max-age=0"))
+ if ((m_loadFlags & net::LOAD_VALIDATE_CACHE) &&
+ LowerCaseEqualsASCII(nameUtf8, "cache-control") && LowerCaseEqualsASCII(valueUtf8, "max-age=0"))
continue;
m_requestHeaders.SetHeader(nameUtf8, valueUtf8);
@@ -68,21 +91,6 @@ WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceR
m_userAgent = resourceRequest.httpUserAgent().utf8().data();
m_url = resourceRequest.url().string().utf8().data();
-
- m_loadFlags = net::LOAD_NORMAL;
- switch (resourceRequest.cachePolicy()) {
- case ReloadIgnoringCacheData:
- m_loadFlags |= net::LOAD_VALIDATE_CACHE;
- break;
- case ReturnCacheDataElseLoad:
- m_loadFlags |= net::LOAD_PREFERRING_CACHE;
- break;
- case ReturnCacheDataDontLoad:
- m_loadFlags |= net::LOAD_ONLY_FROM_CACHE;
- break;
- case UseProtocolCachePolicy:
- break;
- }
}
} // namespace android