--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/PDK/Source/GUID-7800A00C-5BD3-46FA-9D0A-9DF29A5C057E.dita Fri Jan 22 18:26:19 2010 +0000
@@ -0,0 +1,163 @@
+<?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-7800A00C-5BD3-46FA-9D0A-9DF29A5C057E" xml:lang="en"><title>Specific
+header formats</title><prolog><metadata><keywords/></metadata></prolog><conbody>
+<p>This section describes the headers that have specific support for encoding
+or decoding using parts and parameters. Other headers not listed are encoded
+and decoded using a default mechanism that assumes the header field has a
+single part with a string value. </p>
+<section id="GUID-210B3CBF-2885-434C-A8DF-418D5A986088"><title>Accept</title> <p>This
+is a client request header. </p><codeblock id="GUID-1AB0D534-093B-5B81-A80D-D9002A5BA886" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+// Setting a single media range with no parameter, i.e. Accept: text/html
+RStringF textHtml = iStrTb.OpenFStringL(_L8("text/html"));
+CleanupClosePushL(textHtml);
+THTTPHdrVal accVal(textHtml);
+hdr.SetFieldL(iStrTb.String(HTTP::EAccept,RHTTPSession::GetTable()), accVal);
+CleanupStack::PopAndDestroy(&textHtml);
+// Setting several media ranges with no parameters, i.e. Accept: text/html; text/vnd.wap.wml
+RStringF textHtml = iStrTb.OpenFStringL(_L8("text/html"));
+CleanupClosePushL(textHtml);
+RStringF textWml = iStrTb.OpenFStringL(_L8("text/vnd.wap.wml"));
+CleanupClosePushL(textWml);
+THTTPHdrVal accVal(textHtml);
+hdr.SetFieldL(iStrTb.String(HTTP::EAccept,RHTTPSession::GetTable()), accVal);
+accVal.SetStr(textWml);
+hdr.SetFieldL(iStrTb.String(HTTP::EAccept,RHTTPSession::GetTable()), accVal);
+CleanupStack::PopAndDestroy(&textHtml);
+CleanupStack::PopAndDestroy(&textWml);
+// Setting a media range with a 'q' parameter, Accept: text/html; q=0.8
+RStringF textHtml = iStrTb.OpenFStringL(_L8("text/html"));
+CleanupClosePushL(textHtml);
+THTTPHdrVal accVal(textHtml);
+THTTPHdrVal q(THTTPHdrVal::TQConv(0.8));
+hdr.SetFieldL(iStrTb.String(HTTP::EAccept,RHTTPSession::GetTable()), accVal, iStrTb.String(HTTP::EQ,RHTTPSession::GetTable()), q);
+CleanupStack::PopAndDestroy(&textHtml);
+// Using an accept extension, Accept: text/html; extended=value
+RStringF textHtml = iStrTb.OpenFStringL(_L8("text/html"));
+CleanupClosePushL(textHtml);
+RStringF extended = iStrTb.OpenFStringL(_L8("extended"));
+CleanupClosePushL(extended);
+RStringF extendVal = iStrTb.OpenFStringL(_L8("value"));
+CleanupClosePushL(extendVal);
+
+THTTPHdrVal accVal(textHtml);
+THTTPHdrVal extVal(extendVal);
+
+hdr.SetFieldL(iStrTb.String(HTTP::EAccept,RHTTPSession::GetTable()), accVal, extended, extVal);
+CleanupStack::PopAndDestroy(3); // textHtml, extended, extendVal</codeblock>
+ </section>
+<section id="GUID-37A82EFB-820A-4BD0-BA38-F3507F709E73"><title>Accept-Charset</title><p>This is a client request header. </p><codeblock id="GUID-EE14D9C1-1EEE-56FF-91F0-2B3BB8455A65" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+// Setting up two accepted character sets, i.e. Accept-Charset: us-ascii, utf-8
+RStringF usAscii = iStrTb.OpenFStringL(_L8("us-ascii"));
+CleanupClosePushL(usAscii);
+RStringF utf8 = iStrTb.OpenFStringL(_L8("utf-8"));
+CleanupClosePushL(utf8);
+THTTPHdrVal accChSetVal(usAscii);
+hdr.SetFieldL(iStrTb.String(HTTP::EAcceptCharset,RHTTPSession::GetTable()), accChSetVal);
+// sets the first part accChSetVal.(SetStrutf8);
+hdr.SetFieldL(iStrTb.String(HTTP::EAcceptCharset,RHTTPSession::GetTable()), accChSetVal);
+// adds an additional part usAscii.Close();
+CleanupStack::PopAndDestroy(2);</codeblock></section>
+<section id="GUID-28FB5629-78CC-4229-B30D-6EF40F8E3C33"><title>Authorisation</title><p>This is a client request header. <b>Note:</b> The
+client need not set this header for most normal requests. </p><codeblock id="GUID-5D430FE4-8EE4-5537-818F-B7C9EBFC923D" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+// Setting an authorization credential, i.e. Authorization: Basic c3ltYmlhbjpmMXN5bmNtbA==
+RStringF basicCred = iStrTb.OpenFStringL(_L8("c3ltYmlhbjpmMXN5bmNtbA=="));
+CleanupClosePushL(basicCred);
+THTTPHdrVal authVal(iStrTb.String(HTTP::EBasic,RHTTPSession::GetTable()));
+hdr.SetFieldL(iStrTb.String(HTTP::EAuthorization,RHTTPSession::GetTable()), authVal);
+authVal.(SetStrbasicCred);
+hdr.SetFieldL(iStrTb.String(HTTP::EAuthorization,RHTTPSession::GetTable()), authVal);
+CleanupStack::PopAndDestroy(&basicCred);</codeblock></section>
+<section id="GUID-64B95F8D-3E6D-48F6-A7E1-C997C69F5C6A"><title>Connection</title><p>This is a general header, that is, it
+applies to the connection between client and server. <b>Note:</b> The client
+need not set this header for normal, persistent HTTP/1.1 requests. </p><codeblock id="GUID-96A98445-2D81-555B-A727-CA364F906F04" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+// Indicate that the connection is to close, i.e. Connection: close
+THTTPHdrVal closeVal(iStrTb.String(HTTP::EClose,RHTTPSession::GetTable()));
+hdr.SetFieldL(iStrTb.String(HTTP::EConnection,RHTTPSession::GetTable()), closeVal);
+</codeblock></section>
+<section id="GUID-8F6F6A87-0C05-4635-BBCD-72B5E4AFB3CC"><title>Content-Length</title><p>This is an entity header, that is,
+it applies to the body present in a request or a response. <b>Note:</b> The
+client should not set this header for any request: it will be ignored. </p><codeblock id="GUID-58334818-7616-50EA-9862-2701610EB12D" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+// Set a content length of 12345, i.e. Content-Length: 12345
+THTTPHdrVal lengthVal(12345);
+hdr.SetFieldL(iStrTb.String(HTTP::EContentLength,RHTTPSession::GetTable()), lengthVal);
+</codeblock></section>
+<section id="GUID-6639232A-25C9-4CB6-9FF3-7F1EF3D8E148"><title>Content-Type</title><p>This is an entity header, that is,
+it applies to the body present in a request or a response. </p><codeblock id="GUID-8BCE3E31-E6A6-5908-AF87-A1CA6591D223" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+// Set a content type of text/html, i.e. Content-Type: text/html
+THTTPHdrVal contTypeVal(iStrTb.String(HTTP::ETextHtml,RHTTPSession::GetTable()));
+hdr.SetFieldL(iStrTb.String(HTTP::EContentType,RHTTPSession::GetTable()), contTypeVal);
+</codeblock></section>
+<section id="GUID-897C8418-2567-4739-8AFE-BE14A2FBC07D"><title>Date</title><p>This is a general header, that is, it applies
+to the connection between client and server. All three date formats specified
+in RFC2616 are supported in responses. Requests will be made using the RFC1123
+format only. </p><codeblock id="GUID-DE554314-FFAD-5807-B83E-70151BE366B0" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+// Set a date of 9th August 2001, time 13:45:00.000, i.e. Date: Thu, 09 Aug 2001 13:45:00 GMT
+THTTPHdrVal dateVal(TDateTime(2001, EAugust, 8, 13, 45, 0, 0));
+// note, the day starts at 0
+hdr.SetFieldL(iStrTb.String(HTTP::EDate,RHTTPSession::GetTable()), dateVal);
+</codeblock></section>
+<section id="GUID-D1120183-9158-44D6-B64B-A9D8263B7174"><title>Host</title><p>This is a client request header. <b>Note:</b> The
+client should not set this header for any request unless the URL is relative. </p><codeblock id="GUID-A20C80EF-185A-57EF-9F36-D547D5E458C0" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+// Set a host 'www.symbian.com', i.e. Host: www.symbian.com
+_LIT8(host, "www.symbian.com");
+RStringF hostValStr = iStrTb.OpenFStringL(host);
+CleanupClosePushL(hostValStr);
+THTTPHdrVal hostVal(hostValStr);
+hdr.SetFieldL(hostStr, hostVal);
+CleanupStack::PopAndDestroy(&hostValStr);</codeblock></section>
+<section id="GUID-8AA02D22-54A6-4250-9350-D9DE3B0E93B5"><title>Transfer-Encoding</title><p>This is a general header, that
+is, it applies to the connection between client and server. <b>Note:</b> The
+client should not set this header for any request, as it will be ignored. </p><codeblock id="GUID-868090A3-4534-54DE-8B46-B19BA4077B10" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+// Set the transfer encoding to be 'chunked', i.e. Transfer-Encoding: chunked
+THTTPHdrVal xferEncVal;
+xferEncVal.SetStrF(iStrTb.StringF(HTTP::EChunked,RHTTPSession::GetTable()));
+hdr.SetFieldL(iStrTb.StringF(HTTP::ETransferEncoding,RHTTPSession::GetTable()), xferEncVal);
+</codeblock></section>
+<section id="GUID-E3C924A2-E426-496E-BFDD-BA6E85E40F09"><title>User-Agent</title><p>This is a client request header. </p> <codeblock id="GUID-987775EF-4346-57C3-84DB-4C05683DD5D8" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+// Set up a user agent with two part, i.e. User-Agent: CERN-LineMode/2.15 libwww/2.17b3
+RStringF ua1Str = iStrP.OpenFStringL(_L8("CERN-LineMode/2.15"));
+CleanupClosePushL(ua1Str);
+RStringF ua2Str = iStrP.OpenFStringL(_L8("libwww/2.17b3"));
+CleanupClosePushL(ua2Str);
+RStringF uaStr = iStrP.StringF(HTTP::EUserAgent,RHTTPSession::GetTable());
+THTTPHdrVal uaVal(ua1Str);
+hdr.SetFieldL(uaStr, uaVal);
+// sets part 1 uaVal.SetStrF(ua2Str);
+hdr.SetFieldL(uaStr, uaVal);
+// sets part 2
+CleanupStack::PopAndDestroy(2);</codeblock></section>
+<section id="GUID-8127BB03-00A9-4815-83F8-69838862B17A"><title>WWW-Authenticate</title><p>This is a server response header. <b>Note:</b> The
+client need not read this header for most normal responses. </p> <codeblock id="GUID-5ED4C598-80E5-5514-A616-AFCA5D1D4002" xml:space="preserve">RHTTPHeaders hdr = aReq.GetHeaderCollection();
+...
+// 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) &&
+ (!hdr.GetParam(wwwAuth, realm, realmVal)))
+ {
+ RStringF realmValStr = strP.StringF(realmVal.StrF());
+ fieldVal16.Copy(realmValStr.DesC());
+ iUtils.Test().Printf(_L("Realm is: %S\n"), &fieldVal16);
+ realmValStr.Close();
+ }
+ basic.Close();
+ realm.Close();
+ }
+ wwwAuth.Close();
+hdr.Close();</codeblock></section>
+</conbody></concept>
\ No newline at end of file