https://bugs.webkit.org/show_bug.cgi?id=53330
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / win / WebPageWin.cpp
index 8a1a126..e20af3a 100644 (file)
@@ -262,6 +262,27 @@ bool WebPage::platformHasLocalDataForURL(const WebCore::KURL& url)
 #endif
 }
 
+String WebPage::cachedResponseMIMETypeForURL(const WebCore::KURL& url)
+{
+#if USE(CFNETWORK)
+    RetainPtr<CFURLRef> cfURL(AdoptCF, url.createCFURL());
+    RetainPtr<CFMutableURLRequestRef> request(AdoptCF, CFURLRequestCreateMutable(0, cfURL.get(), kCFURLRequestCachePolicyReloadIgnoringCache, 60, 0));
+    
+    RetainPtr<CFStringRef> userAgent(AdoptCF, userAgent().createCFString());
+    CFURLRequestSetHTTPHeaderFieldValue(request.get(), CFSTR("User-Agent"), userAgent.get());
+
+    RetainPtr<CFURLCacheRef> cache(AdoptCF, CFURLCacheCopySharedURLCache());
+
+    RetainPtr<CFCachedURLResponseRef> cachedResponse(AdoptCF, CFURLCacheCopyResponseForRequest(cache.get(), request.get()));
+    
+    CFURLResponseRef response = CFCachedURLResponseGetWrappedResponse(cachedResponse.get());
+    
+    return response ? CFURLResponseGetMIMEType(response) : String();
+#else
+    return String();
+#endif
+}
+
 bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request)
 {
 #if USE(CFNETWORK)