Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
.gif)
| Previous | Next |
IWMSHeaderLine::GetValue
The GetValue method retrieves the client cookie.
Syntax
HRESULT GetValue( BSTR* pbstrValue );
Parameters
pbstrValue
[in] Pointer to a BSTR containing the cookie.
Return Values
If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
| Return code | Number | Description |
| E_INVALIDARG | 0x80070057 | pbstrValue is null. |
Example Code
// Declarations.
HRESULT hr = S_OK;
IWMSHeaderLine *pHeaderLine = NULL;
IWMSContext *pRequestContext = NULL;
IWMSContext *pResponseContext = NULL;
CComBSTR bstrCookie;
CComBSTR bstrNewSetCookie;
CComBSTR bstrOrigSetCookie;
hr = pCommandCtx->GetCommandRequest( &pRequestContext );
if (FAILED(hr))
return(hr);
hr = pCommandCtx->GetCommandResponse( &pResponseContext );
if (FAILED(hr))
return(hr);
// Retrieve a pointer to the IWMSHeaderLine interface.
// Specify the cookie value of the request context.
hr = pRequestContext->GetAndQueryIUnknownValue(
L"Cookie",
WMS_CONTEXT_NO_NAME_HINT,
IID_IWMSHeaderLine,
(IUnknown**) &pHeaderLine,
0);
if (FAILED(hr))
return(hr);
// Retrieve the cookie.
hr = pHeaderLine->GetValue( &bstrCookie );
if (FAILED(hr))
return(hr);
// If this is an authorization plug-in, you can add a Set-Cookie header
// to the response. This cannot be done from an event plug-in, however,
// because the response may already have been sent by the time the code
// is executed.
// TODO: You can modify the cookie here.
// Retrieve the "Set-Cookie" value from the response context if it
// already exists. Do not overwrite the existing value.
hr = pResponseContext->GetStringValue( L"Set-Cookie",
WMS_CONTEXT_NO_NAME_HINT,
&bstrOrigSetCookie,
0 );
if( SUCCEEDED( hr ) )
{
// The response already contains a Set-Cookie header. Concatenate
// your cookie to the existing value.
bstrNewSetCookie.AssignBSTR( bstrOrigSetCookie );
if( !bstrNewSetCookie )
{
return( E_OUTOFMEMORY );
}
bstrNewSetCookie.Append( L", " );
if( !bstrNewSetCookie )
{
return( E_OUTOFMEMORY );
}
bstrNewSetCookie.AppendBSTR( bstrCookie );
if( !bstrNewSetCookie )
{
return( E_OUTOFMEMORY );
}
}
else
{
// The response does not already contain a Set-Cookie header.
hr = S_OK;
bstrNewSetCookie.AssignBSTR( bstrCookie );
if( !bstrNewSetCookie )
{
return( E_OUTOFMEMORY );
}
}
// Specify the new cookie.
hr = pResponseContext->SetStringValue( L"Set-Cookie",
WMS_CONTEXT_NO_NAME_HINT,
bstrNewSetCookie,
0 );
if (FAILED(hr))
return(hr);
// Release the pointers.
Requirements
Header: wmsheaderline.h.
Library: WMSServerTypeLib.dll.
Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.
See Also
| Previous | Next |