Changeset 230973 in webkit
- Timestamp:
- Apr 24, 2018 2:54:49 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r230970 r230973 1 2018-04-24 Basuke Suzuki <Basuke.Suzuki@sony.com> 2 3 [Curl] Extract proxy settings into a separate class to hold advanced information. 4 https://bugs.webkit.org/show_bug.cgi?id=184714 5 6 It was simplely structure to hold proxy setting. To support advanced feature of proxy 7 such as authentication, more inteligent object is required to store intermediate state 8 or errors. That's why we've introduced new class for that purpose. 9 10 Reviewed by Youenn Fablet. 11 12 No new tests because there's no new behavior. 13 14 * platform/Curl.cmake: 15 * platform/network/curl/CurlContext.cpp: 16 (WebCore::CurlHandle::enableProxyIfExists): 17 (WebCore::CurlContext::ProxyInfo::url const): Deleted. 18 (WebCore::CurlContext::setProxyInfo): Deleted. 19 * platform/network/curl/CurlContext.h: 20 (WebCore::CurlContext::proxySettings const): 21 (WebCore::CurlContext::setProxySettings): 22 (WebCore::CurlContext::setProxyUserPass): 23 (WebCore::CurlContext::proxyInfo const): Deleted. 24 (WebCore::CurlContext::setProxyInfo): Deleted. 25 * platform/network/curl/CurlProxySettings.cpp: Added. 26 (WebCore::CurlProxySettings::CurlProxySettings): 27 (WebCore::CurlProxySettings::rebuildUrl): 28 (WebCore::CurlProxySettings::setUserPass): 29 (WebCore::protocolIsInSocksFamily): 30 (WebCore::getProxyPort): 31 (WebCore::createProxyUrl): 32 * platform/network/curl/CurlProxySettings.h: Added. 33 (WebCore::CurlProxySettings::CurlProxySettings): 34 (WebCore::CurlProxySettings::isEmpty const): 35 (WebCore::CurlProxySettings::mode const): 36 (WebCore::CurlProxySettings::url const): 37 (WebCore::CurlProxySettings::ignoreHosts const): 38 (WebCore::CurlProxySettings::user const): 39 (WebCore::CurlProxySettings::password const): 40 * platform/network/curl/CurlRequest.cpp: 41 (WebCore::CurlRequest::didReceiveHeader): 42 * platform/network/curl/CurlResponse.h: 43 (WebCore::CurlResponse::isolatedCopy const): 44 * platform/network/curl/ResourceResponseCurl.cpp: 45 (WebCore::ResourceResponse::ResourceResponse): 46 1 47 2018-04-24 Youenn Fablet <youenn@apple.com> 2 48 -
trunk/Source/WebCore/platform/Curl.cmake
r229359 r230973 17 17 platform/network/curl/CurlFormDataStream.cpp 18 18 platform/network/curl/CurlMultipartHandle.cpp 19 platform/network/curl/CurlProxySettings.cpp 19 20 platform/network/curl/CurlRequest.cpp 20 21 platform/network/curl/CurlRequestScheduler.cpp -
trunk/Source/WebCore/platform/network/curl/CurlContext.cpp
r230620 r230973 1 1 /* 2 2 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 201 7Sony Interactive Entertainment Inc.3 * Copyright (C) 2018 Sony Interactive Entertainment Inc. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 139 139 } 140 140 141 // Proxy =======================142 143 const String CurlContext::ProxyInfo::url() const144 {145 String userPass;146 if (username.length() || password.length())147 userPass = username + ":" + password + "@";148 149 return String("http://") + userPass + host + ":" + String::number(port);150 }151 152 void CurlContext::setProxyInfo(const String& host,153 unsigned long port,154 CurlProxyType type,155 const String& username,156 const String& password)157 {158 ProxyInfo info;159 160 info.host = host;161 info.port = port;162 info.type = type;163 info.username = username;164 info.password = password;165 166 setProxyInfo(info);167 }168 169 141 bool CurlContext::isHttp2Enabled() const 170 142 { … … 513 485 void CurlHandle::enableProxyIfExists() 514 486 { 515 auto& proxy = CurlContext::singleton().proxyInfo(); 516 517 if (proxy.type != CurlProxyType::Invalid) { 487 auto& proxy = CurlContext::singleton().proxySettings(); 488 489 switch (proxy.mode()) { 490 case CurlProxySettings::Mode::Default : 491 // For the proxy set by environment variable 492 if (!proxy.user().isEmpty()) 493 curl_easy_setopt(m_handle, CURLOPT_PROXYUSERNAME, proxy.user().utf8().data()); 494 if (!proxy.password().isEmpty()) 495 curl_easy_setopt(m_handle, CURLOPT_PROXYPASSWORD, proxy.password().utf8().data()); 496 curl_easy_setopt(m_handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY); 497 break; 498 case CurlProxySettings::Mode::NoProxy : 499 // Disable the use of a proxy, even if there is an environment variable set for it. 500 curl_easy_setopt(m_handle, CURLOPT_PROXY, ""); 501 break; 502 case CurlProxySettings::Mode::Custom : 518 503 curl_easy_setopt(m_handle, CURLOPT_PROXY, proxy.url().utf8().data()); 519 curl_easy_setopt(m_handle, CURLOPT_PROXYTYPE, proxy.type); 504 curl_easy_setopt(m_handle, CURLOPT_NOPROXY, proxy.ignoreHosts().utf8().data()); 505 curl_easy_setopt(m_handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY); 506 break; 520 507 } 521 508 } -
trunk/Source/WebCore/platform/network/curl/CurlContext.h
r230303 r230973 1 1 /* 2 2 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 201 7Sony Interactive Entertainment Inc.3 * Copyright (C) 2018 Sony Interactive Entertainment Inc. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 27 27 #pragma once 28 28 29 #include "CurlProxySettings.h" 29 30 #include "CurlSSLHandle.h" 30 31 #include "URL.h" … … 44 45 45 46 namespace WebCore { 46 47 enum class CurlProxyType {48 Invalid = -1,49 HTTP = CURLPROXY_HTTP,50 Socks4 = CURLPROXY_SOCKS4,51 Socks4A = CURLPROXY_SOCKS4A,52 Socks5 = CURLPROXY_SOCKS5,53 Socks5Hostname = CURLPROXY_SOCKS5_HOSTNAME54 };55 47 56 48 // Values taken from http://www.browserscope.org/ following … … 103 95 friend NeverDestroyed<CurlContext>; 104 96 public: 105 struct ProxyInfo {106 String host;107 unsigned long port;108 CurlProxyType type { CurlProxyType::Invalid };109 String username;110 String password;111 112 const String url() const;113 };114 115 97 WEBCORE_EXPORT static CurlContext& singleton(); 116 98 … … 122 104 123 105 // Proxy 124 const ProxyInfo& proxyInfo() const { return m_proxy; }125 void setProxy Info(const ProxyInfo& info) { m_proxy = info;}126 void setProxy Info(const String& host = emptyString(), unsigned long port = 0, CurlProxyType = CurlProxyType::HTTP, const String& username = emptyString(), const String& password = emptyString());106 const CurlProxySettings& proxySettings() const { return m_proxySettings; } 107 void setProxySettings(const CurlProxySettings& settings) { m_proxySettings = settings; } 108 void setProxyUserPass(const String& user, const String& password) { m_proxySettings.setUserPass(user, password); } 127 109 128 110 // SSL … … 145 127 void initShareHandle(); 146 128 147 ProxyInfo m_proxy;129 CurlProxySettings m_proxySettings; 148 130 CurlShareHandle m_shareHandle; 149 131 CurlSSLHandle m_sslHandle; -
trunk/Source/WebCore/platform/network/curl/CurlRequest.cpp
r230734 r230973 313 313 m_response.url = m_request.url(); 314 314 m_response.statusCode = statusCode; 315 m_response.httpConnectCode = httpConnectCode; 315 316 316 317 if (auto length = m_curlHandle->getContentLength()) -
trunk/Source/WebCore/platform/network/curl/CurlResponse.h
r226754 r230973 1 1 /* 2 * Copyright (C) 201 7Sony Interactive Entertainment Inc.2 * Copyright (C) 2018 Sony Interactive Entertainment Inc. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 40 40 copy.url = url.isolatedCopy(); 41 41 copy.statusCode = statusCode; 42 copy.httpConnectCode = httpConnectCode; 42 43 copy.expectedContentLength = expectedContentLength; 43 44 … … 54 55 URL url; 55 56 long statusCode { 0 }; 57 long httpConnectCode { 0 }; 56 58 long long expectedContentLength { 0 }; 57 59 Vector<String> headers; -
trunk/Source/WebCore/platform/network/curl/ResourceResponseCurl.cpp
r226754 r230973 1 1 /* 2 * Copyright (C) 201 7Sony Interactive Entertainment Inc.2 * Copyright (C) 2018 Sony Interactive Entertainment Inc. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 81 81 : ResourceResponseBase(response.url, "", response.expectedContentLength, "") 82 82 { 83 setHTTPStatusCode(response.statusCode );83 setHTTPStatusCode(response.statusCode ? response.statusCode : response.httpConnectCode); 84 84 85 85 for (const auto& header : response.headers)
Note: See TracChangeset
for help on using the changeset viewer.