COCSPTransportDefault::TTransportScheme COCSPTransportDefault::IdentifySchemeL(const TDesC8& aURI)
	{
	TTransportScheme ret = ETransportSchemeNotSupported;
	
	TUriParser8 uri;
	TInt error = uri.Parse(aURI);
	if (error != KErrNone || !uri.IsPresent(EUriScheme))
		{
		return ret;
		}
	const TPtrC8 scheme = uri.Extract(EUriScheme);
			
	RStringPool stringPool;
	stringPool.OpenL();
	CleanupClosePushL(stringPool);

	RStringF schemeF = stringPool.OpenFStringL(scheme);
	CleanupClosePushL(schemeF);
	RStringF httpF = stringPool.OpenFStringL(KHttpString);
	CleanupClosePushL(httpF);

	if (schemeF == httpF)
		{
		ret = ETransportSchemeHTTP;
		}

	CleanupStack::PopAndDestroy(3); // close httpF, schemeF, stringPool

	return ret;
	}
/**
	Checks whether a uri is valid or not. Will check whether the uri contains
	scheme, host and path.
	
	@param aUri [in] URI to validate. Only scheme and host presence is validated.
	
	@return TBool ETrue if the URI is successfully validated else EFalse.
 */	
TBool CTestWebBrowser::ValidateUri ( const TDesC8& aUri )
	{
	TUriParser8 uriParser;
	if ( uriParser.Parse ( aUri ) != KErrNone )
		{
		return EFalse;			
		}
	
	// check for scheme
	if ( !uriParser.IsPresent ( EUriScheme ) )
		{
		return EFalse;				
		}
	
	// check for host
	if ( !uriParser.IsPresent ( EUriHost) )
		{
		return EFalse;			
		}
	return ETrue;				
	}
Beispiel #3
0
/**
	Converts a 16-bit format uri into its internet form. Any Unicode characters 
	are converted into Utf8 representation and then any excluded characters are 
	escape encoded.  Reserved characters specified in RFC2396 will not be escape 
	encoded however, these include ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ",". 
	For example http://localhost will not be encoded to http%3A%2F%2Flocalhost.
	
	@since			6.0
	@deprecated	 Deprecated in 9.1
	@leave			KUriUtilsCannotConvert. When the input data cannot be converted.
	@leave			KUriUtilsErr16BitChar. When the input data has a 16-Bit character to be escape encoded.
	@param			aUri	The 16-bit format uri.
	@return			A pointer to a newly created 8-bit uri.
 */
EXPORT_C CUri8* UriUtils::ConvertToInternetFormL(const TUriC16& aUri)
	{
	// Need to convert to utf8
	HBufC8* utf8Buf = EscapeUtils::ConvertFromUnicodeToUtf8L(aUri.UriDes());
	CleanupStack::PushL(utf8Buf);

	// Ok need to parse for the uri without the fragment
	TUriParser8 parser;
	parser.Parse(*utf8Buf);
	TPtrC8 uriNoFragment;
	parser.UriWithoutFragment(uriNoFragment);

	// Now escape encode the uri without the fragment
	HBufC8* escapedBuf = EscapeUtils::EscapeEncodeL(uriNoFragment, EscapeUtils::EEscapeNormal);
	CleanupStack::PushL(escapedBuf);

	// Now escape encode the fragment if there is one...
	HBufC8* escapedFragmentBuf = NULL;
	if( parser.IsPresent(EUriFragment) )
		{
		escapedFragmentBuf = EscapeUtils::EscapeEncodeL(parser.Extract(EUriFragment), EscapeUtils::EEscapeNormal);
		CleanupStack::PushL(escapedFragmentBuf);
		}

	// Parse and then create the CUri8 object
	parser.Parse(*escapedBuf);
	CUri8* netForm = CUri8::NewL(parser);

	// Set the fragment if there was one...
	if( escapedFragmentBuf != NULL )
		{
		CleanupStack::PushL(netForm);
		netForm->SetComponentL(*escapedFragmentBuf, EUriFragment);
		CleanupStack::Pop(netForm);
		CleanupStack::PopAndDestroy(escapedFragmentBuf);
		}

	// Cleanup and return
	CleanupStack::PopAndDestroy(2, utf8Buf);	// utf8Buf, escapedBuf
	return netForm;
	}