// FIXME: It is confusing that this function both sets connection count and determines maximum request count at network layer. This can and should be done separately. unsigned initializeMaximumHTTPConnectionCountPerHost() { static const unsigned preferredConnectionCount = 6; static const unsigned unlimitedRequestCount = 10000; _CFNetworkHTTPConnectionCacheSetLimit(kHTTPLoadWidth, preferredConnectionCount); unsigned maximumHTTPConnectionCountPerHost = _CFNetworkHTTPConnectionCacheGetLimit(kHTTPLoadWidth); Boolean keyExistsAndHasValidFormat = false; Boolean prefValue = CFPreferencesGetAppBooleanValue(CFSTR("WebKitEnableHTTPPipelining"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); if (keyExistsAndHasValidFormat) ResourceRequest::setHTTPPipeliningEnabled(prefValue); // Use WebCore scheduler when we can't use request priorities with CFNetwork. if (!ResourceRequest::resourcePrioritiesEnabled()) return maximumHTTPConnectionCountPerHost; _CFNetworkHTTPConnectionCacheSetLimit(kHTTPPriorityNumLevels, toPlatformRequestPriority(ResourceLoadPriority::Highest)); #if !PLATFORM(WIN) // FIXME: <rdar://problem/9375609> Implement minimum fast lane priority setting on Windows _CFNetworkHTTPConnectionCacheSetLimit(kHTTPMinimumFastLanePriority, toPlatformRequestPriority(ResourceLoadPriority::Medium)); #endif return unlimitedRequestCount; }
void initializeHTTPConnectionSettingsOnStartup() { // This need to be called from WebKitInitialize so the calls happen early enough, before any requests are made. <rdar://problem/9691871> // Desktop doesn't have early initialization so it is not clear how this should be done there. The CFNetwork SPI probably // needs to become more forgiving. // We can't read settings here as this is called too early for that. All values need to be constants. static const unsigned preferredConnectionCount = 6; static const unsigned fastLaneConnectionCount = 1; _CFNetworkHTTPConnectionCacheSetLimit(kHTTPLoadWidth, preferredConnectionCount); _CFNetworkHTTPConnectionCacheSetLimit(kHTTPPriorityNumLevels, toPlatformRequestPriority(ResourceLoadPriority::Highest)); _CFNetworkHTTPConnectionCacheSetLimit(kHTTPMinimumFastLanePriority, toPlatformRequestPriority(ResourceLoadPriority::Medium)); _CFNetworkHTTPConnectionCacheSetLimit(kHTTPNumFastLanes, fastLaneConnectionCount); }
void ResourceRequest::doUpdatePlatformRequest() { CFMutableURLRequestRef cfRequest; RetainPtr<CFURLRef> url = ResourceRequest::url().createCFURL(); RetainPtr<CFURLRef> firstPartyForCookies = ResourceRequest::firstPartyForCookies().createCFURL(); if (m_cfRequest) { cfRequest = CFURLRequestCreateMutableCopy(0, m_cfRequest.get()); CFURLRequestSetURL(cfRequest, url.get()); CFURLRequestSetMainDocumentURL(cfRequest, firstPartyForCookies.get()); CFURLRequestSetCachePolicy(cfRequest, (CFURLRequestCachePolicy)cachePolicy()); CFURLRequestSetTimeoutInterval(cfRequest, timeoutInterval()); } else cfRequest = CFURLRequestCreateMutable(0, url.get(), (CFURLRequestCachePolicy)cachePolicy(), timeoutInterval(), firstPartyForCookies.get()); CFURLRequestSetHTTPRequestMethod(cfRequest, httpMethod().createCFString().get()); if (httpPipeliningEnabled()) CFURLRequestSetShouldPipelineHTTP(cfRequest, true, true); if (resourcePrioritiesEnabled()) CFURLRequestSetRequestPriority(cfRequest, toPlatformRequestPriority(priority())); #if !PLATFORM(WIN) _CFURLRequestSetProtocolProperty(cfRequest, kCFURLRequestAllowAllPOSTCaching, kCFBooleanTrue); #endif setHeaderFields(cfRequest, httpHeaderFields()); CFURLRequestSetShouldHandleHTTPCookies(cfRequest, allowCookies()); unsigned fallbackCount = m_responseContentDispositionEncodingFallbackArray.size(); RetainPtr<CFMutableArrayRef> encodingFallbacks = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, fallbackCount, 0)); for (unsigned i = 0; i != fallbackCount; ++i) { RetainPtr<CFStringRef> encodingName = m_responseContentDispositionEncodingFallbackArray[i].createCFString(); CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding(encodingName.get()); if (encoding != kCFStringEncodingInvalidId) CFArrayAppendValue(encodingFallbacks.get(), reinterpret_cast<const void*>(encoding)); } setContentDispositionEncodingFallbackArray(cfRequest, encodingFallbacks.get()); #if ENABLE(CACHE_PARTITIONING) String partition = cachePartition(); if (!partition.isNull() && !partition.isEmpty()) { CString utf8String = partition.utf8(); RetainPtr<CFStringRef> partitionValue = adoptCF(CFStringCreateWithBytes(0, reinterpret_cast<const UInt8*>(utf8String.data()), utf8String.length(), kCFStringEncodingUTF8, false)); _CFURLRequestSetProtocolProperty(cfRequest, wkCachePartitionKey(), partitionValue.get()); } #endif m_cfRequest = adoptCF(cfRequest); #if PLATFORM(COCOA) clearOrUpdateNSURLRequest(); #endif }
unsigned initializeMaximumHTTPConnectionCountPerHost() { static const unsigned preferredConnectionCount = 6; static const unsigned unlimitedConnectionCount = 10000; wkInitializeMaximumHTTPConnectionCountPerHost(preferredConnectionCount); Boolean keyExistsAndHasValidFormat = false; Boolean prefValue = CFPreferencesGetAppBooleanValue(CFSTR("WebKitEnableHTTPPipelining"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); if (keyExistsAndHasValidFormat) ResourceRequest::setHTTPPipeliningEnabled(prefValue); wkSetHTTPRequestMaximumPriority(toPlatformRequestPriority(ResourceLoadPriorityHighest)); #if !PLATFORM(WIN) // FIXME: <rdar://problem/9375609> Implement minimum fast lane priority setting on Windows wkSetHTTPRequestMinimumFastLanePriority(toPlatformRequestPriority(ResourceLoadPriorityMedium)); #endif return unlimitedConnectionCount; }