当前位置: 首页>>代码示例>>C++>>正文


C++ THTTPHdrVal::Str方法代码示例

本文整理汇总了C++中THTTPHdrVal::Str方法的典型用法代码示例。如果您正苦于以下问题:C++ THTTPHdrVal::Str方法的具体用法?C++ THTTPHdrVal::Str怎么用?C++ THTTPHdrVal::Str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在THTTPHdrVal的用法示例。


在下文中一共展示了THTTPHdrVal::Str方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetHdrVal

TBool CHttpEventHandler::GetHdrVal( THTTPHdrVal& hdrVal, RStringPool& pool)
{
	TBool retval = ETrue;
	TPtrC8 auth_token((const TUint8*)"auth_token");
	
	switch (hdrVal.Type())
	{
		case THTTPHdrVal::KStrFVal:
			{
				RStringF fieldNameStr = pool.StringF(hdrVal.StrF());
				const TDesC8& fieldNameDesC = fieldNameStr.DesC();
				
				if (iVerbose)
				{
					TBuf<CHttpConstants::KMaxHeaderValueLen>  value;
					value.Copy(fieldNameDesC.Left(CHttpConstants::KMaxHeaderValueLen));
					iTest->Console()->Printf(_L("%S:\n"), &value);
				}

				if ( fieldNameDesC.Length() > 0 && fieldNameDesC.Compare(auth_token) )
					iCookies.Append(fieldNameDesC);
				else
					retval = EFalse;
			}
			break;
		case THTTPHdrVal::KStrVal:
			{
				RString fieldNameStr = pool.String(hdrVal.Str());
				const TDesC8& fieldNameDesC = fieldNameStr.DesC();
				
				if (iVerbose)
				{
					TBuf<CHttpConstants::KMaxHeaderValueLen>  value;
					value.Copy(fieldNameDesC.Left(CHttpConstants::KMaxHeaderValueLen));
					iTest->Console()->Printf(_L("%S:\n"), &value);
				}
				
				if ( fieldNameDesC.Length() > 0 && fieldNameDesC.Compare(auth_token) )
					iCookies.Append(fieldNameDesC);
				else
					retval = EFalse;
			}
			break;
	}
	
	return retval;
}
开发者ID:DoktahWorm,项目名称:rhodes,代码行数:47,代码来源:HttpEventHandler.cpp

示例2: ParseHeadersL

void CHttpController::ParseHeadersL( RHTTPTransaction& aTransaction )
	{
	const TInt KMaxNumericLen = 32;

	RStringPool stringPool = aTransaction.Session().StringPool();
	RHTTPHeaders header = aTransaction.Response().GetHeaderCollection();
	THTTPHdrFieldIter iterator = header.Fields();

	HBufC8* fieldName8 = NULL;
	HBufC8* fieldVal8 = NULL;
	CHttpHeaders* headers = CHttpHeaders::NewLC();
	while ( !iterator.AtEnd() )
		{
		RStringTokenF fieldName = iterator();
		RStringF fieldNameStr = stringPool.StringF( fieldName );
		THTTPHdrVal fieldVal;
		if ( header.GetField( fieldNameStr, 0, fieldVal ) == KErrNone )
			{
			fieldName8 = fieldNameStr.DesC().AllocLC();
			switch ( fieldVal.Type() )
				{
				case THTTPHdrVal::KTIntVal:
					{
					fieldVal8 = HBufC8::NewLC( KMaxNumericLen );
					TPtr8 ptr( fieldVal8->Des() );
					ptr.Num( fieldVal.Int() );
					break;
					}
				case THTTPHdrVal::KStrFVal:
					{
					RStringF fieldValStr = stringPool.StringF( fieldVal.StrF() );
					fieldVal8 = fieldValStr.DesC().AllocLC();
					break;
					}
				case THTTPHdrVal::KStrVal:
					{
					RString fieldValStr = stringPool.String( fieldVal.Str() );
					fieldVal8 = fieldValStr.DesC().AllocLC();
					break;
					}
				case THTTPHdrVal::KDateVal:
					{
					_LIT(KDateFormat,"%D%M%Y%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S.%C%:3");
					TDateTime date = fieldVal.DateTime();
					const TInt KMaxDateBuferLength = 100;
					TBuf< KMaxDateBuferLength > dateBuffer;
					TTime time( date );
					time.FormatL( dateBuffer, KDateFormat );
					fieldVal8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( dateBuffer );
					CleanupDeletePushL( fieldVal8 );
					break;
					}
				default:
					User::Leave( KErrNotSupported );//new field types will be added in future
					break;
				}
			if ( !fieldVal8 )
				{
				CleanupStack::PopAndDestroy( fieldName8 );
				}
			else
				{
				headers->AddL( *fieldName8, *fieldVal8 );
				CleanupStack::PopAndDestroy( 2, fieldName8 );
				}
			fieldVal8 = NULL;
			fieldName8 = NULL;
			}
		++iterator;
		}

	iObserver->HeadersReceivedL( headers );
	CleanupStack::Pop( headers );
	}
开发者ID:Symbian9,项目名称:symbian-http-engine,代码行数:74,代码来源:HttpController.cpp

示例3: EncodeAuthorizationL

void CHttpClientHeaderWriter::EncodeAuthorizationL(RHeaderField& aHeader) const
/**
	Encodes the authorization header. RFC2616 section 14.4 - 
	
		Authorization		=	"Authorization" ":" credentials
		credentials			=	auth-scheme #auth-param
							|	"Digest" digest-response
							|	"Basic" basic-credentials

		basic-credentials	=	base64-user-pass
		base64-user-pass	=	<base64 [4] encoding of user-pass, except not limited to 76 char/line>
		user-pass			=	userid ":" password
		userid				=	*<TEXT excluding ":">
		password			=	*TEXT
		
		digest-response		=	1#( username | realm | nonce | digest-uri |	response |
								[ algorithm ] | [ cnonce ] |
								[ opaque ] | [ message-qop ] |
								[ nonce-count ] | [ auth-param ] )

		username			=	"username" "=" username-value
		username-value		=	quoted-string
		digest-uri			=	"uri" "=" digest-uri-value
		digest-uri-value	=	request-uri ; As specified by HTTP/1.1
		message-qop			=	"qop" "=" qop-value
		cnonce				=	"cnonce" "=" cnonce-value
		cnonce-value		=	nonce-value
		nonce-count			=	"nc" "=" nc-value
		nc-value			=	8LHEX
		response			=	"response" "=" request-digest
		request-digest		=	<"> 32LHEX <">
		LHEX				=	"0" | "1" | "2" | "3" |
								"4" | "5" | "6" | "7" |
								"8" | "9" | "a" | "b" |
								"c" | "d" | "e" | "f"
	
	Encoding here is interpreted very simply. Parts are encoded with no 
	punctuation after them and parameters are comma separated with the value in
	quotes. This means that for basic authentication, part 1 must be 'Basic' and
	part 2 is the credentials. For digest, part1 is 'Digest', and the 
	digest-response is stored in parameters.
	@internalComponent
	@param		aHeader	The authorization header field to encode.
	@leave		RHeaderField::BeginRawDataL
	@leave		RHeaderField::PartsL
	@leave		RHeaderField::WriteRawDataL
	@leave		KErrHttpEncodeAuthorization	There were no parts, or the part
											value type or the parameter value 
											type was not a string or a folded 
											string.
*/
	{
	__START_PERFORMANCE_LOGGER();
	// Check part 1
	aHeader.BeginRawDataL();
	THeaderFieldPartIter iter = aHeader.PartsL();
	for( iter.First(); !iter.AtEnd(); )
		{
		const CHeaderFieldPart* part = iter();
		if( part == NULL )
			{
			// No parts!!
			User::Leave(KErrHttpEncodeAuthorization);
			}
		THTTPHdrVal ptVal = part->Value();
		switch( ptVal.Type() )
			{
		case THTTPHdrVal::KStrFVal:
			{
			aHeader.WriteRawDataL(ptVal.StrF().DesC());
			} break;
		case THTTPHdrVal::KStrVal:
			{
			aHeader.WriteRawDataL(ptVal.Str().DesC());
			} break;			
		default:
			User::Leave(KErrHttpEncodeAuthorization);
			break;
			}

		// Now output the params
		THeaderFieldParamIter paramIter = part->Parameters();
		for( paramIter.First(); !paramIter.AtEnd(); )
			{
			const  TInt param = paramIter()->Name().Index(iStringTable);

			const TBool quoted = (param != HTTP::ENc && param != HTTP::EAlgorithm  && param != HTTP::EUri  && param != HTTP::EStale);
			aHeader.WriteRawDataL(' ');
			aHeader.WriteRawDataL(paramIter()->Name().DesC());
			aHeader.WriteRawDataL('=');
			
			if( quoted ) 
                {
                aHeader.WriteRawDataL('"');
                }

			THTTPHdrVal paramVal = paramIter()->Value();
			switch (paramVal.Type())
				{
			case THTTPHdrVal::KStrFVal:
//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-mw2,代码行数:101,代码来源:chttpclientheaderwriter.cpp

示例4: DumpRespHeadersL

void CHttpEventHandler::DumpRespHeadersL(RHTTPTransaction& aTrans)
	{
	RHTTPResponse resp = aTrans.Response();
	RStringPool strP = aTrans.Session().StringPool();
	RHTTPHeaders hdr = resp.GetHeaderCollection();
	THTTPHdrFieldIter it = hdr.Fields();

	TBuf<CHttpConstants::KMaxHeaderNameLen>  fieldName16;
	TBuf<CHttpConstants::KMaxHeaderValueLen> fieldVal16;

	while (it.AtEnd() == EFalse)
		{
		RStringTokenF fieldName = it();
		RStringF fieldNameStr = strP.StringF(fieldName);
		THTTPHdrVal fieldVal;
		if (hdr.GetField(fieldNameStr,0,fieldVal) == KErrNone)
			{
			const TDesC8& fieldNameDesC = fieldNameStr.DesC();
			fieldName16.Copy(fieldNameDesC.Left(CHttpConstants::KMaxHeaderNameLen));
			switch (fieldVal.Type())
				{
			case THTTPHdrVal::KTIntVal:
				iTest->Console()->Printf(_L("%S: %d\n"), &fieldName16, fieldVal.Int());
				break;
			case THTTPHdrVal::KStrFVal:
				{
				RStringF fieldValStr = strP.StringF(fieldVal.StrF());
				const TDesC8& fieldValDesC = fieldValStr.DesC();
				fieldVal16.Copy(fieldValDesC.Left(CHttpConstants::KMaxHeaderValueLen));
				iTest->Console()->Printf(_L("%S: %S\n"), &fieldName16, &fieldVal16);
				}
				break;
			case THTTPHdrVal::KStrVal:
				{
				RString fieldValStr = strP.String(fieldVal.Str());
				const TDesC8& fieldValDesC = fieldValStr.DesC();
				fieldVal16.Copy(fieldValDesC.Left(CHttpConstants::KMaxHeaderValueLen));
				iTest->Console()->Printf(_L("%S: %S\n"), &fieldName16, &fieldVal16);
				}
				break;
			case THTTPHdrVal::KDateVal:
				{
				TDateTime date = fieldVal.DateTime();
				TBuf<40> dateTimeString;
				TTime t(date);
				t.FormatL(dateTimeString,CHttpConstants::KDateFormat);

				iTest->Console()->Printf(_L("%S: %S\n"), &fieldName16, &dateTimeString);
				} 
				break;
			default:
				iTest->Console()->Printf(_L("%S: <unrecognised value type>\n"), &fieldName16);
				break;
				}

			// Display realm for WWW-Authenticate header
			RStringF wwwAuth = strP.StringF(HTTP::EWWWAuthenticate,RHTTPSession::GetTable());
			if (fieldNameStr == wwwAuth)
				{
				// check the auth scheme is 'basic'
				RStringF basic = strP.StringF(HTTP::EBasic,RHTTPSession::GetTable());
				RStringF realm = strP.StringF(HTTP::ERealm,RHTTPSession::GetTable());
				THTTPHdrVal realmVal;
				if ((fieldVal.StrF() == basic) && 
					(!hdr.GetParam(wwwAuth, realm, realmVal)))
					{
					RStringF realmValStr = strP.StringF(realmVal.StrF());
					fieldVal16.Copy(realmValStr.DesC());
					iTest->Console()->Printf(_L("Realm is: %S\n"), &fieldVal16);
					}
				}
			}
		++it;
		}
	}
开发者ID:DoktahWorm,项目名称:rhodes,代码行数:75,代码来源:HttpEventHandler.cpp


注:本文中的THTTPHdrVal::Str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。