Diff
Modified: trunk/Source/WebCore/ChangeLog (222222 => 222223)
--- trunk/Source/WebCore/ChangeLog 2017-09-19 20:42:26 UTC (rev 222222)
+++ trunk/Source/WebCore/ChangeLog 2017-09-19 20:45:09 UTC (rev 222223)
@@ -1,3 +1,30 @@
+2017-09-19 Basuke Suzuki <[email protected]>
+
+ [Curl] Move Authentication related tasks into AuthenticationChallenge class
+ https://bugs.webkit.org/show_bug.cgi?id=177105
+
+ Currently those codes are in ResourceHandle or related companion. It will
+ be reused with NetworkLoadTask so that it should be separated from them.
+
+ Reviewed by Alex Christensen.
+
+ * platform/Curl.cmake:
+ * platform/network/curl/AuthenticationChallenge.h:
+ (WebCore::AuthenticationChallenge::AuthenticationChallenge): Deleted.
+ (WebCore::AuthenticationChallenge::authenticationClient const): Deleted.
+ (WebCore::AuthenticationChallenge::setAuthenticationClient): Deleted.
+ * platform/network/curl/AuthenticationChallengeCurl.cpp: Added.
+ (WebCore::AuthenticationChallenge::AuthenticationChallenge):
+ (WebCore::AuthenticationChallenge::protectionSpaceServerTypeFromURI):
+ (WebCore::AuthenticationChallenge::protectionSpaceFromHandle):
+ (WebCore::AuthenticationChallenge::removeLeadingAndTrailingQuotes):
+ * platform/network/curl/ResourceHandleCurlDelegate.cpp:
+ (WebCore::ResourceHandleCurlDelegate::didReceiveAllHeaders):
+ (WebCore::ResourceHandleCurlDelegate::didReceiveHeader):
+ (WebCore::removeLeadingAndTrailingQuotes): Deleted.
+ (WebCore::ResourceHandleCurlDelegate::getProtectionSpace): Deleted.
+ * platform/network/curl/ResourceHandleCurlDelegate.h:
+
2017-09-19 Zalan Bujtas <[email protected]>
Do not mutate RenderText content during layout.
Modified: trunk/Source/WebCore/platform/Curl.cmake (222222 => 222223)
--- trunk/Source/WebCore/platform/Curl.cmake 2017-09-19 20:42:26 UTC (rev 222222)
+++ trunk/Source/WebCore/platform/Curl.cmake 2017-09-19 20:45:09 UTC (rev 222223)
@@ -3,6 +3,7 @@
)
list(APPEND WebCore_SOURCES
+ platform/network/curl/AuthenticationChallengeCurl.cpp
platform/network/curl/CookieJarCurl.cpp
platform/network/curl/CredentialStorageCurl.cpp
platform/network/curl/CurlCacheEntry.cpp
Modified: trunk/Source/WebCore/platform/network/curl/AuthenticationChallenge.h (222222 => 222223)
--- trunk/Source/WebCore/platform/network/curl/AuthenticationChallenge.h 2017-09-19 20:42:26 UTC (rev 222222)
+++ trunk/Source/WebCore/platform/network/curl/AuthenticationChallenge.h 2017-09-19 20:45:09 UTC (rev 222223)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2017 Sony Interactive Entertainment Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +28,10 @@
#include "AuthenticationChallengeBase.h"
#include "AuthenticationClient.h"
-#include <wtf/RefPtr.h>
namespace WebCore {
-class AuthenticationChallenge : public AuthenticationChallengeBase {
+class AuthenticationChallenge final : public AuthenticationChallengeBase {
public:
AuthenticationChallenge()
{
@@ -42,9 +42,14 @@
{
}
+ AuthenticationChallenge(uint16_t, long, unsigned, const ResourceResponse&, AuthenticationClient* = nullptr);
AuthenticationClient* authenticationClient() const { return m_authenticationClient.get(); }
- void setAuthenticationClient(AuthenticationClient* client) { m_authenticationClient = client; }
+private:
+ ProtectionSpaceServerType protectionSpaceServerTypeFromURI(const URL&);
+ ProtectionSpace protectionSpaceFromHandle(uint16_t, long, const ResourceResponse&);
+ void removeLeadingAndTrailingQuotes(String&);
+
RefPtr<AuthenticationClient> m_authenticationClient;
};
Added: trunk/Source/WebCore/platform/network/curl/AuthenticationChallengeCurl.cpp (0 => 222223)
--- trunk/Source/WebCore/platform/network/curl/AuthenticationChallengeCurl.cpp (rev 0)
+++ trunk/Source/WebCore/platform/network/curl/AuthenticationChallengeCurl.cpp 2017-09-19 20:45:09 UTC (rev 222223)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2017 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AuthenticationChallenge.h"
+
+#if USE(CURL)
+
+#include "CurlContext.h"
+#include "ResourceError.h"
+
+namespace WebCore {
+
+AuthenticationChallenge::AuthenticationChallenge(uint16_t connectPort, long availableHttpAuth, unsigned previousFailureCount, const ResourceResponse& response, AuthenticationClient* client)
+ : AuthenticationChallengeBase(protectionSpaceFromHandle(connectPort, availableHttpAuth, response), Credential(), previousFailureCount, response, ResourceError())
+ , m_authenticationClient(client)
+{
+}
+
+ProtectionSpaceServerType AuthenticationChallenge::protectionSpaceServerTypeFromURI(const URL& url)
+{
+ if (url.protocolIs("https"))
+ return ProtectionSpaceServerHTTPS;
+ if (url.protocolIs("http"))
+ return ProtectionSpaceServerHTTP;
+ if (url.protocolIs("ftp"))
+ return ProtectionSpaceServerFTP;
+ return ProtectionSpaceServerHTTP;
+}
+
+ProtectionSpace AuthenticationChallenge::protectionSpaceFromHandle(uint16_t connectPort, long availableHttpAuth, const ResourceResponse& response)
+{
+ ProtectionSpaceAuthenticationScheme scheme = ProtectionSpaceAuthenticationSchemeUnknown;
+ if (availableHttpAuth & CURLAUTH_BASIC)
+ scheme = ProtectionSpaceAuthenticationSchemeHTTPBasic;
+ if (availableHttpAuth & CURLAUTH_DIGEST)
+ scheme = ProtectionSpaceAuthenticationSchemeHTTPDigest;
+ if (availableHttpAuth & CURLAUTH_NEGOTIATE)
+ scheme = ProtectionSpaceAuthenticationSchemeNegotiate;
+ if (availableHttpAuth & CURLAUTH_NTLM)
+ scheme = ProtectionSpaceAuthenticationSchemeNTLM;
+
+ String realm;
+ const String realmString("realm=");
+ auto authHeader = response.httpHeaderField(HTTPHeaderName::Authorization);
+ auto realmPos = authHeader.find(realmString);
+ if (realmPos != notFound) {
+ realm = authHeader.substring(realmPos + realmString.length());
+ realm = realm.left(realm.find(','));
+ removeLeadingAndTrailingQuotes(realm);
+ }
+
+ return ProtectionSpace(response.url().host(), static_cast<int>(connectPort), protectionSpaceServerTypeFromURI(response.url()), realm, scheme);
+}
+
+void AuthenticationChallenge::removeLeadingAndTrailingQuotes(String& value)
+{
+ auto length = value.length();
+ if (value.startsWith('"') && value.endsWith('"') && length > 1)
+ value = value.substring(1, length - 2);
+}
+
+} // namespace WebCore
+
+#endif
Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.cpp (222222 => 222223)
--- trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.cpp 2017-09-19 20:42:26 UTC (rev 222222)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.cpp 2017-09-19 20:45:09 UTC (rev 222223)
@@ -324,67 +324,12 @@
}
}
-static void removeLeadingAndTrailingQuotes(String& value)
-{
- unsigned length = value.length();
- if (value.startsWith('"') && value.endsWith('"') && length > 1)
- value = value.substring(1, length - 2);
-}
-
-bool ResourceHandleCurlDelegate::getProtectionSpace(const ResourceResponse& response, ProtectionSpace& protectionSpace)
-{
- auto port = m_curlHandle.getPrimaryPort();
- if (!port)
- return false;
-
- auto availableAuth = m_curlHandle.getHttpAuthAvail();
- if (!availableAuth)
- return false;
-
- auto url = ""
- if (!url.isValid())
- return false;
-
- String host = url.host();
- StringView protocol = url.protocol();
-
- String realm;
-
- const String authHeader = response.httpHeaderField(HTTPHeaderName::Authorization);
- const String realmString = "realm=";
- int realmPos = authHeader.find(realmString);
- if (realmPos > 0) {
- realm = authHeader.substring(realmPos + realmString.length());
- realm = realm.left(realm.find(','));
- removeLeadingAndTrailingQuotes(realm);
- }
-
- ProtectionSpaceServerType serverType = ProtectionSpaceServerHTTP;
- if (protocol == "https")
- serverType = ProtectionSpaceServerHTTPS;
-
- ProtectionSpaceAuthenticationScheme authScheme = ProtectionSpaceAuthenticationSchemeUnknown;
-
- if (*availableAuth & CURLAUTH_BASIC)
- authScheme = ProtectionSpaceAuthenticationSchemeHTTPBasic;
- if (*availableAuth & CURLAUTH_DIGEST)
- authScheme = ProtectionSpaceAuthenticationSchemeHTTPDigest;
- if (*availableAuth & CURLAUTH_GSSNEGOTIATE)
- authScheme = ProtectionSpaceAuthenticationSchemeNegotiate;
- if (*availableAuth & CURLAUTH_NTLM)
- authScheme = ProtectionSpaceAuthenticationSchemeNTLM;
-
- protectionSpace = ProtectionSpace(host, *port, serverType, realm, authScheme);
-
- return true;
-}
-
inline static bool isHttpInfo(int statusCode)
{
return 100 <= statusCode && statusCode < 200;
}
-void ResourceHandleCurlDelegate::didReceiveAllHeaders(long httpCode, long long contentLength)
+void ResourceHandleCurlDelegate::didReceiveAllHeaders(long httpCode, long long contentLength, uint16_t connectPort, long availableHttpAuth)
{
ASSERT(isMainThread());
@@ -419,15 +364,10 @@
return;
}
} else if (response().isUnauthorized()) {
- ProtectionSpace protectionSpace;
- if (getProtectionSpace(response(), protectionSpace)) {
- Credential credential;
- AuthenticationChallenge challenge(protectionSpace, credential, m_authFailureCount, response(), ResourceError());
- challenge.setAuthenticationClient(m_handle);
- m_handle->didReceiveAuthenticationChallenge(challenge);
- m_authFailureCount++;
- return;
- }
+ AuthenticationChallenge challenge(connectPort, availableHttpAuth, m_authFailureCount, response(), m_handle);
+ m_handle->didReceiveAuthenticationChallenge(challenge);
+ m_authFailureCount++;
+ return;
}
response().setResponseFired(true);
@@ -762,13 +702,21 @@
if (auto length = m_curlHandle.getContentLenghtDownload())
contentLength = *length;
+ uint16_t connectPort = 0;
+ if (auto port = m_curlHandle.getPrimaryPort())
+ connectPort = *port;
+
+ long availableAuth = CURLAUTH_NONE;
+ if (auto auth = m_curlHandle.getHttpAuthAvail())
+ availableAuth = *auth;
+
if (isMainThread())
- didReceiveAllHeaders(httpCode, contentLength);
+ didReceiveAllHeaders(httpCode, contentLength, connectPort, availableAuth);
else {
- callOnMainThread([protectedThis = makeRef(*this), httpCode, contentLength] {
+ callOnMainThread([protectedThis = makeRef(*this), httpCode, contentLength, connectPort, availableAuth] {
if (!protectedThis->m_handle)
return;
- protectedThis->didReceiveAllHeaders(httpCode, contentLength);
+ protectedThis->didReceiveAllHeaders(httpCode, contentLength, connectPort, availableAuth);
});
}
} else {
Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.h (222222 => 222223)
--- trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.h 2017-09-19 20:42:26 UTC (rev 222222)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.h 2017-09-19 20:45:09 UTC (rev 222223)
@@ -73,9 +73,8 @@
ResourceResponse& response();
void setupAuthentication();
- bool getProtectionSpace(const ResourceResponse&, ProtectionSpace&);
- void didReceiveAllHeaders(long httpCode, long long contentLength);
+ void didReceiveAllHeaders(long httpCode, long long contentLength, uint16_t connectPort, long availableHttpAuth);
void didReceiveContentData(ThreadSafeDataBuffer);
void handleLocalReceiveResponse();
void prepareSendData(char*, size_t blockSize, size_t numberOfBlocks);