msxml3: Use IUri for storing XMLHTTPRequest URL.
This commit is contained in:
parent
10a832cc04
commit
b7a26db575
|
@ -82,8 +82,8 @@ typedef struct
|
|||
/* request */
|
||||
BINDVERB verb;
|
||||
BSTR custom;
|
||||
BSTR siteurl;
|
||||
BSTR url;
|
||||
IUri *uri;
|
||||
IUri *base_uri;
|
||||
BOOL async;
|
||||
struct list reqheaders;
|
||||
/* cached resulting custom request headers string length in WCHARs */
|
||||
|
@ -736,7 +736,7 @@ static HRESULT BindStatusCallback_create(httprequest* This, BindStatusCallback *
|
|||
{
|
||||
IMoniker *moniker;
|
||||
|
||||
hr = CreateURLMoniker(NULL, This->url, &moniker);
|
||||
hr = CreateURLMonikerEx2(NULL, This->uri, &moniker, URL_MK_UNIFORM);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
IStream *stream;
|
||||
|
@ -772,10 +772,14 @@ static HRESULT httprequest_open(httprequest *This, BSTR method, BSTR url,
|
|||
if (!method || !url) return E_INVALIDARG;
|
||||
|
||||
/* free previously set data */
|
||||
SysFreeString(This->url);
|
||||
if(This->uri) {
|
||||
IUri_Release(This->uri);
|
||||
This->uri = NULL;
|
||||
}
|
||||
|
||||
SysFreeString(This->user);
|
||||
SysFreeString(This->password);
|
||||
This->url = This->user = This->password = NULL;
|
||||
This->user = This->password = NULL;
|
||||
|
||||
if (!strcmpiW(method, MethodGetW))
|
||||
{
|
||||
|
@ -802,22 +806,14 @@ static HRESULT httprequest_open(httprequest *This, BSTR method, BSTR url,
|
|||
return E_FAIL;
|
||||
}
|
||||
|
||||
/* try to combine with site url */
|
||||
if (This->siteurl && PathIsRelativeW(url))
|
||||
{
|
||||
DWORD len = INTERNET_MAX_URL_LENGTH;
|
||||
WCHAR *fullW = heap_alloc(len*sizeof(WCHAR));
|
||||
|
||||
hr = UrlCombineW(This->siteurl, url, fullW, &len, 0);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
TRACE("combined url %s\n", debugstr_w(fullW));
|
||||
This->url = SysAllocString(fullW);
|
||||
}
|
||||
heap_free(fullW);
|
||||
}
|
||||
if(This->base_uri)
|
||||
hr = CoInternetCombineUrlEx(This->base_uri, url, 0, &This->uri, 0);
|
||||
else
|
||||
This->url = SysAllocString(url);
|
||||
hr = CreateUri(url, 0, 0, &This->uri);
|
||||
if(FAILED(hr)) {
|
||||
WARN("Could not create IUri object: %08x\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
VariantInit(&is_async);
|
||||
hr = VariantChangeType(&is_async, &async, 0, VT_BOOL);
|
||||
|
@ -1141,10 +1137,12 @@ static void httprequest_release(httprequest *This)
|
|||
|
||||
if (This->site)
|
||||
IUnknown_Release( This->site );
|
||||
if (This->uri)
|
||||
IUri_Release(This->uri);
|
||||
if (This->base_uri)
|
||||
IUri_Release(This->base_uri);
|
||||
|
||||
SysFreeString(This->custom);
|
||||
SysFreeString(This->siteurl);
|
||||
SysFreeString(This->url);
|
||||
SysFreeString(This->user);
|
||||
SysFreeString(This->password);
|
||||
|
||||
|
@ -1444,6 +1442,38 @@ static HRESULT WINAPI httprequest_ObjectWithSite_GetSite( IObjectWithSite *iface
|
|||
return IUnknown_QueryInterface( This->site, iid, ppvSite );
|
||||
}
|
||||
|
||||
static void get_base_uri(httprequest *This)
|
||||
{
|
||||
IServiceProvider *provider;
|
||||
IHTMLDocument2 *doc;
|
||||
IUri *uri;
|
||||
BSTR url;
|
||||
HRESULT hr;
|
||||
|
||||
hr = IUnknown_QueryInterface(This->site, &IID_IServiceProvider, (void**)&provider);
|
||||
if(FAILED(hr))
|
||||
return;
|
||||
|
||||
hr = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc);
|
||||
IServiceProvider_Release(provider);
|
||||
if(FAILED(hr))
|
||||
return;
|
||||
|
||||
hr = IHTMLDocument2_get_URL(doc, &url);
|
||||
IHTMLDocument2_Release(doc);
|
||||
if(FAILED(hr) || !url || !*url)
|
||||
return;
|
||||
|
||||
TRACE("host url %s\n", debugstr_w(url));
|
||||
|
||||
hr = CreateUri(url, 0, 0, &uri);
|
||||
SysFreeString(url);
|
||||
if(FAILED(hr))
|
||||
return;
|
||||
|
||||
This->base_uri = uri;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI httprequest_ObjectWithSite_SetSite( IObjectWithSite *iface, IUnknown *punk )
|
||||
{
|
||||
httprequest *This = impl_from_IObjectWithSite(iface);
|
||||
|
@ -1452,32 +1482,15 @@ static HRESULT WINAPI httprequest_ObjectWithSite_SetSite( IObjectWithSite *iface
|
|||
|
||||
if(This->site)
|
||||
IUnknown_Release( This->site );
|
||||
if(This->base_uri)
|
||||
IUri_Release(This->base_uri);
|
||||
|
||||
SysFreeString(This->siteurl);
|
||||
This->siteurl = NULL;
|
||||
This->site = punk;
|
||||
|
||||
if (punk)
|
||||
{
|
||||
IServiceProvider *provider;
|
||||
HRESULT hr;
|
||||
|
||||
IUnknown_AddRef( punk );
|
||||
|
||||
hr = IUnknown_QueryInterface(This->site, &IID_IServiceProvider, (void**)&provider);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
IHTMLDocument2 *doc;
|
||||
|
||||
hr = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
hr = IHTMLDocument2_get_URL(doc, &This->siteurl);
|
||||
IHTMLDocument2_Release(doc);
|
||||
TRACE("host url %s, 0x%08x\n", debugstr_w(This->siteurl), hr);
|
||||
}
|
||||
IServiceProvider_Release(provider);
|
||||
}
|
||||
get_base_uri(This);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
@ -1831,7 +1844,8 @@ static void init_httprequest(httprequest *req)
|
|||
req->async = FALSE;
|
||||
req->verb = -1;
|
||||
req->custom = NULL;
|
||||
req->url = req->siteurl = req->user = req->password = NULL;
|
||||
req->uri = req->base_uri = NULL;
|
||||
req->user = req->password = NULL;
|
||||
|
||||
req->state = READYSTATE_UNINITIALIZED;
|
||||
req->sink = NULL;
|
||||
|
|
Loading…
Reference in New Issue