Changeset 218947 in webkit
- Timestamp:
- Jun 29, 2017 11:07:32 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r218944 r218947 1 2017-06-29 Basuke Suzuki <Basuke.Suzuki@sony.com> 2 3 [Curl] Separate global curl settings from ResourceHandleManager as CurlContext class 4 https://bugs.webkit.org/show_bug.cgi?id=173629 5 6 Reviewed by Alex Christensen. 7 8 * PlatformWinCairo.cmake: 9 * platform/network/curl/CookieJarCurl.cpp: 10 (WebCore::setCookiesFromDOM): 11 (WebCore::cookiesForSession): 12 * platform/network/curl/CurlContext.cpp: Added. 13 (WebCore::certificatePath): 14 (WebCore::cookieJarPath): 15 (WebCore::CurlContext::CurlContext): 16 (WebCore::CurlContext::~CurlContext): 17 (WebCore::CurlContext::initCookieSession): 18 (WebCore::CurlContext::ProxyInfo::url): 19 (WebCore::CurlContext::setProxyInfo): 20 (WebCore::CurlContext::getEffectiveURL): 21 (WebCore::CurlContext::createMultiHandle): 22 (WebCore::CurlContext::mutexFor): 23 (WebCore::CurlContext::lock): 24 (WebCore::CurlContext::unlock): 25 * platform/network/curl/CurlContext.h: Added. 26 (WebCore::CurlContext::singleton): 27 (WebCore::CurlContext::curlShareHandle): 28 (WebCore::CurlContext::getCookieJarFileName): 29 (WebCore::CurlContext::setCookieJarFileName): 30 (WebCore::CurlContext::getCertificatePath): 31 (WebCore::CurlContext::shouldIgnoreSSLErrors): 32 (WebCore::CurlContext::proxyInfo): 33 (WebCore::CurlContext::setProxyInfo): 34 (WebCore::CurlContext::getLogFile): 35 (WebCore::CurlContext::isVerbose): 36 * platform/network/curl/CurlDownload.cpp: 37 (WebCore::CurlDownload::init): 38 (WebCore::CurlDownload::start): 39 (WebCore::CurlDownload::cancel): 40 (WebCore::CurlDownload::didReceiveHeader): 41 * platform/network/curl/CurlDownload.h: 42 * platform/network/curl/CurlJobManager.cpp: Renamed from Source/WebCore/platform/network/curl/CurlManager.cpp. 43 (WebCore::CurlJobManager::CurlJobManager): 44 (WebCore::CurlJobManager::~CurlJobManager): 45 (WebCore::CurlJobManager::add): 46 (WebCore::CurlJobManager::remove): 47 (WebCore::CurlJobManager::getActiveCount): 48 (WebCore::CurlJobManager::getPendingCount): 49 (WebCore::CurlJobManager::startThreadIfNeeded): 50 (WebCore::CurlJobManager::stopThread): 51 (WebCore::CurlJobManager::stopThreadIfIdle): 52 (WebCore::CurlJobManager::updateHandleList): 53 (WebCore::CurlJobManager::addToCurl): 54 (WebCore::CurlJobManager::removeFromCurl): 55 (WebCore::CurlJobManager::workerThread): 56 * platform/network/curl/CurlJobManager.h: Renamed from Source/WebCore/platform/network/curl/CurlManager.h. 57 (WebCore::CurlJobManager::singleton): 58 * platform/network/curl/ResourceHandleManager.cpp: 59 (WebCore::ResourceHandleManager::ResourceHandleManager): 60 (WebCore::ResourceHandleManager::~ResourceHandleManager): 61 (WebCore::handleLocalReceiveResponse): 62 (WebCore::getProtectionSpace): 63 (WebCore::headerCallback): 64 (WebCore::ResourceHandleManager::downloadTimerCallback): 65 (WebCore::ResourceHandleManager::initializeHandle): 66 (WebCore::certificatePath): Deleted. 67 (WebCore::cookieJarPath): Deleted. 68 (WebCore::ResourceHandleManager::setCookieJarFileName): Deleted. 69 (WebCore::ResourceHandleManager::getCookieJarFileName): Deleted. 70 (WebCore::ResourceHandleManager::setProxyInfo): Deleted. 71 (WebCore::ResourceHandleManager::initCookieSession): Deleted. 72 * platform/network/curl/ResourceHandleManager.h: 73 (): Deleted. 74 1 75 2017-06-29 Chris Dumez <cdumez@apple.com> 2 76 -
trunk/Source/WebCore/PlatformWinCairo.cmake
r218637 r218947 34 34 platform/network/curl/CurlCacheEntry.cpp 35 35 platform/network/curl/CurlCacheManager.cpp 36 platform/network/curl/CurlContext.cpp 36 37 platform/network/curl/CurlDownload.cpp 37 platform/network/curl/Curl Manager.cpp38 platform/network/curl/CurlJobManager.cpp 38 39 platform/network/curl/DNSCurl.cpp 39 40 platform/network/curl/FormDataStreamCurl.cpp -
trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp
r218637 r218947 23 23 24 24 #include "Cookie.h" 25 #include "Curl Manager.h"25 #include "CurlContext.h" 26 26 #include "NotImplemented.h" 27 #include "ResourceHandleManager.h"28 27 #include "URL.h" 29 28 … … 244 243 void setCookiesFromDOM(const NetworkStorageSession&, const URL&, const URL& url, const String& value) 245 244 { 245 const CurlContext& context = CurlContext::singleton(); 246 246 247 CURL* curl = curl_easy_init(); 247 248 … … 249 250 return; 250 251 251 const char* cookieJarFileName = ResourceHandleManager::sharedInstance()->getCookieJarFileName();252 CURLSH* curlsh = CurlManager::singleton().getCurlShareHandle();252 const char* cookieJarFileName = context.getCookieJarFileName(); 253 CURLSH* curlsh = context.curlShareHandle(); 253 254 254 255 curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieJarFileName); … … 279 280 return cookies; 280 281 281 CURLSH* curlsh = Curl Manager::singleton().getCurlShareHandle();282 CURLSH* curlsh = CurlContext::singleton().curlShareHandle(); 282 283 283 284 curl_easy_setopt(curl, CURLOPT_SHARE, curlsh); -
trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp
r218637 r218947 30 30 #include "CurlDownload.h" 31 31 32 #include "CurlContext.h" 33 32 34 #include "HTTPHeaderNames.h" 33 35 #include "HTTPParsers.h" … … 86 88 curl_easy_setopt(m_curlHandle, CURLOPT_CAINFO, certPath); 87 89 88 CURLSH* curlsh = Curl Manager::singleton().getCurlShareHandle();90 CURLSH* curlsh = CurlContext::singleton().curlShareHandle(); 89 91 if (curlsh) 90 92 curl_easy_setopt(m_curlHandle, CURLOPT_SHARE, curlsh); … … 107 109 bool CurlDownload::start() 108 110 { 109 ref(); // Curl DownloadManager::downloadThreadwill call deref when the download has finished.110 return Curl Manager::singleton().add(m_curlHandle);111 ref(); // CurlJobManager will call deref when the download has finished. 112 return CurlJobManager::singleton().add(m_curlHandle); 111 113 } 112 114 113 115 bool CurlDownload::cancel() 114 116 { 115 return Curl Manager::singleton().remove(m_curlHandle);117 return CurlJobManager::singleton().remove(m_curlHandle); 116 118 } 117 119 … … 204 206 205 207 if (httpCode >= 200 && httpCode < 300) { 206 URL url = Curl Utils::getEffectiveURL(m_curlHandle);208 URL url = CurlContext::singleton().getEffectiveURL(m_curlHandle); 207 209 callOnMainThread([this, url = url.isolatedCopy(), protectedThis = makeRef(*this)] { 208 210 m_response.setURL(url); -
trunk/Source/WebCore/platform/network/curl/CurlDownload.h
r218637 r218947 37 37 #endif 38 38 39 #include "Curl Manager.h"39 #include "CurlJobManager.h" 40 40 41 41 namespace WebCore { -
trunk/Source/WebCore/platform/network/curl/CurlJobManager.cpp
r218944 r218947 28 28 29 29 #if USE(CURL) 30 #include "CurlManager.h" 30 #include "CurlJobManager.h" 31 32 #include "CurlContext.h" 31 33 32 34 #include <wtf/MainThread.h> … … 37 39 namespace WebCore { 38 40 39 class CurlSharedResources { 40 public: 41 static void lock(CURL*, curl_lock_data, curl_lock_access, void*); 42 static void unlock(CURL*, curl_lock_data, void*); 43 44 private: 45 static Lock* mutexFor(curl_lock_data); 46 }; 47 48 // CurlDownloadManager ------------------------------------------------------------------- 49 50 CurlManager::CurlManager() 51 { 52 curl_global_init(CURL_GLOBAL_ALL); 53 m_curlMultiHandle = curl_multi_init(); 54 m_curlShareHandle = curl_share_init(); 55 curl_share_setopt(m_curlShareHandle, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); 56 curl_share_setopt(m_curlShareHandle, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); 57 curl_share_setopt(m_curlShareHandle, CURLSHOPT_LOCKFUNC, CurlSharedResources::lock); 58 curl_share_setopt(m_curlShareHandle, CURLSHOPT_UNLOCKFUNC, CurlSharedResources::unlock); 59 } 60 61 CurlManager::~CurlManager() 41 CurlJobManager::CurlJobManager() 42 { 43 m_curlMultiHandle = CurlContext::singleton().createMultiHandle(); 44 } 45 46 CurlJobManager::~CurlJobManager() 62 47 { 63 48 stopThread(); 64 49 curl_multi_cleanup(m_curlMultiHandle); 65 curl_share_cleanup(m_curlShareHandle); 66 curl_global_cleanup(); 67 } 68 69 bool CurlManager::add(CURL* curlHandle) 50 } 51 52 bool CurlJobManager::add(CURL* curlHandle) 70 53 { 71 54 ASSERT(isMainThread()); … … 81 64 } 82 65 83 bool Curl Manager::remove(CURL* curlHandle)66 bool CurlJobManager::remove(CURL* curlHandle) 84 67 { 85 68 LockHolder locker(m_mutex); … … 90 73 } 91 74 92 int Curl Manager::getActiveCount() const75 int CurlJobManager::getActiveCount() const 93 76 { 94 77 LockHolder locker(m_mutex); … … 96 79 } 97 80 98 int Curl Manager::getPendingCount() const81 int CurlJobManager::getPendingCount() const 99 82 { 100 83 LockHolder locker(m_mutex); … … 102 85 } 103 86 104 void Curl Manager::startThreadIfNeeded()87 void CurlJobManager::startThreadIfNeeded() 105 88 { 106 89 ASSERT(isMainThread()); … … 116 99 } 117 100 118 void CurlManager::stopThread() 119 { 120 ASSERT(isMainThread()); 121 101 void CurlJobManager::stopThread() 102 { 122 103 setRunThread(false); 123 104 … … 128 109 } 129 110 130 void Curl Manager::stopThreadIfIdle()111 void CurlJobManager::stopThreadIfIdle() 131 112 { 132 113 if (!getActiveCount() && !getPendingCount()) … … 134 115 } 135 116 136 void Curl Manager::updateHandleList()117 void CurlJobManager::updateHandleList() 137 118 { 138 119 LockHolder locker(m_mutex); … … 153 134 } 154 135 155 bool Curl Manager::addToCurl(CURL* curlHandle)136 bool CurlJobManager::addToCurl(CURL* curlHandle) 156 137 { 157 138 CURLMcode retval = curl_multi_add_handle(m_curlMultiHandle, curlHandle); … … 163 144 } 164 145 165 bool Curl Manager::removeFromCurl(CURL* curlHandle)146 bool CurlJobManager::removeFromCurl(CURL* curlHandle) 166 147 { 167 148 int handlePos = m_activeHandleList.find(curlHandle); … … 179 160 } 180 161 181 void Curl Manager::workerThread()162 void CurlJobManager::workerThread() 182 163 { 183 164 ASSERT(!isMainThread()); … … 237 218 } 238 219 239 // CURL Utilities240 241 URL CurlUtils::getEffectiveURL(CURL* handle)242 {243 const char* url;244 CURLcode err = curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url);245 if (CURLE_OK != err)246 return URL();247 return URL(URL(), url);248 }249 250 // Shared Resource management =======================251 252 Lock* CurlSharedResources::mutexFor(curl_lock_data data)253 {254 DEPRECATED_DEFINE_STATIC_LOCAL(Lock, cookieMutex, ());255 DEPRECATED_DEFINE_STATIC_LOCAL(Lock, dnsMutex, ());256 DEPRECATED_DEFINE_STATIC_LOCAL(Lock, shareMutex, ());257 258 switch (data) {259 case CURL_LOCK_DATA_COOKIE:260 return &cookieMutex;261 case CURL_LOCK_DATA_DNS:262 return &dnsMutex;263 case CURL_LOCK_DATA_SHARE:264 return &shareMutex;265 default:266 ASSERT_NOT_REACHED();267 return nullptr;268 }269 }270 271 // libcurl does not implement its own thread synchronization primitives.272 // these two functions provide mutexes for cookies, and for the global DNS273 // cache.274 void CurlSharedResources::lock(CURL* /* handle */, curl_lock_data data, curl_lock_access /* access */, void* /* userPtr */)275 {276 if (Lock* mutex = CurlSharedResources::mutexFor(data))277 mutex->lock();278 }279 280 void CurlSharedResources::unlock(CURL* /* handle */, curl_lock_data data, void* /* userPtr */)281 {282 if (Lock* mutex = CurlSharedResources::mutexFor(data))283 mutex->unlock();284 }285 286 220 } 287 221 -
trunk/Source/WebCore/platform/network/curl/CurlJobManager.h
r218944 r218947 29 29 #include <wtf/Lock.h> 30 30 #include <wtf/Threading.h> 31 #include <wtf/Vector.h> 31 32 32 33 #if PLATFORM(WIN) … … 36 37 37 38 #include <curl/curl.h> 38 #include "URL.h"39 39 40 40 namespace WebCore { … … 47 47 }; 48 48 49 class Curl Manager {49 class CurlJobManager { 50 50 public: 51 static Curl Manager& singleton()51 static CurlJobManager& singleton() 52 52 { 53 53 // Since it's a static variable, if the class has already been created, … … 55 55 // And it **is** thread-safe in C++11. 56 56 57 static Curl Manager shared;57 static CurlJobManager shared; 58 58 return shared; 59 59 } 60 60 61 Curl Manager();62 virtual ~Curl Manager();61 CurlJobManager(); 62 virtual ~CurlJobManager(); 63 63 64 64 bool add(CURL* curlHandle); … … 67 67 int getActiveCount() const; 68 68 int getPendingCount() const; 69 70 CURLSH* getCurlShareHandle() const { return m_curlShareHandle; }71 69 72 70 private: … … 95 93 bool m_runThread { false }; 96 94 97 CURLSH* m_curlShareHandle { nullptr };98 99 95 friend class CurlJob; 100 96 }; 101 97 102 class CurlUtils {103 public:104 static URL getEffectiveURL(CURL* handle);105 };106 107 98 } -
trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp
r218637 r218947 43 43 #include "CredentialStorage.h" 44 44 #include "CurlCacheManager.h" 45 #include "Curl Manager.h"45 #include "CurlContext.h" 46 46 #include "HTTPHeaderNames.h" 47 47 #include "HTTPParsers.h" … … 61 61 62 62 #if OS(WINDOWS) 63 #include "WebCoreBundleWin.h"64 #include <shlobj.h>65 #include <shlwapi.h>66 63 #else 67 64 #include <sys/param.h> … … 74 71 #include <wtf/CurrentTime.h> 75 72 #endif 76 #if USE(CF)77 #include <wtf/RetainPtr.h>78 #endif79 73 #include <wtf/Lock.h> 80 74 #include <wtf/Threading.h> 81 75 #include <wtf/Vector.h> 82 #include <wtf/text/CString.h>83 76 84 77 namespace WebCore { … … 89 82 const char* const errorDomainCurl = "CurlErrorDomain"; 90 83 91 static const bool ignoreSSLErrors = getenv("WEBKIT_IGNORE_SSL_ERRORS");92 93 static CString certificatePath()94 {95 char* envPath = getenv("CURL_CA_BUNDLE_PATH");96 if (envPath)97 return envPath;98 99 #if USE(CF)100 CFBundleRef webKitBundleRef = webKitBundle();101 if (webKitBundleRef) {102 RetainPtr<CFURLRef> certURLRef = adoptCF(CFBundleCopyResourceURL(webKitBundleRef, CFSTR("cacert"), CFSTR("pem"), CFSTR("certificates")));103 if (certURLRef) {104 char path[MAX_PATH];105 CFURLGetFileSystemRepresentation(certURLRef.get(), false, reinterpret_cast<UInt8*>(path), MAX_PATH);106 return path;107 }108 }109 #endif110 111 return CString();112 }113 114 static char* cookieJarPath()115 {116 char* cookieJarPath = getenv("CURL_COOKIE_JAR_PATH");117 if (cookieJarPath)118 return fastStrDup(cookieJarPath);119 120 #if OS(WINDOWS)121 char executablePath[MAX_PATH];122 char appDataDirectory[MAX_PATH];123 char cookieJarFullPath[MAX_PATH];124 char cookieJarDirectory[MAX_PATH];125 126 if (FAILED(::SHGetFolderPathA(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory))127 || FAILED(::GetModuleFileNameA(0, executablePath, MAX_PATH)))128 return fastStrDup("cookies.dat");129 130 ::PathRemoveExtensionA(executablePath);131 LPSTR executableName = ::PathFindFileNameA(executablePath);132 sprintf_s(cookieJarDirectory, MAX_PATH, "%s/%s", appDataDirectory, executableName);133 sprintf_s(cookieJarFullPath, MAX_PATH, "%s/cookies.dat", cookieJarDirectory);134 135 if (::SHCreateDirectoryExA(0, cookieJarDirectory, 0) != ERROR_SUCCESS136 && ::GetLastError() != ERROR_FILE_EXISTS137 && ::GetLastError() != ERROR_ALREADY_EXISTS)138 return fastStrDup("cookies.dat");139 140 return fastStrDup(cookieJarFullPath);141 #else142 return fastStrDup("cookies.dat");143 #endif144 }145 146 84 #if ENABLE(WEB_TIMING) 147 85 static void calculateWebTimingInformations(ResourceHandleInternal* d) … … 193 131 ResourceHandleManager::ResourceHandleManager() 194 132 : m_downloadTimer(*this, &ResourceHandleManager::downloadTimerCallback) 195 , m_cookieJarFileName(cookieJarPath())196 , m_certificatePath(certificatePath())197 133 , m_runningJobs(0) 198 #ifndef NDEBUG 199 , m_logFile(nullptr) 200 #endif 201 { 202 CURLSH* h = CurlManager::singleton().getCurlShareHandle(); 203 m_curlShareHandle = h; 204 m_curlMultiHandle = curl_multi_init(); 205 206 207 initCookieSession(); 208 209 #ifndef NDEBUG 210 char* logFile = getenv("CURL_LOG_FILE"); 211 if (logFile) 212 m_logFile = fopen(logFile, "a"); 213 #endif 134 { 135 m_curlMultiHandle = CurlContext::singleton().createMultiHandle(); 214 136 } 215 137 … … 217 139 { 218 140 curl_multi_cleanup(m_curlMultiHandle); 219 if (m_cookieJarFileName)220 fastFree(m_cookieJarFileName);221 222 #ifndef NDEBUG223 if (m_logFile)224 fclose(m_logFile);225 #endif226 }227 228 void ResourceHandleManager::setCookieJarFileName(const char* cookieJarFileName)229 {230 m_cookieJarFileName = fastStrDup(cookieJarFileName);231 }232 233 const char* ResourceHandleManager::getCookieJarFileName() const234 {235 return m_cookieJarFileName;236 141 } 237 142 … … 251 156 // Run the code here for local files to resolve the issue. 252 157 // TODO: See if there is a better approach for handling this. 253 URL url = Curl Utils::getEffectiveURL(handle);158 URL url = CurlContext::singleton().getEffectiveURL(handle); 254 159 ASSERT(url.isValid()); 255 160 d->m_response.setURL(url); … … 362 267 return false; 363 268 364 URL url = Curl Utils::getEffectiveURL(h);269 URL url = CurlContext::singleton().getEffectiveURL(h); 365 270 if (!url.isValid()) 366 271 return false; … … 451 356 d->m_response.setExpectedContentLength(static_cast<long long int>(contentLength)); 452 357 453 d->m_response.setURL(Curl Utils::getEffectiveURL(h));358 d->m_response.setURL(CurlContext::singleton().getEffectiveURL(h)); 454 359 455 360 d->m_response.setHTTPStatusCode(httpCode); … … 658 563 } 659 564 } else { 660 URL url = Curl Utils::getEffectiveURL(d->m_handle);565 URL url = CurlContext::singleton().getEffectiveURL(d->m_handle); 661 566 #ifndef NDEBUG 662 567 fprintf(stderr, "Curl ERROR for url='%s', error: '%s'\n", url.string().utf8().data(), curl_easy_strerror(msg->data.result)); … … 677 582 if (!m_downloadTimer.isActive() && (started || (runningHandles > 0))) 678 583 m_downloadTimer.startOneShot(pollTime); 679 }680 681 void ResourceHandleManager::setProxyInfo(const String& host,682 unsigned long port,683 ProxyType type,684 const String& username,685 const String& password)686 {687 m_proxyType = type;688 689 if (!host.length()) {690 m_proxy = emptyString();691 } else {692 String userPass;693 if (username.length() || password.length())694 userPass = username + ":" + password + "@";695 696 m_proxy = String("http://") + userPass + host + ":" + String::number(port);697 }698 584 } 699 585 … … 1020 906 void ResourceHandleManager::initializeHandle(ResourceHandle* job) 1021 907 { 908 CurlContext& context = CurlContext::singleton(); 909 1022 910 static const int allowedProtocols = CURLPROTO_FILE | CURLPROTO_FTP | CURLPROTO_FTPS | CURLPROTO_HTTP | CURLPROTO_HTTPS; 1023 911 URL url = job->firstRequest().url(); … … 1049 937 } 1050 938 #ifndef NDEBUG 1051 if ( getenv("DEBUG_CURL"))939 if (context.isVerbose()) 1052 940 curl_easy_setopt(d->m_handle, CURLOPT_VERBOSE, 1); 1053 if ( m_logFile)1054 curl_easy_setopt(d->m_handle, CURLOPT_STDERR, m_logFile);941 if (context.getLogFile()) 942 curl_easy_setopt(d->m_handle, CURLOPT_STDERR, context.getLogFile()); 1055 943 #endif 1056 944 curl_easy_setopt(d->m_handle, CURLOPT_SSL_VERIFYPEER, 1L); … … 1066 954 curl_easy_setopt(d->m_handle, CURLOPT_MAXREDIRS, 10); 1067 955 curl_easy_setopt(d->m_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 1068 curl_easy_setopt(d->m_handle, CURLOPT_SHARE, m_curlShareHandle);956 curl_easy_setopt(d->m_handle, CURLOPT_SHARE, CurlContext::singleton().curlShareHandle()); 1069 957 curl_easy_setopt(d->m_handle, CURLOPT_DNS_CACHE_TIMEOUT, 60 * 5); // 5 minutes 1070 958 curl_easy_setopt(d->m_handle, CURLOPT_PROTOCOLS, allowedProtocols); … … 1072 960 setSSLClientCertificate(job); 1073 961 1074 if ( ignoreSSLErrors)962 if (context.shouldIgnoreSSLErrors()) 1075 963 curl_easy_setopt(d->m_handle, CURLOPT_SSL_VERIFYPEER, false); 1076 964 else 1077 965 setSSLVerifyOptions(job); 1078 966 1079 if (!m_certificatePath.isNull()) 1080 curl_easy_setopt(d->m_handle, CURLOPT_CAINFO, m_certificatePath.data()); 967 const char* certificate = context.getCertificatePath(); 968 if (certificate) 969 curl_easy_setopt(d->m_handle, CURLOPT_CAINFO, certificate); 1081 970 1082 971 // enable gzip and deflate through Accept-Encoding: … … 1090 979 curl_easy_setopt(d->m_handle, CURLOPT_URL, d->m_url); 1091 980 1092 if (m_cookieJarFileName) 1093 curl_easy_setopt(d->m_handle, CURLOPT_COOKIEJAR, m_cookieJarFileName); 981 const char* cookieJar = context.getCookieJarFileName(); 982 if (cookieJar) 983 curl_easy_setopt(d->m_handle, CURLOPT_COOKIEJAR, cookieJar); 1094 984 1095 985 struct curl_slist* headers = 0; … … 1151 1041 1152 1042 // Set proxy options if we have them. 1153 if (m_proxy.length()) { 1154 curl_easy_setopt(d->m_handle, CURLOPT_PROXY, m_proxy.utf8().data()); 1155 curl_easy_setopt(d->m_handle, CURLOPT_PROXYTYPE, m_proxyType); 1156 } 1157 } 1158 1159 void ResourceHandleManager::initCookieSession() 1160 { 1161 // Curl saves both persistent cookies, and session cookies to the cookie file. 1162 // The session cookies should be deleted before starting a new session. 1163 1164 CURL* curl = curl_easy_init(); 1165 1166 if (!curl) 1167 return; 1168 1169 curl_easy_setopt(curl, CURLOPT_SHARE, m_curlShareHandle); 1170 1171 if (m_cookieJarFileName) { 1172 curl_easy_setopt(curl, CURLOPT_COOKIEFILE, m_cookieJarFileName); 1173 curl_easy_setopt(curl, CURLOPT_COOKIEJAR, m_cookieJarFileName); 1174 } 1175 1176 curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1); 1177 1178 curl_easy_cleanup(curl); 1043 auto& proxy = CurlContext::singleton().proxyInfo(); 1044 if (proxy.type != CurlProxyType::Invalid) { 1045 curl_easy_setopt(d->m_handle, CURLOPT_PROXY, proxy.url().utf8().data()); 1046 curl_easy_setopt(d->m_handle, CURLOPT_PROXYTYPE, proxy.type); 1047 } 1179 1048 } 1180 1049 -
trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.h
r218637 r218947 47 47 class ResourceHandleManager { 48 48 public: 49 enum ProxyType {50 HTTP = CURLPROXY_HTTP,51 Socks4 = CURLPROXY_SOCKS4,52 Socks4A = CURLPROXY_SOCKS4A,53 Socks5 = CURLPROXY_SOCKS5,54 Socks5Hostname = CURLPROXY_SOCKS5_HOSTNAME55 };56 49 static ResourceHandleManager* sharedInstance(); 57 50 void add(ResourceHandle*); 58 51 void cancel(ResourceHandle*); 59 60 void setCookieJarFileName(const char* cookieJarFileName);61 const char* getCookieJarFileName() const;62 52 63 53 void dispatchSynchronousJob(ResourceHandle*); … … 65 55 void setupPOST(ResourceHandle*, struct curl_slist**); 66 56 void setupPUT(ResourceHandle*, struct curl_slist**); 67 68 void setProxyInfo(const String& host = emptyString(), unsigned long port = 0, ProxyType = HTTP, const String& username = emptyString(), const String& password = emptyString());69 57 70 58 private: … … 80 68 void initializeHandle(ResourceHandle*); 81 69 82 void initCookieSession();83 84 70 Timer m_downloadTimer; 85 71 CURLM* m_curlMultiHandle; 86 CURLSH* m_curlShareHandle;87 char* m_cookieJarFileName;88 72 char m_curlErrorBuffer[CURL_ERROR_SIZE]; 89 73 Vector<ResourceHandle*> m_resourceHandleList; 90 const CString m_certificatePath;91 74 int m_runningJobs; 92 93 String m_proxy;94 ProxyType m_proxyType;95 96 #ifndef NDEBUG97 FILE* m_logFile;98 #endif99 75 }; 100 76
Note: See TracChangeset
for help on using the changeset viewer.