Hans Leidekker : winhttp: Add support for retrieving the URL codepage.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Aug 26 09:57:11 CDT 2015
Module: wine
Branch: master
Commit: 58bf3ca17ffd469823063b8e9ff8a0366a81edb6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=58bf3ca17ffd469823063b8e9ff8a0366a81edb6
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed Aug 26 08:45:07 2015 +0200
winhttp: Add support for retrieving the URL codepage.
---
dlls/winhttp/request.c | 21 +++++++++++++++++++--
dlls/winhttp/tests/winhttp.c | 36 +++++++++++++++++++++++++++++++++++-
2 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 6ca3727..d3f4d91 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -3999,8 +3999,25 @@ static HRESULT WINAPI winhttp_request_get_Option(
WinHttpRequestOption option,
VARIANT *value )
{
- FIXME("\n");
- return E_NOTIMPL;
+ struct winhttp_request *request = impl_from_IWinHttpRequest( iface );
+ HRESULT hr = S_OK;
+
+ TRACE("%p, %u, %p\n", request, option, value);
+
+ EnterCriticalSection( &request->cs );
+ switch (option)
+ {
+ case WinHttpRequestOption_URLCodePage:
+ V_VT( value ) = VT_I4;
+ V_I4( value ) = request->url_codepage;
+ break;
+ default:
+ FIXME("unimplemented option %u\n", option);
+ hr = E_NOTIMPL;
+ break;
+ }
+ LeaveCriticalSection( &request->cs );
+ return hr;
}
static HRESULT WINAPI winhttp_request_put_Option(
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index d2f7671..9bda2af 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -3043,11 +3043,12 @@ static void test_IWinHttpRequest(void)
static const WCHAR connectionW[] = {'C','o','n','n','e','c','t','i','o','n',0};
static const WCHAR dateW[] = {'D','a','t','e',0};
static const WCHAR test_dataW[] = {'t','e','s','t','d','a','t','a',128,0};
+ static const WCHAR utf8W[] = {'u','t','f','-','8',0};
HRESULT hr;
IWinHttpRequest *req;
BSTR method, url, username, password, response = NULL, status_text = NULL, headers = NULL;
BSTR date, today, connection, value = NULL;
- VARIANT async, empty, timeout, body, body2, proxy_server, bypass_list, data;
+ VARIANT async, empty, timeout, body, body2, proxy_server, bypass_list, data, cp;
VARIANT_BOOL succeeded;
LONG status;
WCHAR todayW[WINHTTP_TIME_FORMAT_BUFSIZE];
@@ -3131,6 +3132,39 @@ static void test_IWinHttpRequest(void)
hr = IWinHttpRequest_Open( req, method, url, async );
ok( hr == S_OK, "got %08x\n", hr );
+ V_VT( &cp ) = VT_ERROR;
+ V_ERROR( &cp ) = 0xdeadbeef;
+ hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
+ ok( V_I4( &cp ) == CP_UTF8, "got %u\n", V_I4( &cp ) );
+
+ V_VT( &cp ) = VT_UI4;
+ V_UI4( &cp ) = CP_ACP;
+ hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ V_VT( &cp ) = VT_ERROR;
+ V_ERROR( &cp ) = 0xdeadbeef;
+ hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
+ ok( V_I4( &cp ) == CP_ACP, "got %u\n", V_I4( &cp ) );
+
+ value = SysAllocString( utf8W );
+ V_VT( &cp ) = VT_BSTR;
+ V_BSTR( &cp ) = value;
+ hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
+ ok( hr == S_OK, "got %08x\n", hr );
+ SysFreeString( value );
+
+ V_VT( &cp ) = VT_ERROR;
+ V_ERROR( &cp ) = 0xdeadbeef;
+ hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
+ ok( V_I4( &cp ) == CP_UTF8, "got %u\n", V_I4( &cp ) );
+
hr = IWinHttpRequest_Abort( req );
ok( hr == S_OK, "got %08x\n", hr );
More information about the wine-cvs
mailing list