* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-
#define COBJMACROS
#define NONAMELESSUNION
-#include <config.h>
+#include "config.h"
-//#include <stdarg.h>
+#include <stdarg.h>
#ifdef HAVE_LIBXML2
# include <libxml/parser.h>
-//# include <libxml/xmlerror.h>
-//# include <libxml/encoding.h>
+# include <libxml/xmlerror.h>
+# include <libxml/encoding.h>
#endif
-#include <windef.h>
-#include <winbase.h>
-#include <wingdi.h>
-#include <wininet.h>
-#include <winreg.h>
-//#include "winuser.h"
-#include <ole2.h>
-#include <mshtml.h>
-#include <msxml6.h>
-#include <objsafe.h>
-#include <docobj.h>
-#include <shlwapi.h>
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "wininet.h"
+#include "winreg.h"
+#include "winuser.h"
+#include "ole2.h"
+#include "mshtml.h"
+#include "msxml6.h"
+#include "objsafe.h"
+#include "docobj.h"
+#include "shlwapi.h"
#include "msxml_private.h"
-#include <wine/debug.h>
-#include <wine/list.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(msxml);
+#include "wine/debug.h"
#ifdef HAVE_LIBXML2
+WINE_DEFAULT_DEBUG_CHANNEL(msxml);
+
static const WCHAR colspaceW[] = {':',' ',0};
static const WCHAR crlfW[] = {'\r','\n',0};
static const DWORD safety_supported_options =
IXMLHTTPRequest IXMLHTTPRequest_iface;
IObjectWithSite IObjectWithSite_iface;
IObjectSafety IObjectSafety_iface;
+ ISupportErrorInfo ISupportErrorInfo_iface;
LONG ref;
READYSTATE state;
{
httprequest req;
IServerXMLHTTPRequest IServerXMLHTTPRequest_iface;
- LONG ref;
} serverhttp;
static inline httprequest *impl_from_IXMLHTTPRequest( IXMLHTTPRequest *iface )
return CONTAINING_RECORD(iface, httprequest, IObjectSafety_iface);
}
+static inline httprequest *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
+{
+ return CONTAINING_RECORD(iface, httprequest, ISupportErrorInfo_iface);
+}
+
static inline serverhttp *impl_from_IServerXMLHTTPRequest(IServerXMLHTTPRequest *iface)
{
return CONTAINING_RECORD(iface, serverhttp, IServerXMLHTTPRequest_iface);
This->raw_respheaders = NULL;
}
+static void free_request_headers(httprequest *This)
+{
+ struct httpheader *header, *header2;
+
+ LIST_FOR_EACH_ENTRY_SAFE(header, header2, &This->reqheaders, struct httpheader, entry)
+ {
+ list_remove(&header->entry);
+ SysFreeString(header->header);
+ SysFreeString(header->value);
+ heap_free(header);
+ }
+}
+
struct BindStatusCallback
{
IBindStatusCallback IBindStatusCallback_iface;
pbindinfo->dwBindVerb = This->request->verb;
if (This->request->verb == BINDVERB_CUSTOM)
{
- pbindinfo->szCustomVerb = CoTaskMemAlloc(SysStringByteLen(This->request->custom));
+ pbindinfo->szCustomVerb = CoTaskMemAlloc(SysStringByteLen(This->request->custom)+sizeof(WCHAR));
strcpyW(pbindinfo->szCustomVerb, This->request->custom);
}
{
static const WCHAR content_type_utf8W[] = {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ',
't','e','x','t','/','p','l','a','i','n',';','c','h','a','r','s','e','t','=','u','t','f','-','8','\r','\n',0};
+ static const WCHAR refererW[] = {'R','e','f','e','r','e','r',':',' ',0};
BindStatusCallback *This = impl_from_IHttpNegotiate(iface);
const struct httpheader *entry;
+ BSTR base_uri = NULL;
WCHAR *buff, *ptr;
int size = 0;
if (!list_empty(&This->request->reqheaders))
size += This->request->reqheader_size*sizeof(WCHAR);
- if (!size) return S_OK;
+ if (This->request->base_uri)
+ {
+ IUri_GetRawUri(This->request->base_uri, &base_uri);
+ size += SysStringLen(base_uri)*sizeof(WCHAR) + sizeof(refererW) + sizeof(crlfW);
+ }
+
+ if (!size)
+ {
+ SysFreeString(base_uri);
+ return S_OK;
+ }
buff = CoTaskMemAlloc(size);
- if (!buff) return E_OUTOFMEMORY;
+ if (!buff)
+ {
+ SysFreeString(base_uri);
+ return E_OUTOFMEMORY;
+ }
ptr = buff;
if (This->request->use_utf8_content)
{
lstrcpyW(ptr, content_type_utf8W);
- ptr += sizeof(content_type_utf8W)/sizeof(WCHAR)-1;
+ ptr += ARRAY_SIZE(content_type_utf8W) - 1;
+ }
+
+ if (base_uri)
+ {
+ strcpyW(ptr, refererW);
+ strcatW(ptr, base_uri);
+ strcatW(ptr, crlfW);
+ ptr += strlenW(refererW) + SysStringLen(base_uri) + strlenW(crlfW);
+ SysFreeString(base_uri);
}
/* user headers */
ptr += SysStringLen(entry->header);
lstrcpyW(ptr, colspaceW);
- ptr += sizeof(colspaceW)/sizeof(WCHAR)-1;
+ ptr += ARRAY_SIZE(colspaceW) - 1;
lstrcpyW(ptr, entry->value);
ptr += SysStringLen(entry->value);
lstrcpyW(ptr, crlfW);
- ptr += sizeof(crlfW)/sizeof(WCHAR)-1;
+ ptr += ARRAY_SIZE(crlfW) - 1;
}
*add_headers = buff;
HWND *hwnd, LPWSTR *username, LPWSTR *password)
{
BindStatusCallback *This = impl_from_IAuthenticate(iface);
- FIXME("(%p)->(%p %p %p)\n", This, hwnd, username, password);
- return E_NOTIMPL;
+ httprequest *request = This->request;
+
+ TRACE("(%p)->(%p %p %p)\n", This, hwnd, username, password);
+
+ if (request->user && *request->user)
+ {
+ if (hwnd) *hwnd = NULL;
+ *username = CoTaskMemAlloc(SysStringByteLen(request->user)+sizeof(WCHAR));
+ *password = CoTaskMemAlloc(SysStringByteLen(request->password)+sizeof(WCHAR));
+ if (!*username || !*password)
+ {
+ CoTaskMemFree(*username);
+ CoTaskMemFree(*password);
+ return E_OUTOFMEMORY;
+ }
+
+ memcpy(*username, request->user, SysStringByteLen(request->user)+sizeof(WCHAR));
+ memcpy(*password, request->password, SysStringByteLen(request->password)+sizeof(WCHAR));
+ }
+
+ return S_OK;
}
static const IAuthenticateVtbl AuthenticateVtbl = {
case VT_ARRAY|VT_UI1:
{
sa = V_ARRAY(body);
- if ((hr = SafeArrayAccessData(sa, (void **)&ptr)) != S_OK)
+ if ((hr = SafeArrayAccessData(sa, &ptr)) != S_OK)
{
heap_free(bsc);
return hr;
}
- if ((hr = SafeArrayGetUBound(sa, 1, &size) != S_OK))
+ if ((hr = SafeArrayGetUBound(sa, 1, &size)) != S_OK)
{
SafeArrayUnaccessData(sa);
heap_free(bsc);
/* fall through */
case VT_EMPTY:
case VT_ERROR:
+ case VT_NULL:
ptr = NULL;
size = 0;
break;
}
- bsc->body = GlobalAlloc(GMEM_FIXED, size);
- if (!bsc->body)
+ if (size)
{
- if (V_VT(body) == VT_BSTR)
- heap_free(ptr);
- else if (V_VT(body) == (VT_ARRAY|VT_UI1))
- SafeArrayUnaccessData(sa);
+ bsc->body = GlobalAlloc(GMEM_FIXED, size);
+ if (!bsc->body)
+ {
+ if (V_VT(body) == VT_BSTR)
+ heap_free(ptr);
+ else if (V_VT(body) == (VT_ARRAY|VT_UI1))
+ SafeArrayUnaccessData(sa);
- heap_free(bsc);
- return E_OUTOFMEMORY;
- }
+ heap_free(bsc);
+ return E_OUTOFMEMORY;
+ }
- send_data = GlobalLock(bsc->body);
- memcpy(send_data, ptr, size);
- GlobalUnlock(bsc->body);
+ send_data = GlobalLock(bsc->body);
+ memcpy(send_data, ptr, size);
+ GlobalUnlock(bsc->body);
+ }
if (V_VT(body) == VT_BSTR)
heap_free(ptr);
static HRESULT httprequest_open(httprequest *This, BSTR method, BSTR url,
VARIANT async, VARIANT user, VARIANT password)
{
+ static const WCHAR MethodHeadW[] = {'H','E','A','D',0};
static const WCHAR MethodGetW[] = {'G','E','T',0};
static const WCHAR MethodPutW[] = {'P','U','T',0};
static const WCHAR MethodPostW[] = {'P','O','S','T',0};
SysFreeString(This->user);
SysFreeString(This->password);
This->user = This->password = NULL;
+ free_request_headers(This);
if (!strcmpiW(method, MethodGetW))
{
This->verb = BINDVERB_POST;
}
else if (!strcmpiW(method, MethodDeleteW) ||
+ !strcmpiW(method, MethodHeadW) ||
!strcmpiW(method, MethodPropFindW))
{
This->verb = BINDVERB_CUSTOM;
return hr;
}
- This->uri = uri;
-
- VariantInit(&is_async);
- hr = VariantChangeType(&is_async, &async, 0, VT_BOOL);
- This->async = hr == S_OK && V_BOOL(&is_async);
-
VariantInit(&str);
hr = VariantChangeType(&str, &user, 0, VT_BSTR);
if (hr == S_OK)
if (hr == S_OK)
This->password = V_BSTR(&str);
+ /* add authentication info */
+ if (This->user && *This->user)
+ {
+ IUriBuilder *builder;
+
+ hr = CreateIUriBuilder(uri, 0, 0, &builder);
+ if (hr == S_OK)
+ {
+ IUri *full_uri;
+
+ IUriBuilder_SetUserName(builder, This->user);
+ IUriBuilder_SetPassword(builder, This->password);
+ hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &full_uri);
+ if (hr == S_OK)
+ {
+ IUri_Release(uri);
+ uri = full_uri;
+ }
+ else
+ WARN("failed to create modified uri, 0x%08x\n", hr);
+ IUriBuilder_Release(builder);
+ }
+ else
+ WARN("IUriBuilder creation failed, 0x%08x\n", hr);
+ }
+
+ This->uri = uri;
+
+ VariantInit(&is_async);
+ hr = VariantChangeType(&is_async, &async, 0, VT_BOOL);
+ This->async = hr == S_OK && V_BOOL(&is_async);
+
httprequest_setreadystate(This, READYSTATE_LOADING);
return S_OK;
entry->value = SysAllocString(value);
/* header length including null terminator */
- This->reqheader_size += SysStringLen(entry->header) + sizeof(colspaceW)/sizeof(WCHAR) +
- SysStringLen(entry->value) + sizeof(crlfW)/sizeof(WCHAR) - 1;
+ This->reqheader_size += SysStringLen(entry->header) + ARRAY_SIZE(colspaceW) +
+ SysStringLen(entry->value) + ARRAY_SIZE(crlfW) - 1;
list_add_head(&This->reqheaders, &entry->entry);
if (!body) return E_INVALIDARG;
if (This->state != READYSTATE_COMPLETE) return E_FAIL;
- hr = DOMDocument_create(MSXML_DEFAULT, NULL, (void**)&doc);
+ hr = DOMDocument_create(MSXML_DEFAULT, (void**)&doc);
if (hr != S_OK) return hr;
hr = httprequest_get_responseText(This, &str);
static void httprequest_release(httprequest *This)
{
- struct httpheader *header, *header2;
-
if (This->site)
IUnknown_Release( This->site );
if (This->uri)
SysFreeString(This->user);
SysFreeString(This->password);
- /* request headers */
- LIST_FOR_EACH_ENTRY_SAFE(header, header2, &This->reqheaders, struct httpheader, entry)
- {
- list_remove(&header->entry);
- SysFreeString(header->header);
- SysFreeString(header->value);
- heap_free(header);
- }
- /* response headers */
+ /* cleanup headers lists */
+ free_request_headers(This);
free_response_headers(This);
SysFreeString(This->status_text);
{
*ppvObject = &This->IObjectSafety_iface;
}
+ else if (IsEqualGUID(&IID_ISupportErrorInfo, riid))
+ {
+ *ppvObject = &This->ISupportErrorInfo_iface;
+ }
else
{
TRACE("Unsupported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
- IXMLHTTPRequest_AddRef( iface );
+ IUnknown_AddRef((IUnknown *)*ppvObject);
return S_OK;
}
httprequest_ObjectWithSite_QueryInterface( IObjectWithSite* iface, REFIID riid, void** ppvObject )
{
httprequest *This = impl_from_IObjectWithSite(iface);
- return IXMLHTTPRequest_QueryInterface( (IXMLHTTPRequest *)This, riid, ppvObject );
+ return IXMLHTTPRequest_QueryInterface(&This->IXMLHTTPRequest_iface, riid, ppvObject);
}
static ULONG WINAPI httprequest_ObjectWithSite_AddRef( IObjectWithSite* iface )
{
httprequest *This = impl_from_IObjectWithSite(iface);
- return IXMLHTTPRequest_AddRef((IXMLHTTPRequest *)This);
+ return IXMLHTTPRequest_AddRef(&This->IXMLHTTPRequest_iface);
}
static ULONG WINAPI httprequest_ObjectWithSite_Release( IObjectWithSite* iface )
{
httprequest *This = impl_from_IObjectWithSite(iface);
- return IXMLHTTPRequest_Release((IXMLHTTPRequest *)This);
+ return IXMLHTTPRequest_Release(&This->IXMLHTTPRequest_iface);
}
static HRESULT WINAPI httprequest_ObjectWithSite_GetSite( IObjectWithSite *iface, REFIID iid, void **ppvSite )
return;
hr = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc);
+ if(FAILED(hr))
+ hr = IServiceProvider_QueryService(provider, &SID_SInternetHostSecurityManager, &IID_IHTMLDocument2, (void**)&doc);
IServiceProvider_Release(provider);
if(FAILED(hr))
return;
static HRESULT WINAPI httprequest_Safety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
{
httprequest *This = impl_from_IObjectSafety(iface);
- return IXMLHTTPRequest_QueryInterface( (IXMLHTTPRequest *)This, riid, ppv );
+ return IXMLHTTPRequest_QueryInterface(&This->IXMLHTTPRequest_iface, riid, ppv);
}
static ULONG WINAPI httprequest_Safety_AddRef(IObjectSafety *iface)
{
httprequest *This = impl_from_IObjectSafety(iface);
- return IXMLHTTPRequest_AddRef((IXMLHTTPRequest *)This);
+ return IXMLHTTPRequest_AddRef(&This->IXMLHTTPRequest_iface);
}
static ULONG WINAPI httprequest_Safety_Release(IObjectSafety *iface)
{
httprequest *This = impl_from_IObjectSafety(iface);
- return IXMLHTTPRequest_Release((IXMLHTTPRequest *)This);
+ return IXMLHTTPRequest_Release(&This->IXMLHTTPRequest_iface);
}
static HRESULT WINAPI httprequest_Safety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
httprequest_Safety_SetInterfaceSafetyOptions
};
+static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **obj)
+{
+ httprequest *This = impl_from_ISupportErrorInfo(iface);
+ return IXMLHTTPRequest_QueryInterface(&This->IXMLHTTPRequest_iface, riid, obj);
+}
+
+static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
+{
+ httprequest *This = impl_from_ISupportErrorInfo(iface);
+ return IXMLHTTPRequest_AddRef(&This->IXMLHTTPRequest_iface);
+}
+
+static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
+{
+ httprequest *This = impl_from_ISupportErrorInfo(iface);
+ return IXMLHTTPRequest_Release(&This->IXMLHTTPRequest_iface);
+}
+
+static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
+{
+ httprequest *This = impl_from_ISupportErrorInfo(iface);
+
+ FIXME("(%p)->(%s)\n", This, debugstr_guid(riid));
+
+ return E_NOTIMPL;
+}
+
+static const ISupportErrorInfoVtbl SupportErrorInfoVtbl =
+{
+ SupportErrorInfo_QueryInterface,
+ SupportErrorInfo_AddRef,
+ SupportErrorInfo_Release,
+ SupportErrorInfo_InterfaceSupportsErrorInfo,
+};
+
/* IServerXMLHTTPRequest */
static HRESULT WINAPI ServerXMLHTTPRequest_QueryInterface(IServerXMLHTTPRequest *iface, REFIID riid, void **obj)
{
{
*obj = iface;
}
+ else if ( IsEqualGUID( riid, &IID_ISupportErrorInfo ))
+ {
+ *obj = &This->req.ISupportErrorInfo_iface;
+ }
else
{
TRACE("Unsupported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
- IServerXMLHTTPRequest_AddRef( iface );
+ IUnknown_AddRef( (IUnknown *)*obj );
return S_OK;
}
static ULONG WINAPI ServerXMLHTTPRequest_AddRef(IServerXMLHTTPRequest *iface)
{
serverhttp *This = impl_from_IServerXMLHTTPRequest( iface );
- ULONG ref = InterlockedIncrement( &This->ref );
+ ULONG ref = InterlockedIncrement( &This->req.ref );
TRACE("(%p)->(%u)\n", This, ref );
return ref;
}
static ULONG WINAPI ServerXMLHTTPRequest_Release(IServerXMLHTTPRequest *iface)
{
serverhttp *This = impl_from_IServerXMLHTTPRequest( iface );
- ULONG ref = InterlockedDecrement( &This->ref );
+ ULONG ref = InterlockedDecrement( &This->req.ref );
TRACE("(%p)->(%u)\n", This, ref );
{
serverhttp *This = impl_from_IServerXMLHTTPRequest( iface );
FIXME("(%p)->(%d %d %d %d): stub\n", This, resolveTimeout, connectTimeout, sendTimeout, receiveTimeout);
- return E_NOTIMPL;
+ return S_OK;
}
static HRESULT WINAPI ServerXMLHTTPRequest_waitForResponse(IServerXMLHTTPRequest *iface, VARIANT timeout, VARIANT_BOOL *isSuccessful)
req->IXMLHTTPRequest_iface.lpVtbl = &XMLHTTPRequestVtbl;
req->IObjectWithSite_iface.lpVtbl = &ObjectWithSiteVtbl;
req->IObjectSafety_iface.lpVtbl = &ObjectSafetyVtbl;
+ req->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
req->ref = 1;
req->async = FALSE;
req->safeopt = 0;
}
-HRESULT XMLHTTPRequest_create(IUnknown *outer, void **obj)
+HRESULT XMLHTTPRequest_create(void **obj)
{
httprequest *req;
- TRACE("(%p, %p)\n", outer, obj);
+ TRACE("(%p)\n", obj);
req = heap_alloc( sizeof (*req) );
if( !req )
return S_OK;
}
-HRESULT ServerXMLHTTP_create(IUnknown *outer, void **obj)
+HRESULT ServerXMLHTTP_create(void **obj)
{
serverhttp *req;
- TRACE("(%p, %p)\n", outer, obj);
+ TRACE("(%p)\n", obj);
req = heap_alloc( sizeof (*req) );
if( !req )
init_httprequest(&req->req);
req->IServerXMLHTTPRequest_iface.lpVtbl = &ServerXMLHTTPRequestVtbl;
- req->ref = 1;
*obj = &req->IServerXMLHTTPRequest_iface;
#else
-HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, void **ppObj)
+HRESULT XMLHTTPRequest_create(void **ppObj)
{
MESSAGE("This program tried to use a XMLHTTPRequest object, but\n"
"libxml2 support was not present at compile time.\n");
return E_NOTIMPL;
}
-HRESULT ServerXMLHTTP_create(IUnknown *outer, void **obj)
+HRESULT ServerXMLHTTP_create(void **obj)
{
MESSAGE("This program tried to use a ServerXMLHTTP object, but\n"
"libxml2 support was not present at compile time.\n");