Commit 01bfb3d6 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

winhttp: Add custom implementation of IWinHttpRequest::Invoke(DISPID_HTTPREQUEST_OPTION).

parent c1737515
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "ole2.h" #include "ole2.h"
#include "initguid.h" #include "initguid.h"
#include "httprequest.h" #include "httprequest.h"
#include "httprequestid.h"
#include "winhttp.h" #include "winhttp.h"
#include "winhttp_private.h" #include "winhttp_private.h"
...@@ -2946,6 +2947,48 @@ static HRESULT WINAPI winhttp_request_Invoke( ...@@ -2946,6 +2947,48 @@ static HRESULT WINAPI winhttp_request_Invoke(
TRACE("%p, %d, %s, %d, %d, %p, %p, %p, %p\n", request, member, debugstr_guid(riid), TRACE("%p, %d, %s, %d, %d, %p, %p, %p, %p\n", request, member, debugstr_guid(riid),
lcid, flags, params, result, excep_info, arg_err); lcid, flags, params, result, excep_info, arg_err);
if (!IsEqualIID( riid, &IID_NULL )) return DISP_E_UNKNOWNINTERFACE;
if (member == DISPID_HTTPREQUEST_OPTION)
{
VARIANT ret_value, option;
UINT err_pos;
if (!result) result = &ret_value;
if (!arg_err) arg_err = &err_pos;
VariantInit( &option );
VariantInit( result );
if (!flags) return S_OK;
if (flags == DISPATCH_PROPERTYPUT)
{
hr = DispGetParam( params, 0, VT_I4, &option, arg_err );
if (FAILED(hr)) return hr;
hr = IWinHttpRequest_put_Option( &request->IWinHttpRequest_iface, V_I4( &option ), params->rgvarg[0] );
if (FAILED(hr))
WARN("put_Option(%d) failed: %x\n", V_I4( &option ), hr);
return hr;
}
else if (flags & (DISPATCH_PROPERTYGET | DISPATCH_METHOD))
{
hr = DispGetParam( params, 0, VT_I4, &option, arg_err );
if (FAILED(hr)) return hr;
hr = IWinHttpRequest_get_Option( &request->IWinHttpRequest_iface, V_I4( &option ), result );
if (FAILED(hr))
WARN("get_Option(%d) failed: %x\n", V_I4( &option ), hr);
return hr;
}
FIXME("unsupported flags %x\n", flags);
return E_NOTIMPL;
}
/* fallback to standard implementation */
hr = get_typeinfo( IWinHttpRequest_tid, &typeinfo ); hr = get_typeinfo( IWinHttpRequest_tid, &typeinfo );
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
...@@ -4216,6 +4259,7 @@ HRESULT WinHttpRequest_create( void **obj ) ...@@ -4216,6 +4259,7 @@ HRESULT WinHttpRequest_create( void **obj )
request->state = REQUEST_STATE_UNINITIALIZED; request->state = REQUEST_STATE_UNINITIALIZED;
request->proxy.lpszProxy = NULL; request->proxy.lpszProxy = NULL;
request->proxy.lpszProxyBypass = NULL; request->proxy.lpszProxyBypass = NULL;
request->url_codepage = CP_UTF8;
InitializeCriticalSection( &request->cs ); InitializeCriticalSection( &request->cs );
request->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": winhttp_request.cs"); request->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": winhttp_request.cs");
......
...@@ -3569,7 +3569,6 @@ static void request_get_property(IWinHttpRequest *request, int property, VARIANT ...@@ -3569,7 +3569,6 @@ static void request_get_property(IWinHttpRequest *request, int property, VARIANT
VariantInit(ret); VariantInit(ret);
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_PROPERTYGET, &params, ret, NULL, NULL); DISPATCH_PROPERTYGET, &params, ret, NULL, NULL);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
} }
...@@ -3614,9 +3613,7 @@ static void test_IWinHttpRequest_Invoke(void) ...@@ -3614,9 +3613,7 @@ static void test_IWinHttpRequest_Invoke(void)
ok(id == DISPID_HTTPREQUEST_OPTION, "expected DISPID_HTTPREQUEST_OPTION, got %u\n", id); ok(id == DISPID_HTTPREQUEST_OPTION, "expected DISPID_HTTPREQUEST_OPTION, got %u\n", id);
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret); request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
todo_wine
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret)); ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
todo_wine
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret)); ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
memset(&params, 0, sizeof(params)); memset(&params, 0, sizeof(params));
...@@ -3630,13 +3627,10 @@ todo_wine ...@@ -3630,13 +3627,10 @@ todo_wine
VariantInit(&ret); VariantInit(&ret);
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_METHOD, &params, NULL, NULL, &err); DISPATCH_METHOD, &params, NULL, NULL, &err);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret); request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
todo_wine
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret)); ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
todo_wine
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret)); ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
memset(&params, 0, sizeof(params)); memset(&params, 0, sizeof(params));
...@@ -3650,13 +3644,10 @@ todo_wine ...@@ -3650,13 +3644,10 @@ todo_wine
VariantInit(&ret); VariantInit(&ret);
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_METHOD | DISPATCH_PROPERTYPUT, &params, NULL, NULL, &err); DISPATCH_METHOD | DISPATCH_PROPERTYPUT, &params, NULL, NULL, &err);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret); request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
todo_wine
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret)); ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
todo_wine
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret)); ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
memset(&params, 0, sizeof(params)); memset(&params, 0, sizeof(params));
...@@ -3670,13 +3661,10 @@ todo_wine ...@@ -3670,13 +3661,10 @@ todo_wine
VariantInit(&ret); VariantInit(&ret);
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_PROPERTYPUT, &params, NULL, NULL, &err); DISPATCH_PROPERTYPUT, &params, NULL, NULL, &err);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret); request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
todo_wine
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret)); ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
todo_wine
ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret)); ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
memset(&params, 0, sizeof(params)); memset(&params, 0, sizeof(params));
...@@ -3689,39 +3677,29 @@ todo_wine ...@@ -3689,39 +3677,29 @@ todo_wine
V_VT(&arg[1]) = VT_R8; V_VT(&arg[1]) = VT_R8;
V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */ V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, &err); hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, &err);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret); request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
todo_wine
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret)); ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
todo_wine
ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret)); ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
VariantInit(&ret); VariantInit(&ret);
hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, &params, &ret, NULL, &err); hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, &params, &ret, NULL, &err);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret); request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
todo_wine
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret)); ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
todo_wine
ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret)); ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
VariantInit(&ret); VariantInit(&ret);
hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err); hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret); request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
todo_wine
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret)); ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
todo_wine
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret)); ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, NULL, NULL, NULL); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, NULL, NULL, NULL);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
hr = IWinHttpRequest_Invoke(request, 255, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, NULL, NULL, NULL); hr = IWinHttpRequest_Invoke(request, 255, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, NULL, NULL, NULL);
...@@ -3729,7 +3707,6 @@ todo_wine ...@@ -3729,7 +3707,6 @@ todo_wine
VariantInit(&ret); VariantInit(&ret);
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_IUnknown, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_IUnknown, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
todo_wine
ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#x\n", hr); ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#x\n", hr);
VariantInit(&ret); VariantInit(&ret);
...@@ -3738,7 +3715,6 @@ if (0) /* crashes */ ...@@ -3738,7 +3715,6 @@ if (0) /* crashes */
params.cArgs = 1; params.cArgs = 1;
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
todo_wine
ok(hr == DISP_E_TYPEMISMATCH, "error %#x\n", hr); ok(hr == DISP_E_TYPEMISMATCH, "error %#x\n", hr);
VariantInit(&arg[2]); VariantInit(&arg[2]);
...@@ -3755,48 +3731,36 @@ todo_wine ...@@ -3755,48 +3731,36 @@ todo_wine
V_VT(&arg[0]) = VT_I4; V_VT(&arg[0]) = VT_I4;
V_I4(&arg[0]) = WinHttpRequestOption_URLCodePage; V_I4(&arg[0]) = WinHttpRequestOption_URLCodePage;
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
V_VT(&ret) = 0xdead; V_VT(&ret) = 0xdead;
V_I4(&ret) = 0xbeef; V_I4(&ret) = 0xbeef;
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &params, &ret, NULL, NULL); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &params, &ret, NULL, NULL);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
todo_wine
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret)); ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
todo_wine
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret)); ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
V_VT(&ret) = 0xdead; V_VT(&ret) = 0xdead;
V_I4(&ret) = 0xbeef; V_I4(&ret) = 0xbeef;
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD, &params, &ret, NULL, NULL); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD, &params, &ret, NULL, NULL);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
todo_wine
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret)); ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
todo_wine
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret)); ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
V_VT(&ret) = 0xdead; V_VT(&ret) = 0xdead;
V_I4(&ret) = 0xbeef; V_I4(&ret) = 0xbeef;
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0, &params, &ret, NULL, NULL); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0, &params, &ret, NULL, NULL);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
todo_wine
ok(V_VT(&ret) == VT_EMPTY, "expected VT_EMPTY, got %d\n", V_VT(&ret)); ok(V_VT(&ret) == VT_EMPTY, "expected VT_EMPTY, got %d\n", V_VT(&ret));
ok(V_I4(&ret) == 0xbeef || V_I4(&ret) == 0 /* Win8 */, "expected 0xdead, got %d\n", V_I4(&ret)); ok(V_I4(&ret) == 0xbeef || V_I4(&ret) == 0 /* Win8 */, "expected 0xdead, got %d\n", V_I4(&ret));
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0, &params, NULL, NULL, NULL); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0, &params, NULL, NULL, NULL);
todo_wine
ok(hr == S_OK, "error %#x\n", hr); ok(hr == S_OK, "error %#x\n", hr);
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_IUnknown, 0, DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_IUnknown, 0, DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL);
todo_wine
ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#x\n", hr); ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#x\n", hr);
params.cArgs = 2; params.cArgs = 2;
...@@ -3806,7 +3770,6 @@ todo_wine ...@@ -3806,7 +3770,6 @@ todo_wine
params.cArgs = 0; params.cArgs = 0;
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL); hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL);
todo_wine
ok(hr == DISP_E_PARAMNOTFOUND, "error %#x\n", hr); ok(hr == DISP_E_PARAMNOTFOUND, "error %#x\n", hr);
SysFreeString(utf8); SysFreeString(utf8);
......
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