[Curl] Enable Proxy Authentication on WebKit.
authorBasuke.Suzuki@sony.com <Basuke.Suzuki@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Aug 2018 00:43:44 +0000 (00:43 +0000)
committerBasuke.Suzuki@sony.com <Basuke.Suzuki@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Aug 2018 00:43:44 +0000 (00:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188998

Reviewed by Alex Christensen.

Add support for proxy authentication to curl backend running on WebKit.
This is follow up implementation of legacy implementation:
- https://bugs.webkit.org/show_bug.cgi?id=185266

* NetworkProcess/curl/NetworkDataTaskCurl.cpp:
(WebKit::NetworkDataTaskCurl::curlDidReceiveResponse):
(WebKit::NetworkDataTaskCurl::tryProxyAuthentication):
* NetworkProcess/curl/NetworkDataTaskCurl.h:
* NetworkProcess/curl/NetworkProcessCurl.cpp:
* PlatformWin.cmake:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235418 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp
Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.h
Source/WebKit/NetworkProcess/curl/NetworkProcessCurl.cpp
Source/WebKit/PlatformWin.cmake

index b73c679..1354211 100644 (file)
@@ -1,3 +1,21 @@
+2018-08-27  Basuke Suzuki  <Basuke.Suzuki@sony.com>
+
+        [Curl] Enable Proxy Authentication on WebKit.
+        https://bugs.webkit.org/show_bug.cgi?id=188998
+
+        Reviewed by Alex Christensen.
+
+        Add support for proxy authentication to curl backend running on WebKit.
+        This is follow up implementation of legacy implementation:
+        - https://bugs.webkit.org/show_bug.cgi?id=185266
+
+        * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
+        (WebKit::NetworkDataTaskCurl::curlDidReceiveResponse):
+        (WebKit::NetworkDataTaskCurl::tryProxyAuthentication):
+        * NetworkProcess/curl/NetworkDataTaskCurl.h:
+        * NetworkProcess/curl/NetworkProcessCurl.cpp:
+        * PlatformWin.cmake:
+
 2018-08-27  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [Attachment Support] Remove WebCore::AttachmentDisplayOptions and friends
index b0623e3..29b528e 100644 (file)
@@ -169,6 +169,11 @@ void NetworkDataTaskCurl::curlDidReceiveResponse(CurlRequest& request, const Cur
         return;
     }
 
+    if (m_response.isProxyAuthenticationRequired()) {
+        tryProxyAuthentication(AuthenticationChallenge(receivedResponse, 0, m_response));
+        return;
+    }
+
     didReceiveResponse(ResourceResponse(m_response), [this, protectedThis = makeRef(*this)](PolicyAction policyAction) {
         if (m_state == State::Canceling || m_state == State::Completed)
             return;
@@ -360,6 +365,26 @@ void NetworkDataTaskCurl::tryHttpAuthentication(AuthenticationChallenge&& challe
     });
 }
 
+void NetworkDataTaskCurl::tryProxyAuthentication(WebCore::AuthenticationChallenge&& challenge)
+{
+    m_client->didReceiveChallenge(AuthenticationChallenge(challenge), [this, protectedThis = makeRef(*this), challenge](AuthenticationChallengeDisposition disposition, const Credential& credential) {
+        if (m_state == State::Canceling || m_state == State::Completed)
+            return;
+
+        if (disposition == AuthenticationChallengeDisposition::Cancel) {
+            cancel();
+            m_client->didCompleteWithError(ResourceError::httpError(CURLE_COULDNT_RESOLVE_PROXY, m_response.url()));
+            return;
+        }
+
+        CurlContext::singleton().setProxyUserPass(credential.user(), credential.password());
+        CurlContext::singleton().setDefaultProxyAuthMethod();
+
+        auto requestCredential = m_curlRequest ? Credential(m_curlRequest->user(), m_curlRequest->password(), CredentialPersistenceNone) : Credential();
+        restartWithCredential(requestCredential);
+    });
+}
+
 void NetworkDataTaskCurl::restartWithCredential(const Credential& credential)
 {
     if (m_curlRequest)
index d955f9a..1fd3d02 100644 (file)
@@ -73,6 +73,7 @@ private:
     void willPerformHTTPRedirection();
 
     void tryHttpAuthentication(WebCore::AuthenticationChallenge&&);
+    void tryProxyAuthentication(WebCore::AuthenticationChallenge&&);
     void restartWithCredential(const WebCore::Credential&);
 
     void appendCookieHeader(WebCore::ResourceRequest&);
index b046a9b..19131c6 100644 (file)
@@ -33,6 +33,8 @@
 #include <WebCore/CertificateInfo.h>
 #include <WebCore/FileSystem.h>
 #include <WebCore/NetworkStorageSession.h>
+#include "WebCookieManager.h"
+#include <WebCore/CurlContext.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/ResourceHandle.h>
 #include <wtf/RAMSize.h>
index 0be7e26..5c99d5a 100644 (file)
@@ -176,6 +176,7 @@ if (${WTF_PLATFORM_WIN_CAIRO})
     )
 
     list(APPEND WebKit_INCLUDE_DIRECTORIES
+        "${WEBCORE_DIR}/platform/network/curl"
         "${WEBKIT_DIR}/NetworkProcess/curl"
         "${WEBKIT_DIR}/WebProcess/WebCoreSupport/curl"
     )