Symbian3/SDK/Source/GUID-B432A48B-46CE-4FD4-880E-DA15AA304CAA.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-B432A48B-46CE-4FD4-880E-DA15AA304CAA" xml:lang="en"><title>Adding,
removing, and accessing header field parameters</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-D96EA794-4D54-4F15-B839-EBA42687751F"> <p>Parameters can be associated with header field parts at the time
of adding the part. There are two variants of <xref href="GUID-54F9A87B-FE2F-3429-9793-0A24B83466B9.dita#GUID-54F9A87B-FE2F-3429-9793-0A24B83466B9/GUID-A8708AE6-8EAE-37C9-BAD2-87E4A7DCE266"><apiname>RHTTPHeaders::SetFieldL()</apiname></xref>:
the first is described previously. The second variant takes four parameters,
of which two specify the part name/value and two specify the parameter name/value. </p> <p>To
associate more than one parameter with the part, the function must be invoked
repeatedly. This does not create duplicate parts; rather it locates the part
with the specified value, and then adds additional parameters. </p> <p>To
remove parameters from header parts, the entire part must be removed using <xref href="GUID-54F9A87B-FE2F-3429-9793-0A24B83466B9.dita#GUID-54F9A87B-FE2F-3429-9793-0A24B83466B9/GUID-656EF7AC-479E-3408-B00C-9FAE3022A37B"><apiname>RHTTPHeaders::RemoveFieldPart()</apiname></xref>,
and then added again. </p> <p>To access parameter values, the header name
and parameter name must be specified. <xref href="GUID-54F9A87B-FE2F-3429-9793-0A24B83466B9.dita#GUID-54F9A87B-FE2F-3429-9793-0A24B83466B9/GUID-AAEA368C-D8E6-365E-8B05-31CC812F0469"><apiname>RHTTPHeaders::GetParam()</apiname></xref> is
used, and has an optional fourth parameter in which the part index can be
provided. If not, the API assumes that the first header part contains the
parameter. </p> <p>The following code from <filepath>HTTPEXAMPLECLIENT</filepath> illustrates
the use of header parameters with the <codeph>WWW-Authenticate</codeph> header: </p> <codeblock id="GUID-DAD45847-DD81-54D3-AD90-C40A5F7ABC45" xml:space="preserve">// Display realm for WWW-Authenticate header
            RStringF wwwAuth = strP.StringF(HTTP::EWWWAuthenticate,RHTTPSession::GetTable());
            if (fieldNameStr == wwwAuth)
                {
                // check the auth scheme is 'basic'
                RStringF basic = strP.StringF(HTTP::EBasic,RHTTPSession::GetTable());
                RStringF realm = strP.StringF(HTTP::ERealm,RHTTPSession::GetTable());
                THTTPHdrVal realmVal;
                if ((fieldVal.StrF() == basic) &amp;&amp; 
                    (!hdr.GetParam(wwwAuth, realm, realmVal)))
                    {
                    RStringF realmValStr = strP.StringF(realmVal.StrF());
                    fieldVal16.Copy(realmValStr.DesC());
                    iUtils.Test().Printf(_L("Realm is: %S\n"), &amp;fieldVal16);
                    realmValStr.Close();
                    }
                basic.Close();
                realm.Close();
                }
            wwwAuth.Close();</codeblock> </section>
</conbody></concept>