[WinCairo] Download should use header values from provided request object.
authorpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jan 2016 11:41:29 +0000 (11:41 +0000)
committerpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jan 2016 11:41:29 +0000 (11:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152694

Reviewed by Alex Christensen.

Copy header values from request object parameter.

* WebDownloadCurl.cpp:
(WebDownload::initWithRequest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194581 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/win/ChangeLog
Source/WebKit/win/WebDownloadCurl.cpp

index 4523c8a..c089558 100644 (file)
@@ -1,3 +1,15 @@
+2016-01-05  Per Arne Vollan  <peavo@outlook.com>
+
+        [WinCairo] Download should use header values from provided request object.
+        https://bugs.webkit.org/show_bug.cgi?id=152694
+
+        Reviewed by Alex Christensen.
+
+        Copy header values from request object parameter.
+
+        * WebDownloadCurl.cpp:
+        (WebDownload::initWithRequest):
+
 2015-12-31  Andy Estes  <aestes@apple.com>
 
         Replace WTF::move with WTFMove
index a1fd9f1..6c4e16d 100644 (file)
@@ -83,12 +83,26 @@ HRESULT WebDownload::initWithRequest(
         /* [in] */ IWebURLRequest* request, 
         /* [in] */ IWebDownloadDelegate* delegate)
 {
+    if (!request)
+        return E_POINTER;
+
+    COMPtr<WebMutableURLRequest> webRequest;
+    if (FAILED(request->QueryInterface(&webRequest)))
+        return E_FAIL;
+
     BString url;
 
     if (!SUCCEEDED(request->URL(&url)))
         return E_FAIL;
 
-    init(URL(ParsedURLString, String(url)), delegate);
+    ResourceRequest resourceRequest;
+    resourceRequest.setURL(URL(ParsedURLString, String(url)));
+
+    const HTTPHeaderMap& headerMap = webRequest->httpHeaderFields();
+    for (HTTPHeaderMap::const_iterator it = headerMap.begin(); it != headerMap.end(); ++it)
+        resourceRequest.setHTTPHeaderField(it->key, it->value);
+
+    init(nullptr, resourceRequest, ResourceResponse(), delegate);
 
     return S_OK;
 }