[PATCH 4/5] Store user defined request headers on transaction beginning
Nikolay Sivov
nsivov at codeweavers.com
Sat Sep 25 14:31:48 CDT 2010
---
dlls/msxml3/httprequest.c | 64 +++++++++++++++++++++++++++++++++++++++-----
1 files changed, 56 insertions(+), 8 deletions(-)
diff --git a/dlls/msxml3/httprequest.c b/dlls/msxml3/httprequest.c
index e626838..210012a 100644
--- a/dlls/msxml3/httprequest.c
+++ b/dlls/msxml3/httprequest.c
@@ -43,6 +43,13 @@ static const WCHAR MethodPostW[] = {'P','O','S','T',0};
typedef struct BindStatusCallback BindStatusCallback;
+struct reqheader
+{
+ struct list entry;
+ BSTR header;
+ BSTR value;
+};
+
typedef struct
{
const struct IXMLHTTPRequestVtbl *lpVtbl;
@@ -261,12 +268,60 @@ static HRESULT WINAPI BSCHttpNegotiate_BeginningTransaction(IHttpNegotiate *ifac
LPCWSTR url, LPCWSTR headers, DWORD reserved, LPWSTR *add_headers)
{
BindStatusCallback *This = HTTPNEG_THIS(iface);
+ static const WCHAR colspaceW[] = {':',' ',0};
+ static const WCHAR crlfW[] = {'\r','\n',0};
+ const struct reqheader *entry;
+ LONG size = 1024, written = 0;
+ LONG freech = size;
+ WCHAR *buff;
TRACE("(%p)->(%s %s %d %p)\n", This, debugstr_w(url), debugstr_w(headers), reserved, add_headers);
*add_headers = NULL;
- return E_NOTIMPL;
+ /* store user headers */
+ if (list_empty(&This->request->reqheaders)) return S_OK;
+
+ /* one extra to be always able to terminate it */
+ buff = CoTaskMemAlloc((size+1)*sizeof(WCHAR));
+ if (!buff) return E_OUTOFMEMORY;
+
+ LIST_FOR_EACH_ENTRY(entry, &This->request->reqheaders, struct reqheader, entry)
+ {
+ LONG header_size = SysStringLen(entry->header) + SysStringLen(entry->value) + 4 /* colon, space, CRLF */;
+
+ /* get large enough buffer */
+ while (freech < header_size)
+ {
+ WCHAR *buff2;
+
+ freech += size;
+ size *= 2;
+ buff2 = CoTaskMemRealloc(buff, (size+1)*sizeof(WCHAR));
+ if (!buff2)
+ {
+ CoTaskMemFree(buff);
+ return E_OUTOFMEMORY;
+ }
+ buff = buff2;
+ }
+ freech -= header_size;
+
+ lstrcpyW(&buff[written], entry->header);
+ written += SysStringLen(entry->header);
+ lstrcpyW(&buff[written], colspaceW);
+ written += sizeof(colspaceW)/sizeof(WCHAR) - 1;
+
+ lstrcpyW(&buff[written], entry->value);
+ written += SysStringLen(entry->value);
+ lstrcpyW(&buff[written], crlfW);
+ written += sizeof(crlfW)/sizeof(WCHAR) - 1;
+ }
+
+ buff[written] = 0;
+ *add_headers = buff;
+
+ return S_OK;
}
static HRESULT WINAPI BSCHttpNegotiate_OnResponse(IHttpNegotiate *iface, DWORD code,
@@ -338,13 +393,6 @@ static HRESULT BindStatusCallback_create(const httprequest* This, BindStatusCall
return hr;
}
-struct reqheader
-{
- struct list entry;
- BSTR header;
- BSTR value;
-};
-
enum READYSTATE
{
STATE_UNINITIALIZED = 0,
--
1.5.6.5
--------------040707050500030307060709--
More information about the wine-patches
mailing list