Hans Leidekker : qmgr: Implement IBackgroundCopyJobHttpOptions:: SetCustomHeaders and IBackgroundCopyJobHttpOptions::GetCustomHeaders.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jun 15 08:49:07 CDT 2015


Module: wine
Branch: master
Commit: 1e800c7b944e79e85268290510322bf888d637c3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1e800c7b944e79e85268290510322bf888d637c3

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Fri Jun 12 15:05:59 2015 +0200

qmgr: Implement IBackgroundCopyJobHttpOptions::SetCustomHeaders and IBackgroundCopyJobHttpOptions::GetCustomHeaders.

---

 dlls/qmgr/file.c |  2 +-
 dlls/qmgr/job.c  | 51 +++++++++++++++++++++++++++++++++++++++++++++++----
 dlls/qmgr/qmgr.h | 14 ++++++++++++++
 3 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/dlls/qmgr/file.c b/dlls/qmgr/file.c
index 3c92bb0..55e93aa 100644
--- a/dlls/qmgr/file.c
+++ b/dlls/qmgr/file.c
@@ -340,7 +340,7 @@ static BOOL transfer_file_http(BackgroundCopyFileImpl *file, URL_COMPONENTSW *uc
     if (!(con = WinHttpConnect(ses, uc->lpszHostName, uc->nPort, 0))) goto done;
     if (!(req = WinHttpOpenRequest(con, NULL, uc->lpszUrlPath, NULL, NULL, NULL, flags))) goto done;
 
-    if (!(WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, (DWORD_PTR)file))) goto done;
+    if (!(WinHttpSendRequest(req, job->http_options.headers, ~0u, NULL, 0, 0, (DWORD_PTR)file))) goto done;
     if (wait_for_completion(job) || job->error.code) goto done;
 
     if (!(WinHttpReceiveResponse(req, NULL))) goto done;
diff --git a/dlls/qmgr/job.c b/dlls/qmgr/job.c
index 8ee6498..9595616 100644
--- a/dlls/qmgr/job.c
+++ b/dlls/qmgr/job.c
@@ -976,16 +976,59 @@ static HRESULT WINAPI http_options_SetCustomHeaders(
     IBackgroundCopyJobHttpOptions *iface,
     LPCWSTR RequestHeaders)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJobHttpOptions(iface);
+
+    TRACE("(%p)->(%s)\n", iface, debugstr_w(RequestHeaders));
+
+    EnterCriticalSection(&job->cs);
+
+    if (RequestHeaders)
+    {
+        WCHAR *headers = strdupW(RequestHeaders);
+        if (!headers)
+        {
+            LeaveCriticalSection(&job->cs);
+            return E_OUTOFMEMORY;
+        }
+        HeapFree(GetProcessHeap(), 0, job->http_options.headers);
+        job->http_options.headers = headers;
+    }
+    else
+    {
+        HeapFree(GetProcessHeap(), 0, job->http_options.headers);
+        job->http_options.headers = NULL;
+    }
+
+    LeaveCriticalSection(&job->cs);
+    return S_OK;
 }
 
 static HRESULT WINAPI http_options_GetCustomHeaders(
     IBackgroundCopyJobHttpOptions *iface,
     LPWSTR *pRequestHeaders)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJobHttpOptions(iface);
+
+    TRACE("(%p)->(%p)\n", iface, pRequestHeaders);
+
+    EnterCriticalSection(&job->cs);
+
+    if (job->http_options.headers)
+    {
+        WCHAR *headers = co_strdupW(job->http_options.headers);
+        if (!headers)
+        {
+            LeaveCriticalSection(&job->cs);
+            return E_OUTOFMEMORY;
+        }
+        *pRequestHeaders = headers;
+        LeaveCriticalSection(&job->cs);
+        return S_OK;
+    }
+
+    *pRequestHeaders = NULL;
+    LeaveCriticalSection(&job->cs);
+    return S_FALSE;
 }
 
 static HRESULT WINAPI http_options_SetSecurityFlags(
diff --git a/dlls/qmgr/qmgr.h b/dlls/qmgr/qmgr.h
index 4b9d2fb..268fabc 100644
--- a/dlls/qmgr/qmgr.h
+++ b/dlls/qmgr/qmgr.h
@@ -115,6 +115,20 @@ void processJob(BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
 BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
 
 /* Little helper functions */
+static inline WCHAR *strdupW(const WCHAR *src)
+{
+    WCHAR *dst = HeapAlloc(GetProcessHeap(), 0, (strlenW(src) + 1) * sizeof(WCHAR));
+    if (dst) strcpyW(dst, src);
+    return dst;
+}
+
+static inline WCHAR *co_strdupW(const WCHAR *src)
+{
+    WCHAR *dst = CoTaskMemAlloc((strlenW(src) + 1) * sizeof(WCHAR));
+    if (dst) strcpyW(dst, src);
+    return dst;
+}
+
 static inline HRESULT return_strval(const WCHAR *str, WCHAR **ret)
 {
     int len;




More information about the wine-cvs mailing list