Hans Leidekker : winhttp: Implement IWinHttpRequest::SetAutoLogonPolicy.
Alexandre Julliard
julliard at winehq.org
Tue Aug 2 14:18:25 CDT 2011
Module: wine
Branch: master
Commit: 40bf74107faa7f307e7c014a27c026be2471c673
URL: http://source.winehq.org/git/wine.git/?a=commit;h=40bf74107faa7f307e7c014a27c026be2471c673
Author: Hans Leidekker <hans at codeweavers.com>
Date: Tue Aug 2 09:23:35 2011 +0200
winhttp: Implement IWinHttpRequest::SetAutoLogonPolicy.
---
dlls/winhttp/request.c | 30 ++++++++++++++++++++++++++++--
dlls/winhttp/tests/winhttp.c | 15 +++++++++++++++
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 633d8e8..2a70a87 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -2174,6 +2174,7 @@ struct winhttp_request
DWORD bytes_available;
DWORD bytes_read;
DWORD error;
+ DWORD logon_policy;
LONG resolve_timeout;
LONG connect_timeout;
LONG send_timeout;
@@ -2845,6 +2846,11 @@ static HRESULT request_send( struct winhttp_request *request )
{
return HRESULT_FROM_WIN32( get_last_error() );
}
+ if (!WinHttpSetOption( request->hrequest, WINHTTP_OPTION_AUTOLOGON_POLICY, &request->logon_policy,
+ sizeof(request->logon_policy) ))
+ {
+ return HRESULT_FROM_WIN32( get_last_error() );
+ }
if (!WinHttpSetTimeouts( request->hrequest,
request->resolve_timeout,
request->connect_timeout,
@@ -3241,8 +3247,28 @@ static HRESULT WINAPI winhttp_request_SetAutoLogonPolicy(
IWinHttpRequest *iface,
WinHttpRequestAutoLogonPolicy policy )
{
- FIXME("\n");
- return E_NOTIMPL;
+ struct winhttp_request *request = impl_from_IWinHttpRequest( iface );
+ HRESULT hr = S_OK;
+
+ TRACE("%p, %u\n", request, policy );
+
+ EnterCriticalSection( &request->cs );
+ switch (policy)
+ {
+ case AutoLogonPolicy_Always:
+ request->logon_policy = WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW;
+ break;
+ case AutoLogonPolicy_OnlyIfBypassProxy:
+ request->logon_policy = WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM;
+ break;
+ case AutoLogonPolicy_Never:
+ request->logon_policy = WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH;
+ break;
+ default: hr = E_INVALIDARG;
+ break;
+ }
+ LeaveCriticalSection( &request->cs );
+ return hr;
}
static const struct IWinHttpRequestVtbl winhttp_request_vtbl =
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index b450df7..a662ef8 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -2265,6 +2265,12 @@ static void test_IWinHttpRequest(void)
hr = IWinHttpRequest_SetRequestHeader( req, date, today );
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN ), "got %08x\n", hr );
+ hr = IWinHttpRequest_SetAutoLogonPolicy( req, 0xdeadbeef );
+ ok( hr == E_INVALIDARG, "got %08x\n", hr );
+
+ hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
+ ok( hr == S_OK, "got %08x\n", hr );
+
SysFreeString( method );
method = SysAllocString( method1W );
SysFreeString( url );
@@ -2335,6 +2341,9 @@ static void test_IWinHttpRequest(void)
hr = IWinHttpRequest_SetRequestHeader( req, date, NULL );
ok( hr == S_OK, "got %08x\n", hr );
+ hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
+ ok( hr == S_OK, "got %08x\n", hr );
+
hr = IWinHttpRequest_Send( req, empty );
ok( hr == S_OK, "got %08x\n", hr );
@@ -2396,6 +2405,9 @@ static void test_IWinHttpRequest(void)
hr = IWinHttpRequest_SetRequestHeader( req, date, today );
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND ), "got %08x\n", hr );
+ hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
+ ok( hr == S_OK, "got %08x\n", hr );
+
VariantInit( &timeout );
V_VT( &timeout ) = VT_I4;
V_I4( &timeout ) = 10;
@@ -2457,6 +2469,9 @@ static void test_IWinHttpRequest(void)
hr = IWinHttpRequest_SetRequestHeader( req, date, today );
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND ), "got %08x\n", hr );
+ hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
+ 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