Commit a25c865c authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

winhttp: Implement IWinHttpRequest::get_ResponseBody.

parent 73646d35
......@@ -2724,8 +2724,31 @@ static HRESULT WINAPI winhttp_request_get_ResponseBody(
IWinHttpRequest *iface,
VARIANT *body )
{
FIXME("\n");
return E_NOTIMPL;
struct winhttp_request *request = impl_from_IWinHttpRequest( iface );
SAFEARRAY *sa;
HRESULT hr;
DWORD err;
char *ptr;
TRACE("%p, %p\n", request, body);
if ((err = request_read_body( request, INFINITE ))) return HRESULT_FROM_WIN32( err );
if (!(sa = SafeArrayCreateVector( VT_UI1, 0, request->offset ))) return E_OUTOFMEMORY;
if ((hr = SafeArrayAccessData( sa, (void **)&ptr )) != S_OK)
{
SafeArrayDestroy( sa );
return hr;
}
memcpy( ptr, request->buffer, request->offset );
if ((hr = SafeArrayUnaccessData( sa )) != S_OK)
{
SafeArrayDestroy( sa );
return hr;
}
V_VT( body ) = VT_ARRAY|VT_UI1;
V_ARRAY( body ) = sa;
return S_OK;
}
static HRESULT WINAPI winhttp_request_get_ResponseStream(
......
......@@ -2107,7 +2107,7 @@ static void test_IWinHttpRequest(void)
HRESULT hr;
IWinHttpRequest *req;
BSTR method, url, response = NULL, status_text = NULL;
VARIANT async, empty, timeout;
VARIANT async, empty, timeout, body;
VARIANT_BOOL succeeded;
LONG status;
......@@ -2241,6 +2241,15 @@ static void test_IWinHttpRequest(void)
ok( hr == S_OK, "got %08x\n", hr );
SysFreeString( response );
VariantInit( &body );
V_VT( &body ) = VT_ERROR;
hr = IWinHttpRequest_get_ResponseBody( req, &body );
ok( hr == S_OK, "got %08x\n", hr );
ok( V_VT( &body ) == (VT_ARRAY|VT_UI1), "got %08x\n", V_VT( &body ) );
hr = VariantClear( &body );
ok( hr == S_OK, "got %08x\n", hr );
hr = IWinHttpRequest_Send( req, empty );
ok( hr == S_OK, "got %08x\n", hr );
......
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