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

This commit is contained in:
Hans Leidekker 2015-06-12 15:05:59 +02:00 committed by Alexandre Julliard
parent dcfe6648f8
commit 1e800c7b94
3 changed files with 62 additions and 5 deletions

View File

@ -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;

View File

@ -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(

View File

@ -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;