Commit f0546a19 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Implement ::get_responseBody().

parent 8630368a
......@@ -824,13 +824,55 @@ static HRESULT WINAPI httprequest_get_responseText(IXMLHTTPRequest *iface, BSTR
return hr;
}
static HRESULT WINAPI httprequest_get_responseBody(IXMLHTTPRequest *iface, VARIANT *pvarBody)
static HRESULT WINAPI httprequest_get_responseBody(IXMLHTTPRequest *iface, VARIANT *body)
{
httprequest *This = impl_from_IXMLHTTPRequest( iface );
HGLOBAL hglobal;
HRESULT hr;
FIXME("stub %p %p\n", This, pvarBody);
TRACE("(%p)->(%p)\n", This, body);
return E_NOTIMPL;
if (!body) return E_INVALIDARG;
if (This->state != READYSTATE_COMPLETE) return E_FAIL;
hr = GetHGlobalFromStream(This->bsc->stream, &hglobal);
if (hr == S_OK)
{
void *ptr = GlobalLock(hglobal);
DWORD size = GlobalSize(hglobal);
SAFEARRAYBOUND bound;
SAFEARRAY *array;
bound.lLbound = 0;
bound.cElements = size;
array = SafeArrayCreate(VT_UI1, 1, &bound);
if (array)
{
void *dest;
V_VT(body) = VT_ARRAY | VT_UI1;
V_ARRAY(body) = array;
hr = SafeArrayAccessData(array, &dest);
if (hr == S_OK)
{
memcpy(dest, ptr, size);
SafeArrayUnaccessData(array);
}
else
{
VariantClear(body);
}
}
else
hr = E_FAIL;
GlobalUnlock(hglobal);
}
return hr;
}
static HRESULT WINAPI httprequest_get_responseStream(IXMLHTTPRequest *iface, VARIANT *pvarBody)
......
......@@ -3195,7 +3195,8 @@ static void test_XMLHTTP(void)
VARIANT dummy;
VARIANT async;
VARIANT varbody;
LONG state, status, ref;
LONG state, status, ref, bound;
void *ptr;
IDispatch *event;
HRESULT hr = CoCreateInstance(&CLSID_XMLHTTPRequest, NULL,
CLSCTX_INPROC_SERVER, &IID_IXMLHttpRequest,
......@@ -3388,6 +3389,27 @@ todo_wine {
SysFreeString(bstrResponse);
}
hr = IXMLHttpRequest_get_responseBody(pXMLHttpRequest, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
V_VT(&varbody) = VT_EMPTY;
hr = IXMLHttpRequest_get_responseBody(pXMLHttpRequest, &varbody);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(V_VT(&varbody) == (VT_ARRAY|VT_UI1), "got type %d, expected %d\n", V_VT(&varbody), VT_ARRAY|VT_UI1);
ok(SafeArrayGetDim(V_ARRAY(&varbody)) == 1, "got %d, expected one dimension\n", SafeArrayGetDim(V_ARRAY(&varbody)));
bound = -1;
hr = SafeArrayGetLBound(V_ARRAY(&varbody), 1, &bound);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(bound == 0, "got %d, expected zero bound\n", bound);
hr = SafeArrayAccessData(V_ARRAY(&varbody), &ptr);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(memcmp(ptr, xmltestbodyA, sizeof(xmltestbodyA)-1) == 0, "got wrond body data\n");
SafeArrayUnaccessData(V_ARRAY(&varbody));
VariantClear(&varbody);
SysFreeString(url);
IDispatch_Release(event);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment