Symbian3/SDK/Source/GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?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-AFAD0F36-330B-50BD-B810-85BE7FA21179" xml:lang="en"><title>HTTP
Utilities Library (InetProtUtils) Example</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-627EB2DD-530A-5A6E-AC58-854A5C8D636B"><title>Download</title> <p>Click
on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-0ab18a4d-c1a6-49bc-9420-3200f7ead173.zip" scope="external">ExampleInetProtUtil.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-0ab18a4d-c1a6-49bc-9420-3200f7ead173.html" scope="peer">browse</xref> to view the example code. </p> </section>
<section><title>Description</title> <p>This example code demonstrates
the usage of utilities provided by the InetProtUtil API. The users should
have a prior knowledge of concepts associated with it, such as URLs and URI
components. </p> <p>The central class is <codeph>CExampleInetProtUtil</codeph>,
which demonstrates the following functionality: </p> <ul>
<li id="GUID-52A8E18E-25F2-50F1-820D-5A892160F031"><p><xref href="GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita#GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179/GUID-E3A0AB40-553E-5689-A703-075C75430B29">Creating a URI</xref>  </p> </li>
<li id="GUID-C6E9655F-237D-5406-85EF-6D5A0EB5C140"><p><xref href="GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita#GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179/GUID-FBCF247C-5660-5A72-B837-AFAC9E51FF60">Modifying a URI</xref>  </p> </li>
<li id="GUID-1397CABB-FCAB-53D8-94EE-0E9A3353FD21"><p><xref href="GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita#GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179/GUID-DBB7553C-0334-55CB-A5DE-9A233E88780E">Resolving a URI</xref>  </p> </li>
<li id="GUID-9443407C-F9C3-51FF-B3A9-93AB1DC60955"><p><xref href="GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita#GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179/GUID-C3DE7478-80E4-5E05-90F9-C32E8C2624B2">Parsing a URI</xref>  </p> </li>
<li id="GUID-11D5D373-22D0-529D-9B4F-E8DD7470853B"><p><xref href="GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita#GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179/GUID-F8F98700-948D-542C-9B39-6DE3E257C3F3">Validating a URI</xref>  </p> </li>
<li id="GUID-9249C891-4F25-53C8-ACBE-C0FA166D64F6"><p><xref href="GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita#GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179/GUID-B196045B-6DAF-561F-950C-5CDFB8B854A6">Extracting URI components</xref>  </p> </li>
<li id="GUID-8665CD3D-B632-5863-A0D3-BEEEB64CB017"><p><xref href="GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita#GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179/GUID-D30B9D97-7ADE-58EA-9AC0-8DC2095BCBEC">Retrieving a filename from a URI</xref>  </p> </li>
<li id="GUID-29D99927-864E-5FB5-BB61-C96C8636E334"><p><xref href="GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita#GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179/GUID-20375BA7-F367-5E12-9DC6-F9BDF4146E8A">Adding and removing delimiters from a URI</xref>  </p> </li>
<li id="GUID-F956A7AA-CA58-53C5-B08A-19E1575E0CC1"><p><xref href="GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita#GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179/GUID-363D45CC-AC6E-5397-B825-086919FCBF50">Removing whitespace from a URI</xref>  </p> </li>
<li id="GUID-809AF54B-EBD5-5DC5-9A36-4D02721BF1EB"><p><xref href="GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179.dita#GUID-AFAD0F36-330B-50BD-B810-85BE7FA21179/GUID-EC077086-FC68-50ED-8BCC-AFBD58205186">Escape encoding and decoding a URI</xref>  </p> </li>
</ul> <p id="GUID-E3A0AB40-553E-5689-A703-075C75430B29"><b>Creating a URI</b> </p> <codeblock id="GUID-734568B9-1C2F-53A7-9D00-4FDEC52C06C6" xml:space="preserve">void CExampleInetProtUtil::CreateUri();</codeblock> <p>Creates
a URI with respect to the physical path of a given file. </p> <p>For example,
the physical path of the file: </p> <p> <codeph>K:/ws/direct/direct.mmp</codeph>  </p> <p>gives
the following URI file: </p> <p> <codeph>///k/ws/direct/direct.mmp</codeph>  </p> <p>The
screen output from this example is: </p> <fig id="GUID-2E1622EE-F5BF-57AD-9D1A-49FA6A0450E6">
<image href="GUID-ADCDEFF9-4B1D-5E46-A63B-808192123E15_d0e168926_href.jpg" placement="inline"/>
</fig> <p id="GUID-FBCF247C-5660-5A72-B837-AFAC9E51FF60"><b>Modifying a URI</b> </p> <codeblock id="GUID-8B77F94A-4DCC-5798-A2A6-DC778272D12B" xml:space="preserve">void CExampleInetProtUtil::ModifyUriComponents();</codeblock> <p>Modifies
URI components, which involves: </p> <ol id="GUID-505AE129-749E-540C-BAB2-5A079EC29B6B">
<li id="GUID-C4DF42D7-D9BE-5557-A138-B60444172631"><p>Adding URI components,
where it constructs the URI component by component. For example, you can add
the following components: </p> <ul>
<li id="GUID-767B1184-E01F-5FAA-BC14-9E12BA1B121B"><p>scheme: <codeph>http</codeph>  </p> </li>
<li id="GUID-8F2010FF-238A-53A6-BAB9-790CDDAA7804"><p>host: <codeph>waterlang.org</codeph>  </p> </li>
<li id="GUID-19457F90-63E1-59AA-B046-C2BB64AA1EC8"><p>path: <codeph>main_page.html</codeph>  </p> </li>
<li id="GUID-151867C7-8F3C-57FB-A2BE-2622CB16813C"><p>port: <codeph>8080</codeph>  </p> </li>
</ul> <p>to get the complete URI: </p> <p> <codeph>http://waterlang.org:8080/main_page.html</codeph>  </p> <p>The
screen output from this example is: </p> <fig id="GUID-C43845C7-9458-546F-A625-857BF63E21A0">
<image href="GUID-6740A668-33A2-52B1-9416-E9F21591D16C_d0e168995_href.jpg" placement="inline"/>
</fig> </li>
<li id="GUID-E1E71C35-8D25-5F50-ADCD-5441FECEDF67"><p>Removing the specific
URI component(s) from a constructed URI. For example, the above URI with the
port number removed: </p> <p> <codeph>http://waterlang.org/main_page.html</codeph>  </p> <p>The
screen output from this example is: </p> <fig id="GUID-8658720B-DD49-5BF8-B016-0C1FD970E982">
<image href="GUID-817D677C-2422-52B1-8D44-D15A0351FDC6_d0e169014_href.jpg" placement="inline"/>
</fig> </li>
</ol> <p id="GUID-DBB7553C-0334-55CB-A5DE-9A233E88780E"><b>Resolving a URI</b> </p> <codeblock id="GUID-3782F8CB-BA3D-5F9E-AB48-4596DC2E024E" xml:space="preserve">void CExampleInetProtUtil::ResolveUri();</codeblock> <p>Resolves
the URI, which involves creation of an absolute <xref href="GUID-9D22BBBA-2DF2-36D2-BD07-5DE56F8541AA.dita"><apiname>CUri</apiname></xref> object
from a given reference URI. </p> <p>The screen output from this example is: </p> <fig id="GUID-10AC8723-7DAE-5DC9-A568-C3011B9DB040">
<image href="GUID-FB12481D-B3F6-5901-A0DC-DF92BCED3B18_d0e169039_href.jpg" placement="inline"/>
</fig> <p id="GUID-C3DE7478-80E4-5E05-90F9-C32E8C2624B2"><b>Parsing a URI</b> </p> <codeblock id="GUID-48E262B6-D776-5158-8FFD-1F8C43F9710B" xml:space="preserve">void CExampleInetProtUtil::ParseUri();</codeblock> <p>Parses
the URI into its components (as given in <xref href="ftp://ftp.rfc-editor.org/in-notes/rfc2396.txt" scope="external">RFC2396</xref>). The five URI components are: </p> <ul>
<li id="GUID-C3E34C3E-82A4-5410-A054-5D05F0E52942"><p>scheme </p> </li>
<li id="GUID-C4D445B3-B0DB-5969-8E12-38D525C973C2"><p>authority </p> </li>
<li id="GUID-91A17058-D565-5557-B848-DFA375A0F8D6"><p>path </p> </li>
<li id="GUID-7ED0DC97-4A46-5307-B2F8-C5BA41AE7C1A"><p>query </p> </li>
<li id="GUID-2910FC88-DB70-534C-8289-25A4D3DE83E2"><p>fragment. </p> </li>
</ul> <p>The screen output from this example is: </p> <fig id="GUID-403B3926-A0E1-57A8-ADEF-1ECE198876D1">
<image href="GUID-C31DA918-8DEA-5816-B0A6-4AE90B06DD0D_d0e169089_href.jpg" placement="inline"/>
</fig> <p id="GUID-F8F98700-948D-542C-9B39-6DE3E257C3F3"><b>Validating a URI</b> </p> <codeblock id="GUID-294998AC-0125-52C0-82EF-C76729E0122C" xml:space="preserve">void CExampleInetProtUtil::ValidateUriComponents();</codeblock> <p>Validates
a given URI. This function is usually used for URIs with SIP as the scheme. </p> <p>The
screen output from this example is: </p> <fig id="GUID-16B862C4-804F-5751-ACE4-4C3DDC388617">
<image href="GUID-71B31715-3B6A-50F0-86C1-8F7F76985802_d0e169108_href.jpg" placement="inline"/>
</fig> <p id="GUID-B196045B-6DAF-561F-950C-5CDFB8B854A6"><b>Extracting URI
components</b> </p> <codeblock id="GUID-5FBD44E5-F6B9-55C9-BA71-B350B291C666" xml:space="preserve">void CExampleInetProtUtil::ExtractUriComponents();</codeblock> <p>Extracts
URI components from the given URI. </p> <p>The screen output from this example
is: </p> <fig id="GUID-C5AB909C-05DF-5570-A343-B7DD1A8B9EB2">
<image href="GUID-E2455472-49FA-5492-B7CB-2C33BD830591_d0e169127_href.jpg" placement="inline"/>
</fig> <p id="GUID-D30B9D97-7ADE-58EA-9AC0-8DC2095BCBEC"><b>Retrieving a filename
from a URI</b> </p> <codeblock id="GUID-87962D71-02C6-5553-AB4A-51B3AECC837D" xml:space="preserve">void CExampleInetProtUtil::RetrieveFileName();</codeblock> <p>Extracts
the actual physical location of the file from its URI. </p> <p>The screen
output from this example is: </p> <fig id="GUID-45C9AE9D-DBB4-53C3-A547-AB8713039796">
<image href="GUID-C4D0F943-442D-5F3B-BB5E-6B52C33ABBC6_d0e169146_href.jpg" placement="inline"/>
</fig> <p id="GUID-20375BA7-F367-5E12-9DC6-F9BDF4146E8A"><b>Adding and removing
delimiters from a URI</b> </p> <codeblock id="GUID-A8A9773C-4657-5A21-8C40-6E4DAEC49850" xml:space="preserve">void CExampleInetProtUtil::ModifyDelimiter();</codeblock> <p>Adds the delimiters to and removes the delimiters from a URI. Before
doing this ensure that: </p> <ul>
<li id="GUID-072163F7-ECEC-54E5-A664-F4268898DEA9"><p>the delimiter is set
using <xref href="GUID-F8ED680B-1426-337A-8D78-18D0B7BE1EF2.dita"><apiname>SetDelimiter()</apiname></xref>  </p> </li>
<li id="GUID-F1482980-93FC-5D5D-A89F-1D16A5F46AAE"><p>the URI has already
been parsed. </p> </li>
</ul> <p>The screen output from this example is: </p> <fig id="GUID-A7E7FD6F-3A1D-578A-85FE-7F3F771EE046">
<image href="GUID-236C0D1D-AC4C-5C08-9089-1AC59881CD39_d0e169182_href.jpg" placement="inline"/>
</fig> <p id="GUID-363D45CC-AC6E-5397-B825-086919FCBF50"><b>Removing whitespace
from a URI</b> </p> <codeblock id="GUID-A3A5053B-B12E-509B-98C7-9EE7095A9E57" xml:space="preserve">void CExampleInetProtUtil::WhiteSpaceRemover();</codeblock> <p>Removes
the whitespace from the given URI and returns the number of white spaces that
were removed. </p> <p>The screen output from this example is: </p> <fig id="GUID-0EC52CDC-5D6B-58F1-A817-0674CF66535A">
<image href="GUID-F740BA72-B00E-5D98-BD0F-5937F60460BC_d0e169201_href.jpg" placement="inline"/>
</fig> <p id="GUID-EC077086-FC68-50ED-8BCC-AFBD58205186"><b>Escape encoding
and decoding a URI</b> </p> <codeblock id="GUID-C62B11E9-0FE4-5CF4-A96A-5DB0E4E82A33" xml:space="preserve">void CExampleInetProtUtil::EscapeEncodeDecode();</codeblock> <p>Escape encodes the characters in a given URI as escape triplets and decodes
it to the original one. </p> <p>The screen output from this example is: </p> <fig id="GUID-0AC8D213-9857-56A1-9DC6-E6FBE137B608">
<image href="GUID-A92CE0FF-113F-55BE-B5EF-7E5C629A4557_d0e169220_href.jpg" placement="inline"/>
</fig> </section>
<section><title>Class Summary</title><p><xref href="GUID-E6F8C94C-C74C-329B-BB11-E06F0E83A4BB.dita"><apiname>CUri8</apiname></xref></p><p><xref href="GUID-EB2EEEF1-705B-334D-A4B0-3D0C4CBE2DA1.dita"><apiname>TUriParser8</apiname></xref></p><p><xref href="GUID-9CC256C4-D4A2-3534-9B3C-2FBF1AAE5F51.dita"><apiname>EscapeUtils</apiname></xref></p><p><xref href="GUID-B647B6DA-5FF1-3C11-9ACD-E4A5E70F3596.dita"><apiname>TDelimitedParserBase8</apiname></xref></p><p><xref href="GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE.dita"><apiname>InetProtTextUtils</apiname></xref></p></section>
</conbody></concept>