void CHttpClientFilter::EnsureNoEndToEndHeadersInConnectionHeaderL(RHTTPTransaction aTransaction)
	{
	RHTTPHeaders headers = aTransaction.Request().GetHeaderCollection();
	RStringF connection = iStringPool.StringF(HTTP::EConnection,iStringTable);
	const TInt numConnectionHeaderParts = headers.FieldPartsL(connection);

	for( TInt ii = numConnectionHeaderParts - 1; ii >= 0; --ii ) 
		{
		// Examine connection-tokens from back to front so index is always valid. 
		// Check for an end to end header and remove it as a connection header
		// must not contain end to end headers.
		THTTPHdrVal value;
		TInt ret = headers.GetField(connection, ii, value);

		if( ( ret != KErrNotFound ) && ( value.Type() == THTTPHdrVal::KStrFVal ) )
			{
			RStringF valueStrF = value.StrF();
			if( valueStrF.Index(iStringTable) != HTTP::EClose  && 
				!IsHopByHopHeader(valueStrF) )
				{
				// The connection-token is not 'close' nor is it a end-to-end
				// header field name - remove it.
				User::LeaveIfError(headers.RemoveFieldPart(connection, ii)); 
				}
			}
		else
			{
			// The connection-token is not a hop-by-hop header field name -
			// remove it.
			User::LeaveIfError(headers.RemoveFieldPart(connection, ii));
			}			
		}
	}
// -----------------------------------------------------------------------------
// CSIPRequestElements::SetMethodL
// -----------------------------------------------------------------------------
//
EXPORT_C void CSIPRequestElements::SetMethodL(RStringF aMethod)
    {
	__ASSERT_ALWAYS (aMethod.DesC().Length() > 0, User::Leave(KErrArgument));

	iMethod.Close();
	iMethod = aMethod.Copy();
    }
void CHttpController::AddPersistentHeaderL( TInt aHeaderId, const TDesC8& aValue )
	{
	RStringF string = iSession.StringPool().StringF( aHeaderId, RHTTPSession::GetTable() );
	CleanupClosePushL( string );
	iPersistentHeaders->AddL( string.DesC(), aValue );
	CleanupStack::PopAndDestroy( &string );
	}
// ----------------------------------------------------------------------------
// CSdpMediaField::DoInternalizeL
// ----------------------------------------------------------------------------
//
void CSdpMediaField::DoInternalizeL(RReadStream& aStream)
{
    RStringF media = iPool.OpenFStringL(GetTokenFromStreamL(aStream));
    CleanupClosePushL(media);
    SetMediaL(media);
    CleanupStack::Pop();//media
    media.Close();
    TUint32 port = aStream.ReadUint32L();
    //SetPortL(aStream.ReadUint32L());
    TUint flag = aStream.ReadUint8L();
    if(flag)
    {
        SetPortCountL(aStream.ReadUint32L());
    }
    RStringF protocol =iPool.OpenFStringL(GetTokenFromStreamL(aStream));
    CleanupClosePushL(protocol);
    SetProtocolL(protocol);
    CleanupStack::Pop();//protocol
    protocol.Close();
    SetPortL(port);
    SetFormatListL(GetTokenFromStreamL(aStream));
    SetInfoL(GetTokenFromStreamL(aStream));
    SdpCodecTemplate<CSdpConnectionField>::InternalizeArrayL(*iConnectionFields,
            aStream);
    SdpCodecTemplate<CSdpBandwidthField>::InternalizeArrayL(*iBandwidthFields,
            aStream);
    if(aStream.ReadUint8L())
    {
        SetKey(CSdpKeyField::InternalizeL(aStream));
    }
    SdpCodecTemplate<CSdpAttributeField>::InternalizeArrayL(*iAttributeFields,
            aStream);
    SdpCodecTemplate<CSdpFmtAttributeField>::InternalizeArrayL(*iFmtAttrFields,
            aStream);
}
// ----------------------------------------------------------------------------
// CSdpMediaField::SetMedia
// ----------------------------------------------------------------------------
//
EXPORT_C void CSdpMediaField::SetMediaL(RStringF aMedia)
{
    __ASSERT_ALWAYS(SdpUtil::IsTokenChar(aMedia.DesC()),
                    User::Leave(KErrSdpCodecMediaField));
    iMedia.Close();
    iMedia = aMedia.Copy();
}
/**
Sets the headers.
@internalTechnology
@test
@param		aHeaders 	Headers collection
@param		aHdrField 	Header field to be added
@return		aHdrValue	Header value to be added	
*/
void CTestHttpBaseStep::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue)
	{
	RStringF valStr = iSess.StringPool().OpenFStringL(aHdrValue);
	THTTPHdrVal val(valStr);
	aHeaders.SetFieldL(iSess.StringPool().StringF(aHdrField,RHTTPSession::GetTable()), val);
	valStr.Close();
	}
// -----------------------------------------------------------------------------
// CSdpConnectionField::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSdpConnectionField::ConstructL(
    const TDesC8& aText )
	{
    // aText should be in format
    // c=<network type> <address type> <connection address>
    iPool = SdpCodecStringPool::StringPoolL();

    RArray<TPtrC8> array =
        SdpUtil::GetElementsFromLineL( aText, KErrSdpCodecConnectionField );
    CleanupClosePushL( array );

    if ( array.Count() != KTokenCount )
        {
        User::Leave( KErrSdpCodecConnectionField );
        }

    RStringF origHeader =  iPool.StringF( SdpCodecStringConstants::EConnection,
                                          SdpCodecStringConstants::Table );
    if ( origHeader.DesC().CompareF( array[KHeaderIndex] ) != 0 )
        {
        // Header didn't match
        User::Leave( KErrSdpCodecConnectionField );
        }

    // <network type>
    CopyNetTypeL( array[KNetworkTypeIndex] );

    // <address type>
    CopyAddressTypeL( array[KAddressTypeIndex] );

    // <address>
    CopyAddressL( array[KAddressIndex], iPool );

    CleanupStack::PopAndDestroy();  // array
	}
void CUPnPHeaderReader::DecodeHeaderL(RHeaderField& aHeader)
	{
	RStringF fieldStr = iStringPool.StringF(aHeader.Name());
	switch( fieldStr.Index(TUPnPTable::Table()) )
		{
		case UPnP::ENTS:
		case UPnP::ENT:
		case UPnP::EST:
		case UPnP::EUSN:
		case UPnP::ESoapAction:
		case UPnP::ESID:
			DecodeGenericUpnpHeadersL(aHeader);	
			break;
		case UPnP::ETimeout:
			DecodeTimeoutHeaderL(aHeader);
			break;
		case UPnP::EExt:
			DecodeExtL(aHeader);
			break;
		case UPnP::EMX:
		case UPnP::ESEQ:
			DecodeGenericNumberL(aHeader);
			break;
		case UPnP::EMAN:
			DecodeManL(aHeader);
			break;
		case UPnP::ECallback:
			DecodeCallbackL(aHeader);
			break;
		default:
			User::Leave(KErrNotSupported);
		}	
	}
void CUPnPHeaderReader::DecodeTimeoutHeaderL(RHeaderField& aHeader) const
	{
	TPtrC8 buffer;
	aHeader.RawDataL(buffer);
	
	// Search for '\n' separator. In the case when a duplicate header has been received,
	// only use the fist instance of the valid data.
	TInt newLinePos = buffer.Locate('\n');
	if (newLinePos != KErrNotFound)
		{
		buffer.Set(buffer.Left(newLinePos));
		}
		
	RStringF infinite = iStringPool.StringF(UPnP::EInfinite, TUPnPTable::Table());
	if(buffer.Compare(infinite.DesC()) == 0)
		{
		SetNewIntegerPartL(aHeader, 0, -(KMaxTInt));	
		}
	
	else
		{
		TPtrC8 token;
		InetProtTextUtils::ExtractNextTokenFromList(buffer, token, KSemiSpaceSep);
		TInt consumed = token.Locate('-');
		token.Set(token.Mid(consumed+1));
		TInt intVal;
		InetProtTextUtils::ConvertDescriptorToInt(token, intVal);
		SetNewIntegerPartL(aHeader, 0, intVal); // part 0, i.e. the first (and only) part
		}
	}
Exemple #10
0
void CHttpClient::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue)
{
    RStringF valStr = iConnectionManager->GetHTTPSession().StringPool().OpenFStringL(aHdrValue);
    THTTPHdrVal val(valStr);
    aHeaders.SetFieldL(iConnectionManager->GetHTTPSession().StringPool().StringF(aHdrField,RHTTPSession::GetTable()), val);
    valStr.Close();
}
Exemple #11
0
// ---------------------------------------------------------------------------
// SdpUtil::SetDefaultNetTypeAndAddrType
// Sets network type and address type to their "default" values
// ---------------------------------------------------------------------------
//
void SdpUtil::SetDefaultNetTypeAndAddrType( 
    RStringPool aPool, 
    const TInetAddr& aAddress,
    RStringF& aNetType, 
    RStringF& aAddressType )
    {
     // Sets network type to IN
    aNetType.Close();
    aNetType = aPool.StringF( SdpCodecStringConstants::ENetType,
                              SdpCodecStringConstants::Table ).Copy();
    // Address type       
    aAddressType.Close();

    TBuf16 <KMaxAddressLength> output;
    aAddress.Output(output);


    //addresstype for IPv4    
	if((aAddress.Address() &&  !aAddress.IsV4Mapped()) ||
       (!aAddress.Address() && aAddress.IsWildAddr() && 
        output.Match(KWildAddr) == 0))
        {
        aAddressType = aPool.StringF( SdpCodecStringConstants::EAddressTypeIP4,
                                      SdpCodecStringConstants::Table ).Copy();
        }
    else
        {
		//addresstype for IPv4-Mapped IPv6 && IPv6
        aAddressType = aPool.StringF( SdpCodecStringConstants::EAddressType,
                                      SdpCodecStringConstants::Table ).Copy();
        }
    }
/**
@SYMTestCaseID          SYSLIB-BAFL-CT-0489
@SYMTestCaseDesc        Tests for defect number DEF043985
@SYMTestPriority        High
@SYMTestActions         Check for Panic
@SYMTestExpectedResults Tests must not fail
@SYMREQ                 REQ0000
*/
TInt RStringPoolPanicTest::DEF043985_StringFTest_ThreadL(TAny*)
	{
	__UHEAP_MARK;

	RStringPool stringPool;
	stringPool.OpenL();

	// Create a table and make it so it passes some internal tests
	// for validity as we are testing a particular internal test
	TStringTable testTable;
	testTable.iCaseSensitive = EFalse;
	testTable.iCount = 1;

	// Test for Panic
	RStringF testString = stringPool.StringF(0, testTable);
	
	// Test should never get this far as it Panics

	testString.Close();
	stringPool.Close();

	__UHEAP_MARKEND;

	return KErrNone;		
	}
/** Adds a filter to the session's filter queue.  

	Note: This function only adds filters; it doesn't replace or
	otherwise affect any pre-existing filters.

	@pre The session is open and no transactions have been created yet.
	@param aFilter The filter to add
	@param aEvent The event that triggers this filter (or all)
	@param aHeader The header whose presence triggers this filter
	(or KNullDesC for any) 
	@param aStatusCode The status code that triggers this filter
	(or -1 for all) 
	@param aPosition The position of the filter in the
	queue. Standard values are documented in the documentation for
	the supplied filters, and are based on the standard defines in
	MHTTPFilter::TPositions
	@param aName  the name of the Filter to add
	@see See MHTTPFilter::TPositions 
*/
EXPORT_C void RHTTPFilterCollection::AddFilterL(MHTTPFilter& aFilter,
												THTTPEvent aEvent,
												RStringF aHeader,
												TInt aStatusCode, 
												TInt aPosition,
												RStringF aName)
	{
	// You're only allowed to add filters if there aren't any transactions.
	__ASSERT_DEBUG(iImplementation->CanAddFilters(),HTTPPanic::Panic(HTTPPanic::EAddingFilterWithOutstandingTransactions));
	// You're only allowed to add filters between the protocol handler
	// and the client
	__ASSERT_DEBUG(aPosition >= MHTTPFilter::EProtocolHandler &&
				   aPosition <= MHTTPFilter::EClient,
				   HTTPPanic::Panic(HTTPPanic::EFilterInvalidPosition));

	// Copy the strings for use by this filter.
	aHeader.Copy();
	aName.Copy();
	
	//In case Leave happens when inserting filter in array that has reference of above variables,
	//their reference count needs to be decremented. So push onto CleanupStack.
	CleanupClosePushL(aHeader);
	CleanupClosePushL(aName);	
	
	THTTPFilterRegistration r(aFilter, aEvent, aHeader, aStatusCode, 
							  aPosition, aName, 
							  iImplementation->NextFilterHandle());
	User::LeaveIfError(iImplementation->FilterQueue().InsertInSignedKeyOrderAllowRepeats(r));
	
	CleanupStack::Pop(2); // aName, aHeader
	
	THTTPFilterHandle h;
	h.iValue = r.iHandle;
	aFilter.MHFLoad(Session(), h);
	}
// ------------------------------------------------------------------------------------------------
// CNSmlDataModBase::SetUsedMimeType
// Sets mime type that is used for sending and receiving. 
// This method can be called separately before every item.
// ------------------------------------------------------------------------------------------------
EXPORT_C TInt CNSmlDataModBase::SetUsedMimeType( const RStringF aMimeType, const RStringF aMimeVersion )
	{
	_DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL(): begin");
	iUsedRemoteMimeType = -1;
	if ( !iRemoteStoreFormat )
		{
		_DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL() - Not Found: end");
		return KErrNotFound;
		}
	else
		{
		for ( TInt i = 0; i < iRemoteStoreFormat->MimeFormatCount(); i++ )
			{
			if ( iRemoteStoreFormat->MimeFormat( i ).MimeType().DesC().Compare( aMimeType.DesC() ) == 0 )
				{
				if ( iRemoteStoreFormat->MimeFormat( i ).MimeVersion().DesC().Compare( aMimeVersion.DesC() ) == 0 )
					{
					iUsedRemoteMimeType = i;
					iMimeType = iRemoteStoreFormat->MimeFormat( i ).MimeType();
					iMimeVersion = iRemoteStoreFormat->MimeFormat( i ).MimeVersion();
					_DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL() - Found: end");
					return KErrNone;
					}
				}
			}
		}
	_DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL() - Not Found: end");
	return KErrNotFound;
	}
void CHttpClientHeaderReader::DecodeHeaderL(RHeaderField& aHeader)
	{
	RStringF fieldStr = iStrPool.StringF(aHeader.Name()); // this doesn't have to be closed
	switch(fieldStr.Index(iStringTable))
		{
		case HTTP::EWWWAuthenticate:
			{
			DecodeWWWAuthenticateL(aHeader);
			} break;
		case HTTP::ESetCookie:
		case HTTP::ESetCookie2:
			DecodeSetCookieL(aHeader);
			break;
		case HTTP::EAge:
			DecodeGenericNumberL(aHeader);
			break;
		case HTTP::EVary:
		case HTTP::EContentLanguage:
		case HTTP::EUpgrade:
			DecodeGenericL(aHeader, KCommaNewline);
			break;
		case HTTP::ELastModified:
			DecodeDateL(aHeader);
			break;
		default:
			User::Leave(KErrNotSupported);
		}
	}
TBool CHttpHdrTest::CompareStringL(RStringF aStr, const TDesC8& aDes)
	{
	RStringF desStr = iStrP.OpenFStringL(aDes);
	TBool retVal = (desStr == aStr);
	desStr.Close();
	return retVal;
	}
// -----------------------------------------------------------------------------
// RSIPSecChallengeResolver::SelectQopL
// Security-Server can have one qop value. If it has, use it. Challenge can have
// a list of qop values ("auth,auth-int"). Qop is not case-sensitive.
// -----------------------------------------------------------------------------
//
CSIPSecRequestData::TQop
RSIPSecChallengeResolver::SelectQopL( CSIPAuthenticateHeaderBase& aHeader,
									  RStringF aQopInSecurityServer ) const
	{
	if ( aQopInSecurityServer != SIPStrings::StringF( SipStrConsts::EEmpty ) )
		{
		if ( aQopInSecurityServer.DesC().CompareF( KSIPSecAuthInt ) == 0 )
			{
			return CSIPSecRequestData::EAuthInt;
			}
		if ( aQopInSecurityServer.DesC().CompareF( KSIPSecAuth ) == 0 )
			{
			return CSIPSecRequestData::EAuth;
			}
		}


	if ( !aHeader.HasParam( SIPStrings::StringF( SipStrConsts::EQop ) ) )
		{
		// No qop => accept, but "auth" is used later on.
		return CSIPSecRequestData::EDoesNotExist;
		}

	// If many values ("auth,auth-int"), use strongest ("auth-int")
	if ( aHeader.HasQopValueL( KSIPSecAuthInt ) )
		{
		return CSIPSecRequestData::EAuthInt;
		}
	if ( aHeader.HasQopValueL( KSIPSecAuth ) )
		{
		return CSIPSecRequestData::EAuth;
		}

	return CSIPSecRequestData::EUnknown;
	}
void UPPayHttpConnection::AddHeaderL(RHTTPHeaders aHeaders, TInt aHeaderField, const TDesC8& aHeaderValue)
{
	RStringPool stringPool = iSession.StringPool();
	RStringF valStr = stringPool.OpenFStringL(aHeaderValue);
	THTTPHdrVal headerVal(valStr);
	aHeaders.SetFieldL(stringPool.StringF(aHeaderField, RHTTPSession::GetTable()), headerVal);
	valStr.Close();
}
TBool CHttpHdrTest::CompareStringTokenL(RStringTokenF aStrTk, const TDesC8& aDes)
	{
	RStringF desStr = iStrP.OpenFStringL(aDes);
	RStringTokenF desStrTk = desStr;
	TBool retVal = (desStrTk == aStrTk);
	desStr.Close();
	return retVal;
	}
void CHttpHdrTest::TestHdrValL()
	{
	// Open strings needed in this test
	RStringF accStr = iStrP.OpenFStringL(_L8("Accept"));

	THTTPHdrVal v1(accStr);
	TestL(CompareStringL(v1.StrF(), _L8("Accept")));
	TestL(v1.Type() == THTTPHdrVal::KStrFVal);

	THTTPHdrVal v2(3);
	TestL(v2.Int() == 3);
	TestL(v2.Type() == THTTPHdrVal::KTIntVal);


	TDateTime date(2001, EJanuary, 1, 12, 00, 00, 00);
	THTTPHdrVal v3(date);
	TestL(CompareDate(v3.DateTime(), date));
	TestL(v3.Type() == THTTPHdrVal::KDateVal);


	THTTPHdrVal v4 = accStr;
	TestL(v4.Type() == THTTPHdrVal::KStrFVal);


	THTTPHdrVal v5 = 3;
	TestL(v5.Type() == THTTPHdrVal::KTIntVal);

	
	THTTPHdrVal v6 = date;
	TestL(v6.Type() == THTTPHdrVal::KDateVal);

	RStringF str2 = v1;
	TestL(str2 == v1.StrF());

	
	TInt ii = v2;
	TestL(ii == v2.Int());


	TDateTime dt = v3;
	TestL(CompareDate(dt, date));


	v3 = str2;
	TestL(v3.Type() == THTTPHdrVal::KStrFVal);
	TestL(str2 == v3);

	v3 = 67;
	TestL(v3.Type() == THTTPHdrVal::KTIntVal);
	TestL(67 == v3);

	v3 = date;
	TestL(v3.Type() == THTTPHdrVal::KDateVal);
	TestL(CompareDate(date, v3.DateTime()));

	// Close strings used in this test
	accStr.Close();
	}
HBufC8* CHttpController::HeaderNameLC( TInt aId )
	{
	RStringF string = iSession.StringPool().StringF( aId, RHTTPSession::GetTable() );
	CleanupClosePushL( string );
	HBufC8* buffer = string.DesC().AllocL();
	CleanupStack::PopAndDestroy( &string );
	CleanupDeletePushL( buffer );
	return buffer;
	}
// ---------------------------------------------------------------------------
// CSdpCodecParseUtil::ParseMediaLevelL
// ---------------------------------------------------------------------------
//
RPointerArray<CSdpMediaField>*
CSdpCodecParseUtil::ParseMediaLevelL()
{
    RStringF headername = iPool.StringF( SdpCodecStringConstants::EMedia,
                                         SdpCodecStringConstants::Table );
    TInt linestartPosition = 0;
    TInt lineEndPosition = 0;
    CSdpMediaField* mediafield = NULL;
    TBool endloop = EFalse;
    while(iData.Length() > 0 && !endloop)
    {
        linestartPosition = iData.FindF(headername.DesC());
        if(linestartPosition != KErrNotFound)
        {
            TPtrC8 firstline(iData.Mid(linestartPosition));
            TPtrC8 templine(iData.Mid(linestartPosition + 1));
            HBufC8* searchString =
                HBufC8::NewLC(KCRLFStr().Length() +
                              headername.DesC().Length());
            TPtr8 strPtr(searchString->Des());
            strPtr.Append(KCRLFStr);
            strPtr.Append(headername.DesC());
            lineEndPosition = templine.FindF(strPtr);
            CleanupStack::PopAndDestroy(searchString);
            if(lineEndPosition == KErrNotFound)
            {
                mediafield =
                    CSdpMediaField::DecodeLC(iData.Mid(linestartPosition));
                User::LeaveIfError(iMediaFields->Append(mediafield));
                CleanupStack::Pop();//mediafield
                mediafield = 0;
                iElementArray.Reset();
                iLineArray.Reset();
                endloop = ETrue;
            }
            else
            {
                mediafield =
                    CSdpMediaField::DecodeLC(firstline.Left(
                                                 lineEndPosition+1+KCRLFStr().Length()));
                User::LeaveIfError(iMediaFields->Append(mediafield));
                CleanupStack::Pop();//mediafield
                mediafield = 0;
                iData.Set(firstline.Mid(lineEndPosition+1));
            }
        }
        else
        {
            endloop = ETrue;
        }
    }
    RPointerArray<CSdpMediaField>* array = iMediaFields;
    iMediaFields = 0;
    return array;
}
// ----------------------------------------------------------------------------
// CSdpMediaField::EncodeL
// ----------------------------------------------------------------------------
//
EXPORT_C void
CSdpMediaField::EncodeL(RWriteStream& aStream, TBool aRecurse) const
{
    RStringF headername = iPool.StringF( SdpCodecStringConstants::EMedia,
                                         SdpCodecStringConstants::Table );
    aStream.WriteL(headername.DesC());
    aStream.WriteL(iMedia.DesC());
    aStream.WriteL(KSPStr);
    TBuf8<80> text;
    text.Format(_L8("%u"), iPort);
    aStream.WriteL(text);
    if(iPortCount>0)
    {
        aStream.WriteL(_L8("/"));
        text.Format(_L8("%u"), iPortCount);
        aStream.WriteL(text);
    }
    aStream.WriteL(KSPStr);
    aStream.WriteL(iProtocol.DesC());
    aStream.WriteL(KSPStr);
    aStream.WriteL(*iFormatList);
    aStream.WriteL(KCRLFStr);
    if(aRecurse)
    {
        SdpUtil::EncodeBufferL(*iInfo,
                               SdpCodecStringConstants::EInfo, aStream);
        SdpCodecTemplate<CSdpConnectionField>::EncodeArrayL(*iConnectionFields,
                aStream);
        SdpCodecTemplate<CSdpBandwidthField>::EncodeArrayL(*iBandwidthFields,
                aStream);
        SdpCodecTemplate<CSdpKeyField>::EncodeL(Key(), aStream);

        for (TInt i = 0; i < iAttributeFields->Count(); i++)
        {
            if (!(((*iAttributeFields)[i])->IsFmtAttribute()))
            {
                ((*iAttributeFields)[i])->EncodeL(aStream);
            }
        }

        for (TInt i = 0; i < iFmtAttrFields->Count(); i++)
        {
            ((*iFmtAttrFields)[i])->EncodeL(aStream);

            for (TInt j=0; j<iAttributeFields->Count(); j++)
            {
                if ((((*iAttributeFields)[j])->IsFmtAttribute()) &&
                        ((*iAttributeFields)[j])->BelongsTo(*(*iFmtAttrFields)[i]))
                {
                    ((*iAttributeFields)[j])->EncodeL(aStream);
                }
            }
        }
    }
}
void CHttpHdrTest::TestLookupPartL()
	{
	// Open strings needed in this test
	RStringF accStr = iStrP.StringF(HTTP::EAccept,RHTTPSession::GetTable());
	RStringF textHtmlStr = iStrP.StringF(HTTP::ETextHtml,RHTTPSession::GetTable());
	RStringF textPlainStr = iStrP.StringF(HTTP::ETextPlain,RHTTPSession::GetTable());
	RStringF anyAnyStr = iStrP.StringF(HTTP::EAnyAny,RHTTPSession::GetTable());
	RStringF qStr = iStrP.StringF(HTTP::EQ,RHTTPSession::GetTable());

	//
	//	  Accept: text/html; q=0.8, text/plain; q=0.2, */*
	//
	CHeaderField* accept = CHeaderField::NewL(accStr, *iHdrColl);
	CleanupStack::PushL(accept);
	//
	CHeaderFieldPart* htmlPt = CHeaderFieldPart::NewL(THTTPHdrVal(textHtmlStr));
	CleanupStack::PushL(htmlPt);
	THTTPHdrVal::TQConv q(0.8);
	CHeaderFieldParam* headerParam = CHeaderFieldParam::NewL(qStr, THTTPHdrVal(q));
	CleanupStack::PushL(headerParam);
	htmlPt->AddParamL(headerParam);
	CleanupStack::Pop(headerParam);
	accept->AddPartL(htmlPt);
	CleanupStack::Pop(htmlPt); // now owned by the header
	//

	CHeaderFieldPart* plainPt = CHeaderFieldPart::NewL(THTTPHdrVal(textPlainStr));
	CleanupStack::PushL(plainPt);
	THTTPHdrVal::TQConv q2(0.2);
	headerParam = CHeaderFieldParam::NewL(qStr, THTTPHdrVal(q2));
	CleanupStack::PushL(headerParam);
	plainPt->AddParamL(headerParam);
	CleanupStack::Pop(headerParam);
	accept->AddPartL(plainPt);
	CleanupStack::Pop(plainPt); // now owned by the header
	//
	CHeaderFieldPart* headerPart = CHeaderFieldPart::NewL(THTTPHdrVal(anyAnyStr));
	CleanupStack::PushL(headerPart);
	accept->AddPartL(headerPart);
	CleanupStack::Pop(headerPart);

	// now lookup the parts by index and check they are correct
	CHeaderFieldPart* pt = accept->PartL(0);
	TestL(pt == htmlPt);
	pt = accept->PartL(1);
	TestL(pt == plainPt);
	pt = accept->PartL(2);
	THTTPHdrVal val = pt->Value();
	TestL(val.Type() == THTTPHdrVal::KStrFVal);
	TestL(val.StrF().Index(RHTTPSession::GetTable()) == anyAnyStr.Index(RHTTPSession::GetTable()));	

	// Now just destroy that lot
	CleanupStack::PopAndDestroy(accept);
	}
// -----------------------------------------------------------------------------
// TSIPHeaderLookupEntry::TSIPHeaderLookupEntry 
// -----------------------------------------------------------------------------
//
TSIPHeaderLookupEntry::TSIPHeaderLookupEntry 
(RStringF aName,
 RStringF aCompactName,
 RPointerArray<CSIPHeaderBase>(*aDecode)(const TDesC8&),
 CSIPHeaderBase*(*aInternalize)(RReadStream&))

 : iName(aName.Copy()),
   iCompactName(aCompactName.Copy()),
   iDecodeFunction (aDecode),
   iInternalizeFunction(aInternalize)
	{
	}
TBool CTestTransaction::AddAcceptHeaderL(RHTTPHeaders &aHeaders, RStringPool &aStrPool)
	{
	//	some tests may require specific 'Accept' parameters
	TBuf8<KMaxAcceptLengthSize> acceptBuf;
	acceptBuf.Copy(Machine()->GetDefine(KITHAccept));
	RStringF accept = (acceptBuf.Length() == 0) ?
		aStrPool.StringF(HTTP::EAnyAny, RHTTPSession::GetTable()) : aStrPool.OpenFStringL(acceptBuf);
	THTTPHdrVal acceptHdr(accept);
	aHeaders.SetFieldL(aStrPool.StringF(HTTP::EAccept, RHTTPSession::GetTable()), acceptHdr);
	accept.Close();
	return ETrue;
	}
// ----------------------------------------------------------------------------
// CSdpMediaField::SetProtocol
// ----------------------------------------------------------------------------
//
EXPORT_C void CSdpMediaField::SetProtocolL(RStringF aProtocol)
{
    __ASSERT_ALWAYS(SdpUtil::IsTokenCharWithOptionalSlash(aProtocol.DesC()),
                    User::Leave(KErrSdpCodecMediaField));
    if (aProtocol == iPool.StringF( SdpCodecStringConstants::EProtocolUdp,
                                    SdpCodecStringConstants::Table ))
    {
        __ASSERT_ALWAYS((iPort == 0 || (iPort >= 1024 && iPort <= 65535)),
                        User::Leave(KErrSdpCodecMediaField));
    }

    iProtocol.Close();
    iProtocol = aProtocol.Copy();
}
TBool CTestTransaction::SetContentLengthL(RHTTPHeaders &aHeaders, RStringPool &aStrPool)
	{
	TBuf8<KMaxContentLengthSize> contLengthBuf;
	contLengthBuf.Copy(Machine()->GetDefine(KITHContentLength));
	if (contLengthBuf.Length() != 0)
		{
		RStringF contLengthStr = aStrPool.OpenFStringL(contLengthBuf);
		THTTPHdrVal contLength(contLengthStr);
		aHeaders.SetFieldL(aStrPool.StringF(HTTP::EContentLength, RHTTPSession::GetTable()), contLength);
		contLengthStr.Close();
		}

	return ETrue;
	}
TBool CTestTransaction::AcceptEncodingL(RHTTPHeaders &aHeaders, RStringPool &aStrPool)
	{
	TBuf8<KMaxAcceptEncodingSize> acceptEncodingBuf;
	acceptEncodingBuf.Copy(Machine()->GetDefine(KITHAcceptEncoding));
	if (acceptEncodingBuf.Length() > 0)
		{
		RStringF acceptEncoding = aStrPool.OpenFStringL(acceptEncodingBuf);
		THTTPHdrVal acceptEncodingHdr(acceptEncoding);
		aHeaders.SetFieldL(aStrPool.StringF(HTTP::EAcceptCharset, RHTTPSession::GetTable()), acceptEncodingHdr);
		acceptEncoding.Close();
		}

	return ETrue;
	}
// -----------------------------------------------------------------------------
// CMceSdpCodec::Direction
// -----------------------------------------------------------------------------
//
TInt CMceSdpCodec::Direction( 
    CSdpMediaField& aMedia, 
    RPointerArray<CSdpAttributeField>& aSessionAttributes ) const
    {
    
    TInt direction = KErrNotFound;
    TInt index = 0;
    
    // look for the direction attribute, go through all attribute fields.
    while( direction == KErrNotFound && index < aSessionAttributes.Count() )
        {
        RStringF attribute = aSessionAttributes[index++]->Attribute();
        
        if ( attribute == SDP_STRING( SdpCodecStringConstants::EAttributeSendonly ) ||
             attribute == SDP_STRING( SdpCodecStringConstants::EAttributeRecvonly ) ||
             attribute == SDP_STRING( SdpCodecStringConstants::EAttributeInactive ) ||
             attribute == SDP_STRING( SdpCodecStringConstants::EAttributeSendrecv ) )
            {
            // downlink
            direction = attribute.Index( *iStringTable );
            }
        }
        
    if ( direction == KErrNotFound )
        {
        index = 0;
        
        RPointerArray<CSdpAttributeField>& attrfields = aMedia.AttributeFields();
        // look for the direction attribute, go through all attribute fields. if not
        // found then use the default sendrcv
        while( direction == KErrNotFound && index < attrfields.Count() )
            {
    
            RStringF attribute = attrfields[index++]->Attribute();
            if ( attribute == SDP_STRING( SdpCodecStringConstants::EAttributeSendonly ) ||
                 attribute == SDP_STRING( SdpCodecStringConstants::EAttributeRecvonly ) ||
                 attribute == SDP_STRING( SdpCodecStringConstants::EAttributeInactive ) ||
                 attribute == SDP_STRING( SdpCodecStringConstants::EAttributeSendrecv ) )
                {
                // downlink
                direction = attribute.Index( *iStringTable );
                }
            
            }
        }
         
    return direction;
    
    }