Hans Leidekker : winhttp: Implement IWinHttpRequest::get_ResponseBody.
Alexandre Julliard
julliard at winehq.org
Mon Jul 25 11:43:09 CDT 2011
Module: wine
Branch: master
Commit: a25c865cb8b9c6c640e80c7a2585c9bae07084f2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a25c865cb8b9c6c640e80c7a2585c9bae07084f2
Author: Hans Leidekker <hans at codeweavers.com>
Date: Sat Jul 23 18:15:09 2011 +0200
winhttp: Implement IWinHttpRequest::get_ResponseBody.
---
dlls/winhttp/request.c | 27 +++++++++++++++++++++++++--
dlls/winhttp/tests/winhttp.c | 11 ++++++++++-
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index b639f6c..65e0aa7 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -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(
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index 8f2af5a..1227902 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -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 );
More information about the wine-cvs
mailing list