Symbian3/SDK/Source/GUID-D535D51E-EAF5-581A-929B-5B1EF179A273.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 7 51a74ef9ed63
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-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>