msxml3: Implemented get_responseStream().

This commit is contained in:
Nikolay Sivov 2011-12-13 00:56:13 +03:00 committed by Alexandre Julliard
parent 940b50b2d8
commit 19a86feaa1
2 changed files with 52 additions and 5 deletions

View File

@ -926,7 +926,9 @@ static HRESULT WINAPI httprequest_get_responseBody(IXMLHTTPRequest *iface, VARIA
TRACE("(%p)->(%p)\n", This, body);
if (!body) return E_INVALIDARG;
if (This->state != READYSTATE_COMPLETE) return E_FAIL;
V_VT(body) = VT_EMPTY;
if (This->state != READYSTATE_COMPLETE) return E_PENDING;
hr = GetHGlobalFromStream(This->bsc->stream, &hglobal);
if (hr == S_OK)
@ -968,13 +970,29 @@ static HRESULT WINAPI httprequest_get_responseBody(IXMLHTTPRequest *iface, VARIA
return hr;
}
static HRESULT WINAPI httprequest_get_responseStream(IXMLHTTPRequest *iface, VARIANT *pvarBody)
static HRESULT WINAPI httprequest_get_responseStream(IXMLHTTPRequest *iface, VARIANT *body)
{
httprequest *This = impl_from_IXMLHTTPRequest( iface );
LARGE_INTEGER move;
IStream *stream;
HRESULT hr;
FIXME("stub %p %p\n", This, pvarBody);
TRACE("(%p)->(%p)\n", This, body);
return E_NOTIMPL;
if (!body) return E_INVALIDARG;
V_VT(body) = VT_EMPTY;
if (This->state != READYSTATE_COMPLETE) return E_PENDING;
hr = IStream_Clone(This->bsc->stream, &stream);
move.QuadPart = 0;
IStream_Seek(stream, move, STREAM_SEEK_SET, NULL);
V_VT(body) = VT_UNKNOWN;
V_UNKNOWN(body) = (IUnknown*)stream;
return hr;
}
static HRESULT WINAPI httprequest_get_readyState(IXMLHTTPRequest *iface, LONG *state)

View File

@ -4639,6 +4639,7 @@ static void test_XMLHTTP(void)
IDispatch *event;
void *ptr;
HRESULT hr;
HGLOBAL g;
hr = CoCreateInstance(&CLSID_XMLHTTPRequest, NULL, CLSCTX_INPROC_SERVER,
&IID_IXMLHttpRequest, (void**)&xhr);
@ -4665,6 +4666,20 @@ static void test_XMLHTTP(void)
hr = IXMLHttpRequest_abort(xhr);
EXPECT_HR(hr, S_OK);
V_VT(&varbody) = VT_I2;
V_I2(&varbody) = 1;
hr = IXMLHttpRequest_get_responseBody(xhr, &varbody);
EXPECT_HR(hr, E_PENDING);
ok(V_VT(&varbody) == VT_EMPTY, "got type %d\n", V_VT(&varbody));
ok(V_I2(&varbody) == 1, "got %d\n", V_I2(&varbody));
V_VT(&varbody) = VT_I2;
V_I2(&varbody) = 1;
hr = IXMLHttpRequest_get_responseStream(xhr, &varbody);
EXPECT_HR(hr, E_PENDING);
ok(V_VT(&varbody) == VT_EMPTY, "got type %d\n", V_VT(&varbody));
ok(V_I2(&varbody) == 1, "got %d\n", V_I2(&varbody));
/* send before open */
hr = IXMLHttpRequest_send(xhr, dummy);
ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr);
@ -4835,9 +4850,23 @@ static void test_XMLHTTP(void)
SafeArrayUnaccessData(V_ARRAY(&varbody));
VariantClear(&varbody);
SysFreeString(url);
/* get_responseStream */
hr = IXMLHttpRequest_get_responseStream(xhr, NULL);
EXPECT_HR(hr, E_INVALIDARG);
V_VT(&varbody) = VT_EMPTY;
hr = IXMLHttpRequest_get_responseStream(xhr, &varbody);
ok(V_VT(&varbody) == VT_UNKNOWN, "got type %d\n", V_VT(&varbody));
EXPECT_HR(hr, S_OK);
EXPECT_REF(V_UNKNOWN(&varbody), 1);
g = NULL;
hr = GetHGlobalFromStream((IStream*)V_UNKNOWN(&varbody), &g);
EXPECT_HR(hr, S_OK);
ok(g != NULL, "got %p\n", g);
hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectSafety, (void**)&safety);
EXPECT_HR(hr, S_OK);
if(hr == S_OK)