void ResourceRequest::doUpdatePlatformRequest() { CFMutableURLRequestRef cfRequest; RetainPtr<CFURLRef> url(AdoptCF, ResourceRequest::url().createCFURL()); RetainPtr<CFURLRef> firstPartyForCookies(AdoptCF, 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()); } RetainPtr<CFStringRef> requestMethod(AdoptCF, httpMethod().createCFString()); CFURLRequestSetHTTPRequestMethod(cfRequest, requestMethod.get()); addHeadersFromHashMap(cfRequest, httpHeaderFields()); WebCore::setHTTPBody(cfRequest, httpBody()); CFURLRequestSetShouldHandleHTTPCookies(cfRequest, allowHTTPCookies()); unsigned fallbackCount = m_responseContentDispositionEncodingFallbackArray.size(); RetainPtr<CFMutableArrayRef> encodingFallbacks(AdoptCF, CFArrayCreateMutable(kCFAllocatorDefault, fallbackCount, 0)); for (unsigned i = 0; i != fallbackCount; ++i) { RetainPtr<CFStringRef> encodingName(AdoptCF, 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 (m_cfRequest) { RetainPtr<CFHTTPCookieStorageRef> cookieStorage(AdoptCF, CFURLRequestCopyHTTPCookieStorage(m_cfRequest.get())); if (cookieStorage) CFURLRequestSetHTTPCookieStorage(cfRequest, cookieStorage.get()); CFURLRequestSetHTTPCookieStorageAcceptPolicy(cfRequest, CFURLRequestGetHTTPCookieStorageAcceptPolicy(m_cfRequest.get())); CFURLRequestSetSSLProperties(cfRequest, CFURLRequestGetSSLProperties(m_cfRequest.get())); } m_cfRequest.adoptCF(cfRequest); }
CFURLRequestRef cfURLRequest(const ResourceRequest& request) { CFURLRef url = request.url().createCFURL(); CFURLRef mainDocumentURL = request.mainDocumentURL().createCFURL(); CFMutableURLRequestRef cfRequest = CFURLRequestCreateMutable(0, url, (CFURLRequestCachePolicy)request.cachePolicy(), request.timeoutInterval(), mainDocumentURL); CFRelease(url); CFRelease(mainDocumentURL); CFStringRef requestMethod = request.httpMethod().createCFString(); CFURLRequestSetHTTPRequestMethod(cfRequest, requestMethod); CFRelease(requestMethod); addHeadersFromHashMap(cfRequest, request.httpHeaderFields()); setHTTPBody(cfRequest, request.httpBody()); CFURLRequestSetShouldHandleHTTPCookies(cfRequest, request.allowHTTPCookies()); return cfRequest; }