Symbian3/PDK/Source/GUID-D535D51E-EAF5-581A-929B-5B1EF179A273.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Tue, 30 Mar 2010 11:56:28 +0100
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 14 578be2adaf3e
permissions -rw-r--r--
Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"

<?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-D535D51E-EAF5-581A-929B-5B1EF179A273" xml:lang="en"><title>Parsing
an URI</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>This tutorial describes the steps to parse an URI. </p>
<section><title>Introduction </title> <p>Parsing is done before performing
any of the following tasks: </p> <ul>
<li id="GUID-9A1003CA-B215-5AC6-BEE5-8A2803260219"><p>Extracting the URI components </p> </li>
<li id="GUID-E8705543-F900-5EA7-8CDF-683A03F9D83A"><p>Modifying the URI components </p> </li>
<li id="GUID-D89056C6-2F34-5F80-8C8D-26F215362DCD"><p>Getting the file name </p> </li>
<li id="GUID-0E42A1EE-C99E-594C-BB80-A1252FA024F1"><p>Modifying the delimiters </p> </li>
<li id="GUID-11FCEE3E-753B-5C67-AF99-F51CA7E23E02"><p>Resolving the URI </p> </li>
</ul> <p>The URI is parsed into its components (scheme, authority, path, query
and fragment) to check if they are syntactically correct. Also, the checks
the validity of individual components that needs to be parsed, using <xref href="GUID-EB2EEEF1-705B-334D-A4B0-3D0C4CBE2DA1.dita#GUID-EB2EEEF1-705B-334D-A4B0-3D0C4CBE2DA1/GUID-F72D57B8-DFD4-38B7-A54B-29103540E8AA"><apiname>TUriParser8::Parse()</apiname></xref>. </p> </section>
<section><title>Parsing an URI descriptor object</title> <p>The following
code fragment parses the URI descriptor object. It returns <codeph>KErrNone</codeph> if
parsing is successful and <codeph>EUriUtilsParserErrInvalidUri</codeph> if
the passed descriptor is invalid. </p> <codeblock id="GUID-C1B10F10-1D4E-5268-93D4-4C6ECA7C9F7C" xml:space="preserve">
LIT8( KUri,"http://web.intra/Dev/Sysdoc/devlib.htm" );
TUriParser8 parser;                          // URI parser object
TInt result = parser.Parse( KUri );            // Parse the URI descriptor 
const TDesC8&amp; des1 = parser.UriDes();        // Returns the parsed URI
</codeblock> <p>where, <codeph>KUri</codeph> is the URI descriptor to be parsed.
This code returns the descriptor containing <codeph>http://web.intra/Dev/Sysdoc/devlib.htm</codeph>,
the parsed form of the URI. </p> <p> <xref href="GUID-EB2EEEF1-705B-334D-A4B0-3D0C4CBE2DA1.dita#GUID-EB2EEEF1-705B-334D-A4B0-3D0C4CBE2DA1/GUID-F72D57B8-DFD4-38B7-A54B-29103540E8AA"><apiname>TUriParser8::Parse()</apiname></xref> parses
the URI components, except for SIP and SIPS scheme component. </p> </section>
<section><title>Parsing an authority component</title><p>To make use of the
authority parsing utilities, declare a <xref href="GUID-985C12CB-9230-3A35-9F5F-E455D4C23EBB.dita"><apiname>TAuthorityParser8</apiname></xref> parser
object, and parse the descriptor containing the URI authority component. Call <xref href="GUID-985C12CB-9230-3A35-9F5F-E455D4C23EBB.dita#GUID-985C12CB-9230-3A35-9F5F-E455D4C23EBB/GUID-7CCA2647-E8D0-312B-83BE-BE857FB61D0C"><apiname>TAuthorityParser8::Parse()</apiname></xref> to
parse the authority component. </p> <codeblock id="GUID-49539B54-F682-5CDD-BC57-44FAA006E1E9" xml:space="preserve">_LIT8( KAuthorityDesc,    "http://user:pass@www.mypage.com" );
TAuthorityParser8 authorityParser;                     // the authority parser object 
//Parse the authority component by passing authority descriptor   
authorityParser.Parse( KAuthorityDesc );  
const TDesC8&amp; des = authorityParser.AuthorityDes();    //retrieve the parsed URI
</codeblock> <p>where, <codeph>des</codeph> is a descriptor that contains
the parsed URI. </p></section>
<section><title> See also</title> <p>For related information, see <xref href="GUID-795B41AF-FBEA-56CE-AE20-EF17BE754723.dita">HTTP
Utilities Library Overview</xref> </p> </section>
</conbody></concept>