Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to parse a URI

[Top]


Parsing a URI

Parse the URI to check if the components in the URI are syntactically correct as per the four main components and fragment identifier(#). Also, the individual components need to be parsed to check their validity. TUriParser8::Parse() allows you to do this.

The code fragment below parses the URI descriptor object. It returns KErrNone if parsing is successful and EUriUtilsParserErrInvalidUri if the passed descriptor is invalid.

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& des1 = parser.UriDes();// returns the parsed URI

where, KUri is the URI descriptor to be parsed. This code returns the descriptor containing http://web.intra/Dev/Sysdoc/devlib.htm, the parsed form of the URI.

Parsing is done before performing any of the following tasks:

TUriParser8::Parse() parses the URI components, except for SIP and SIPS scheme component.

[Top]


Parsing an authority component

To make use of the authority parsing utilities, declare a TAuthorityParser8 parser object, and parse the descriptor containing the URI authority component. Call TAuthorityParser8::Parse() to parse the authority component.

_LIT8(KAuthorityDesc,       "http://user:[email protected]");
TAuthorityParser8 authorityParser; // the authority parser object 
//Parse the authority component by passing authority descriptor   
authorityParser.Parse(KAuthorityDesc);  
const TDesC8& des = authorityParser.AuthorityDes();//retrieve the parsed URI

where, des is a descriptor that contains the parsed URI.

[Top]


See also

For related information, see:

InetProtUtils Overview