webservices: Implement WsResetChannel.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2017-04-05 11:40:22 +02:00 committed by Alexandre Julliard
parent 5488acf1d3
commit 29d4c50391
3 changed files with 111 additions and 16 deletions

View File

@ -121,14 +121,27 @@ static struct channel *alloc_channel(void)
return ret;
}
static void reset_channel( struct channel *channel )
{
channel->state = WS_CHANNEL_STATE_CREATED;
heap_free( channel->addr.url.chars );
channel->addr.url.chars = NULL;
channel->addr.url.length = 0;
WinHttpCloseHandle( channel->http_request );
channel->http_request = NULL;
WinHttpCloseHandle( channel->http_connect );
channel->http_connect = NULL;
WinHttpCloseHandle( channel->http_session );
channel->http_session = NULL;
}
static void free_channel( struct channel *channel )
{
reset_channel( channel );
WsFreeWriter( channel->writer );
WsFreeReader( channel->reader );
WinHttpCloseHandle( channel->http_request );
WinHttpCloseHandle( channel->http_connect );
WinHttpCloseHandle( channel->http_session );
heap_free( channel->addr.url.chars );
channel->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &channel->cs );
@ -225,6 +238,38 @@ void WINAPI WsFreeChannel( WS_CHANNEL *handle )
free_channel( channel );
}
/**************************************************************************
* WsResetChannel [webservices.@]
*/
HRESULT WINAPI WsResetChannel( WS_CHANNEL *handle, WS_ERROR *error )
{
struct channel *channel = (struct channel *)handle;
TRACE( "%p %p\n", handle, error );
if (error) FIXME( "ignoring error parameter\n" );
if (!channel) return E_INVALIDARG;
EnterCriticalSection( &channel->cs );
if (channel->magic != CHANNEL_MAGIC)
{
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
if (channel->state != WS_CHANNEL_STATE_CREATED && channel->state != WS_CHANNEL_STATE_CLOSED)
{
LeaveCriticalSection( &channel->cs );
return WS_E_INVALID_OPERATION;
}
reset_channel( channel );
LeaveCriticalSection( &channel->cs );
return S_OK;
}
/**************************************************************************
* WsGetChannelProperty [webservices.@]
*/
@ -343,17 +388,7 @@ HRESULT WINAPI WsOpenChannel( WS_CHANNEL *handle, const WS_ENDPOINT_ADDRESS *end
static HRESULT close_channel( struct channel *channel )
{
WinHttpCloseHandle( channel->http_request );
channel->http_request = NULL;
WinHttpCloseHandle( channel->http_connect );
channel->http_connect = NULL;
WinHttpCloseHandle( channel->http_session );
channel->http_session = NULL;
heap_free( channel->addr.url.chars );
channel->addr.url.chars = NULL;
channel->addr.url.length = 0;
reset_channel( channel );
channel->state = WS_CHANNEL_STATE_CLOSED;
return S_OK;
}

View File

@ -103,8 +103,68 @@ static void test_WsOpenChannel(void)
WsFreeChannel( channel );
}
static void test_WsResetChannel(void)
{
WCHAR url[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t'};
HRESULT hr;
WS_CHANNEL *channel;
WS_CHANNEL_STATE state;
WS_CHANNEL_TYPE type;
WS_ENDPOINT_ADDRESS addr;
ULONG size, timeout;
hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsResetChannel( channel, NULL );
ok( hr == S_OK, "got %08x\n", hr );
timeout = 5000;
size = sizeof(timeout);
hr = WsSetChannelProperty( channel, WS_CHANNEL_PROPERTY_RESOLVE_TIMEOUT, &timeout, size, NULL );
ok( hr == S_OK, "got %08x\n", hr );
addr.url.length = sizeof(url)/sizeof(url[0]);
addr.url.chars = url;
addr.headers = NULL;
addr.extensions = NULL;
addr.identity = NULL;
hr = WsOpenChannel( channel, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsResetChannel( channel, NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = WsCloseChannel( channel, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsResetChannel( channel, NULL );
ok( hr == S_OK, "got %08x\n", hr );
state = 0xdeadbeef;
size = sizeof(state);
hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_STATE, &state, size, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( state == WS_CHANNEL_STATE_CREATED, "got %u\n", state );
type = 0xdeadbeef;
size = sizeof(type);
hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_CHANNEL_TYPE, &type, size, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( type == WS_CHANNEL_TYPE_REQUEST, "got %u\n", type );
timeout = 0xdeadbeef;
size = sizeof(timeout);
hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_RESOLVE_TIMEOUT, &timeout, size, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( timeout == 5000, "got %u\n", timeout );
WsFreeChannel( channel );
}
START_TEST(channel)
{
test_WsCreateChannel();
test_WsOpenChannel();
test_WsResetChannel();
}

View File

@ -133,7 +133,7 @@
@ stub WsRemoveNode
@ stub WsRequestReply
@ stub WsRequestSecurityToken
@ stub WsResetChannel
@ stdcall WsResetChannel(ptr ptr)
@ stdcall WsResetError(ptr)
@ stdcall WsResetHeap(ptr ptr)
@ stub WsResetListener