summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/network/cf
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-04-27 16:31:00 +0100
committerSteve Block <steveblock@google.com>2010-05-11 14:42:12 +0100
commitdcc8cf2e65d1aa555cce12431a16547e66b469ee (patch)
tree92a8d65cd5383bca9749f5327fb5e440563926e6 /WebCore/platform/network/cf
parentccac38a6b48843126402088a309597e682f40fe6 (diff)
downloadexternal_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebCore/platform/network/cf')
-rw-r--r--WebCore/platform/network/cf/AuthenticationCF.cpp1
-rw-r--r--WebCore/platform/network/cf/FormDataStreamCFNet.cpp2
-rw-r--r--WebCore/platform/network/cf/ResourceHandleCFNet.cpp70
-rw-r--r--WebCore/platform/network/cf/ResourceResponseCFNet.cpp8
-rw-r--r--WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp2
5 files changed, 59 insertions, 24 deletions
diff --git a/WebCore/platform/network/cf/AuthenticationCF.cpp b/WebCore/platform/network/cf/AuthenticationCF.cpp
index 93b62a8..170d419 100644
--- a/WebCore/platform/network/cf/AuthenticationCF.cpp
+++ b/WebCore/platform/network/cf/AuthenticationCF.cpp
@@ -253,6 +253,7 @@ ProtectionSpace core(CFURLProtectionSpaceRef cfSpace)
scheme = ProtectionSpaceAuthenticationSchemeNegotiate;
break;
default:
+ scheme = ProtectionSpaceAuthenticationSchemeUnknown;
ASSERT_NOT_REACHED();
}
diff --git a/WebCore/platform/network/cf/FormDataStreamCFNet.cpp b/WebCore/platform/network/cf/FormDataStreamCFNet.cpp
index 3414d90..bba717d 100644
--- a/WebCore/platform/network/cf/FormDataStreamCFNet.cpp
+++ b/WebCore/platform/network/cf/FormDataStreamCFNet.cpp
@@ -31,7 +31,6 @@
#include "config.h"
#include "FormDataStreamCFNet.h"
-#include "CString.h"
#include "FileSystem.h"
#include "FormData.h"
#include <CFNetwork/CFURLRequestPriv.h>
@@ -41,6 +40,7 @@
#include <wtf/Assertions.h>
#include <wtf/HashMap.h>
#include <wtf/RetainPtr.h>
+#include <wtf/text/CString.h>
#define USE_V1_CFSTREAM_CALLBACKS
#ifdef USE_V1_CFSTREAM_CALLBACKS
diff --git a/WebCore/platform/network/cf/ResourceHandleCFNet.cpp b/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
index 8cc5022..e5eeef0 100644
--- a/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
+++ b/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
@@ -32,7 +32,6 @@
#include "AuthenticationCF.h"
#include "AuthenticationChallenge.h"
#include "Base64.h"
-#include "CString.h"
#include "CookieStorageWin.h"
#include "CredentialStorage.h"
#include "DocLoader.h"
@@ -44,16 +43,24 @@
#include "MIMETypeRegistry.h"
#include "ResourceError.h"
#include "ResourceResponse.h"
-
+#include "SharedBuffer.h"
+#include <CFNetwork/CFNetwork.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <process.h> // for _beginthread()
+#include <sys/stat.h>
+#include <sys/types.h>
#include <wtf/HashMap.h>
#include <wtf/Threading.h>
+#include <wtf/text/CString.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <process.h> // for _beginthread()
-
-#include <CFNetwork/CFNetwork.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+// FIXME: Remove this declaration once it's in WebKitSupportLibrary.
+extern "C" {
+__declspec(dllimport) CFURLConnectionRef CFURLConnectionCreateWithProperties(
+ CFAllocatorRef alloc,
+ CFURLRequestRef request,
+ CFURLConnectionClient * client,
+ CFDictionaryRef properties);
+}
namespace WebCore {
@@ -136,11 +143,11 @@ CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef cfReque
if (cfRedirectResponse) {
CFHTTPMessageRef httpMessage = CFURLResponseGetHTTPResponse(cfRedirectResponse);
if (httpMessage && CFHTTPMessageGetResponseStatusCode(httpMessage) == 307) {
- RetainPtr<CFStringRef> originalMethod(AdoptCF, handle->request().httpMethod().createCFString());
+ RetainPtr<CFStringRef> lastHTTPMethod(AdoptCF, handle->lastHTTPMethod().createCFString());
RetainPtr<CFStringRef> newMethod(AdoptCF, CFURLRequestCopyHTTPRequestMethod(cfRequest));
- if (CFStringCompareWithOptions(originalMethod.get(), newMethod.get(), CFRangeMake(0, CFStringGetLength(originalMethod.get())), kCFCompareCaseInsensitive)) {
+ if (CFStringCompareWithOptions(lastHTTPMethod.get(), newMethod.get(), CFRangeMake(0, CFStringGetLength(lastHTTPMethod.get())), kCFCompareCaseInsensitive)) {
RetainPtr<CFMutableURLRequestRef> mutableRequest(AdoptCF, CFURLRequestCreateMutableCopy(0, cfRequest));
- CFURLRequestSetHTTPRequestMethod(mutableRequest.get(), originalMethod.get());
+ CFURLRequestSetHTTPRequestMethod(mutableRequest.get(), lastHTTPMethod.get());
FormData* body = handle->request().httpBody();
if (!equalIgnoringCase(handle->request().httpMethod(), "GET") && body && !body->isEmpty())
@@ -352,12 +359,37 @@ static CFURLRequestRef makeFinalRequest(const ResourceRequest& request, bool sho
if (CFHTTPCookieStorageRef cookieStorage = currentCookieStorage()) {
CFURLRequestSetHTTPCookieStorage(newRequest, cookieStorage);
- CFURLRequestSetHTTPCookieStorageAcceptPolicy(newRequest, CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage));
+ CFHTTPCookieStorageAcceptPolicy policy = CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage);
+ CFURLRequestSetHTTPCookieStorageAcceptPolicy(newRequest, policy);
+
+ // If a URL already has cookies, then we'll relax the 3rd party cookie policy and accept new cookies.
+ if (policy == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain) {
+ CFURLRef url = CFURLRequestGetURL(newRequest);
+ RetainPtr<CFArrayRef> cookies(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(cookieStorage, url, false));
+ if (CFArrayGetCount(cookies.get()))
+ CFURLRequestSetMainDocumentURL(newRequest, url);
+ }
}
return newRequest;
}
+static CFDictionaryRef createConnectionProperties(bool shouldUseCredentialStorage)
+{
+ static const CFStringRef webKitPrivateSessionCF = CFSTR("WebKitPrivateSession");
+ static const CFStringRef _kCFURLConnectionSessionID = CFSTR("_kCFURLConnectionSessionID");
+ static const CFStringRef kCFURLConnectionSocketStreamProperties = CFSTR("kCFURLConnectionSocketStreamProperties");
+
+ CFDictionaryRef sessionID = shouldUseCredentialStorage ?
+ CFDictionaryCreate(0, 0, 0, 0, 0, 0) :
+ CFDictionaryCreate(0, (const void**)&_kCFURLConnectionSessionID, (const void**)&webKitPrivateSessionCF, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+
+ CFDictionaryRef propertiesDictionary = CFDictionaryCreate(0, (const void**)&kCFURLConnectionSocketStreamProperties, (const void**)&sessionID, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+
+ CFRelease(sessionID);
+ return propertiesDictionary;
+}
+
bool ResourceHandle::start(Frame* frame)
{
// If we are no longer attached to a Page, this must be an attempted load from an
@@ -373,9 +405,11 @@ bool ResourceHandle::start(Frame* frame)
d->m_request.setURL(urlWithCredentials);
}
+ bool shouldUseCredentialStorage = !client() || client()->shouldUseCredentialStorage(this);
+
// <rdar://problem/7174050> - For URLs that match the paths of those previously challenged for HTTP Basic authentication,
// try and reuse the credential preemptively, as allowed by RFC 2617.
- if (!client() || client()->shouldUseCredentialStorage(this) && d->m_request.url().protocolInHTTPFamily()) {
+ if (shouldUseCredentialStorage && d->m_request.url().protocolInHTTPFamily()) {
if (d->m_user.isEmpty() && d->m_pass.isEmpty()) {
// <rdar://problem/7174050> - For URLs that match the paths of those previously challenged for HTTP Basic authentication,
// try and reuse the credential preemptively, as allowed by RFC 2617.
@@ -397,7 +431,9 @@ bool ResourceHandle::start(Frame* frame)
CFURLConnectionClient_V3 client = { 3, this, 0, 0, 0, WebCore::willSendRequest, didReceiveResponse, didReceiveData, NULL, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge, didSendBodyData, shouldUseCredentialStorageCallback, 0};
- d->m_connection.adoptCF(CFURLConnectionCreate(0, request.get(), reinterpret_cast<CFURLConnectionClient*>(&client)));
+ RetainPtr<CFDictionaryRef> connectionProperties(AdoptCF, createConnectionProperties(shouldUseCredentialStorage));
+
+ d->m_connection.adoptCF(CFURLConnectionCreateWithProperties(0, request.get(), reinterpret_cast<CFURLConnectionClient*>(&client), connectionProperties.get()));
CFURLConnectionScheduleWithCurrentMessageQueue(d->m_connection.get());
CFURLConnectionScheduleDownloadWithRunLoop(d->m_connection.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
@@ -432,6 +468,7 @@ void ResourceHandle::willSendRequest(ResourceRequest& request, const ResourceRes
const KURL& url = request.url();
d->m_user = url.user();
d->m_pass = url.pass();
+ d->m_lastHTTPMethod = request.httpMethod();
request.removeCredentials();
client()->willSendRequest(this, request, redirectResponse);
@@ -763,7 +800,10 @@ RetainPtr<CFDataRef> WebCoreSynchronousLoader::load(const ResourceRequest& reque
}
CFURLConnectionClient_V3 client = { 3, &loader, 0, 0, 0, willSendRequest, didReceiveResponse, didReceiveData, 0, didFinishLoading, didFail, 0, didReceiveChallenge, 0, shouldUseCredentialStorage, 0 };
- RetainPtr<CFURLConnectionRef> connection(AdoptCF, CFURLConnectionCreate(kCFAllocatorDefault, cfRequest.get(), reinterpret_cast<CFURLConnectionClient*>(&client)));
+
+ RetainPtr<CFDictionaryRef> connectionProperties(AdoptCF, createConnectionProperties(loader.m_allowStoredCredentials));
+
+ RetainPtr<CFURLConnectionRef> connection(AdoptCF, CFURLConnectionCreateWithProperties(kCFAllocatorDefault, cfRequest.get(), reinterpret_cast<CFURLConnectionClient*>(&client), connectionProperties.get()));
CFURLConnectionScheduleWithRunLoop(connection.get(), CFRunLoopGetCurrent(), WebCoreSynchronousLoaderRunLoopMode);
CFURLConnectionScheduleDownloadWithRunLoop(connection.get(), CFRunLoopGetCurrent(), WebCoreSynchronousLoaderRunLoopMode);
diff --git a/WebCore/platform/network/cf/ResourceResponseCFNet.cpp b/WebCore/platform/network/cf/ResourceResponseCFNet.cpp
index 95e9aff..469e5ad 100644
--- a/WebCore/platform/network/cf/ResourceResponseCFNet.cpp
+++ b/WebCore/platform/network/cf/ResourceResponseCFNet.cpp
@@ -89,13 +89,7 @@ void ResourceResponse::platformLazyInit()
m_httpStatusCode = CFHTTPMessageGetResponseStatusCode(httpResponse);
RetainPtr<CFStringRef> statusLine(AdoptCF, CFHTTPMessageCopyResponseStatusLine(httpResponse));
- String statusText(statusLine.get());
- int spacePos = statusText.find(' ');
- // Remove the status code from the status text.
- spacePos = statusText.find(' ', spacePos + 1);
- statusText = statusText.substring(spacePos + 1);
-
- m_httpStatusText = statusText;
+ m_httpStatusText = extractReasonPhraseFromHTTPStatusLine(statusLine.get());
RetainPtr<CFDictionaryRef> headers(AdoptCF, CFHTTPMessageCopyAllHeaderFields(httpResponse));
CFIndex headerCount = CFDictionaryGetCount(headers.get());
diff --git a/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp b/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp
index e7e64da..c66de33 100644
--- a/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp
+++ b/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp
@@ -377,7 +377,7 @@ static ProtectionSpaceAuthenticationScheme authenticationSchemeFromAuthenticatio
return ProtectionSpaceAuthenticationSchemeNegotiate;
#endif
ASSERT_NOT_REACHED();
- return ProtectionSpaceAuthenticationSchemeDefault;
+ return ProtectionSpaceAuthenticationSchemeUnknown;
}
void SocketStreamHandle::addCONNECTCredentials(CFHTTPMessageRef proxyResponse)