winhttp: Implement IWinHttpRequest::get_ResponseBody.

This commit is contained in:
Hans Leidekker 2011-07-23 18:15:09 +02:00 committed by Alexandre Julliard
parent 73646d3529
commit a25c865cb8
2 changed files with 35 additions and 3 deletions

View File

@ -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(

View File

@ -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 );