// --------------------------------------------------------------------------- // 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(); } }
void CINC097492_3::CreateTransArrayL() { RStringPool strP = iSession.StringPool(); TUriParser8 up; up.Parse(KHttpUrl1); RHTTPTransaction trans1 = iSession.OpenTransactionL(up, *this, strP.StringF(HTTP::EGET,RHTTPSession::GetTable())); CleanupClosePushL(trans1); iTransArray.Append(trans1); CleanupStack::Pop(&trans1); up.Parse(KHttpUrl2); RHTTPTransaction trans2 = iSession.OpenTransactionL(up, *this, strP.StringF(HTTP::EGET,RHTTPSession::GetTable())); CleanupClosePushL(trans2); iTransArray.Append(trans2); CleanupStack::Pop(&trans2); up.Parse(KHttpUrl3); RHTTPTransaction trans3 = iSession.OpenTransactionL(up, *this, strP.StringF(HTTP::EGET,RHTTPSession::GetTable())); CleanupClosePushL(trans3); iTransArray.Append(trans3); CleanupStack::Pop(&trans3); for(TInt i=0; i<iTransArray.Count(); i++) { iTransArray[i].SubmitL(); iOpenTransCount++; } }
// ------------------------------------------------------------------------------------------------ // CHttpFilterConnHandler::MHFRunL // Process a transaction event. // ------------------------------------------------------------------------------------------------ // void CHttpFilterConnHandler::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent) { TInt state = 0; TInt gprsState = 0; TInt wcdmaState = 0; TApBearerType bearerType; if (aEvent.iStatus == THTTPEvent::ESubmit) { THTTPHdrVal isNewConn; RHTTPConnectionInfo connInfo = iSession->ConnectionInfo(); RStringPool strPool = aTransaction.Session().StringPool(); TBool ret = connInfo.Property (strPool.StringF(HttpFilterCommonStringsExt::EHttpNewConnFlag, HttpFilterCommonStringsExt::GetTable()), isNewConn); if ( LocalHostCheckL(aTransaction) && !( ret && isNewConn.Type() == THTTPHdrVal::KTIntVal ) ) { return; } THTTPHdrVal callback; RHTTPTransactionPropertySet propSet = aTransaction.PropertySet(); RStringF callbackStr = strPool.StringF( HttpFilterCommonStringsExt::EConnectionCallback, HttpFilterCommonStringsExt::GetTable() ); MConnectionCallback* callbackPtr = NULL; // this is a transaction, already forwarded to download manager if( propSet.Property( callbackStr, callback ) ) { callbackPtr = REINTERPRET_CAST( MConnectionCallback*, callback.Int() ); }
void CPipeliningConfigTest::CheckAndSetSessionSettingsL(RHTTPSession aSession) { RStringPool stringPool = aSession.StringPool(); RHTTPConnectionInfo sessionSettings = aSession.ConnectionInfo(); if (iMaxNumberTransactionsToPipeline > 0) { RStringF maxToPipelineSetting = stringPool.StringF(HTTP::EMaxNumTransactionsToPipeline, aSession.GetTable()); THTTPHdrVal value; if (sessionSettings.Property(maxToPipelineSetting, value) == EFalse) { value.SetInt(iMaxNumberTransactionsToPipeline); sessionSettings.SetPropertyL(maxToPipelineSetting,value); } } if (iMaxNumberTransportHandlers > 0) { RStringF maxTransportHandlers = stringPool.StringF(HTTP::EMaxNumTransportHandlers, aSession.GetTable()); THTTPHdrVal value; if (sessionSettings.Property(maxTransportHandlers, value) == EFalse) { value.SetInt(iMaxNumberTransportHandlers); sessionSettings.SetPropertyL(maxTransportHandlers,value); } } }
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; }
// ----------------------------------------------------------------------------- // LocalHostCheckL // If the host is a local host, then remove the proxy property. Returns ETrue // if the transaction request URI was for a localhost. // ----------------------------------------------------------------------------- // TBool LocalHostCheckL(RHTTPTransaction& aTransaction, RStringPool& aStringPool) { _LIT8(KLoopbackIPv4Url, "http://127.0.0.1"); RHTTPRequest request = aTransaction.Request(); TUriC8 uri = request.URI(); TUriParser8 parserLoopBack; parserLoopBack.Parse(KLoopbackIPv4Url()); TInt match = parserLoopBack.Compare(uri, EUriHost); if (KErrNone != match) { _LIT8(KLocalHostUrl, "http://localhost"); // try another compare - compare against the "localhost". TUriParser8 parserLocalHost; parserLocalHost.Parse(KLocalHostUrl()); match = parserLocalHost.Compare(uri, EUriHost); if (KErrNone == match) { _LIT8(KLoopbackIPv4, "127.0.0.1"); // "localhost" resolves to "::1", manually, replace with "127.0.0.1" CUri8* newUri = CUri8::NewLC(uri); newUri->SetComponentL(KLoopbackIPv4(), EUriHost); request.SetURIL(newUri->Uri()); CleanupStack::PopAndDestroy(newUri); } } if (KErrNone == match) { // request is for localhost, explicitly state that this transaction // must not be sent to proxy. RStringF proxyUsageStrF = aStringPool.StringF(HTTP::EProxyUsage, RHTTPSession::GetTable()); RStringF dontUseProxyStrF = aStringPool.StringF(HTTP::EDoNotUseProxy, RHTTPSession::GetTable()); aTransaction.PropertySet().RemoveProperty(proxyUsageStrF); aTransaction.PropertySet().SetPropertyL(proxyUsageStrF, dontUseProxyStrF); //RStringF proxyAddrStrF = aStringPool.StringF(HTTP::EProxyAddress, // RHTTPSession::GetTable()); //aTransaction.PropertySet().RemoveProperty(proxyAddrStrF); return ETrue; } return EFalse; }
// ----------------------------------------------------------------------------- // TSdpTypedTime::DecodeL // Decodes typed time from TDesC // ----------------------------------------------------------------------------- // TSdpTypedTime TSdpTypedTime::DecodeL(const TDesC8& aText) { TLex8 typedTimeLex(aText); TSdpTypedTime typedTime; User::LeaveIfError(typedTimeLex.Val(typedTime.iValue, EDecimal)); if (typedTimeLex.Peek() != 0) { TPtrC8 unitString = typedTimeLex.NextToken(); RStringPool pool = SdpCodecStringPool::StringPoolL(); const TDesC8& timeDays = pool.StringF( SdpCodecStringConstants::ETimeUnitDays, SdpCodecStringConstants::Table).DesC(); const TDesC8& timeHours = pool.StringF( SdpCodecStringConstants::ETimeUnitHours, SdpCodecStringConstants::Table).DesC(); const TDesC8& timeMinutes = pool.StringF( SdpCodecStringConstants::ETimeUnitMinutes, SdpCodecStringConstants::Table).DesC(); const TDesC8& timeSeconds = pool.StringF( SdpCodecStringConstants::ETimeUnitSeconds, SdpCodecStringConstants::Table).DesC(); if (unitString.Compare(timeDays) == 0) { typedTime.iUnit = ETimeUnitDays; } else if (unitString.Compare(timeHours) == 0) { typedTime.iUnit = ETimeUnitHours; } else if (unitString.Compare(timeMinutes) == 0) { typedTime.iUnit = ETimeUnitMinutes; } else if (unitString.Compare(timeSeconds) == 0) { typedTime.iUnit = ETimeUnitSeconds; } else { User::Leave(KErrSdpCodecTypedTime); } } else { typedTime.iUnit = ETimeUnitNone; } return typedTime; }
void CHttpEventHandler::ParseCookieL(RHTTPTransaction& aTrans) { RHTTPResponse response = aTrans.Response(); RHTTPResponse resp = aTrans.Response(); RStringPool pool = aTrans.Session().StringPool(); RHTTPHeaders headers = resp.GetHeaderCollection(); RStringF fieldName = pool.StringF(HTTP::ESetCookie,RHTTPSession::GetTable()); _LIT(KSeparator,";"); _LIT(KPathName,";path="); _LIT(KEqual,"="); THTTPHdrVal val; if (headers.GetField(fieldName, 0, val) != KErrNotFound) { RStringF cookieValueName = pool.StringF(HTTP::ECookieValue,RHTTPSession::GetTable()); RStringF cookieNameName = pool.StringF(HTTP::ECookieName,RHTTPSession::GetTable()); RStringF cookiePathName = pool.StringF(HTTP::EPath,RHTTPSession::GetTable()); if (val.StrF() == pool.StringF(HTTP::ECookie, RHTTPSession::GetTable())) { THTTPHdrVal cookieValue; THTTPHdrVal cookieName; THTTPHdrVal cookiePath; TInt parts = headers.FieldPartsL(fieldName); Mem::Fill((void*)iCookies.Ptr(), 1024, 0); // Get all the cookies. for (TInt i = 0; i < parts; i++) { headers.GetParam(fieldName, cookieValueName, cookieValue, i); headers.GetParam(fieldName, cookieNameName, cookieName, i); headers.GetParam(fieldName, cookiePathName, cookiePath, i); if ( GetHdrVal( cookieName, pool) ) iCookies.Append(KEqual); if ( GetHdrVal( cookieValue, pool) ) { iCookies.Append(KPathName); GetHdrVal( cookiePath, pool); iCookies.Append(KSeparator); } } } } }
void CHttpTestCaseGet12::LogConnectionProperties() { RHTTPConnectionInfo connectionInfo = iSession.ConnectionInfo(); RStringPool stringPool = iSession.StringPool(); THTTPHdrVal value; TBool hasValue = connectionInfo.Property (stringPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), value); if (hasValue) { RConnection* conn = REINTERPRET_CAST(RConnection*, value.Int()); TUint count; //get the no of active connections TInt err = conn->EnumerateConnections(count); if(err==KErrNone) { for (TUint i=1; i<=count; ++i) { TPckgBuf<TConnectionInfo> connInfo; conn->GetConnectionInfo(i, connInfo); iEngine->Utils().LogIt(_L("Connection %d: IapId=%d, NetId=%d\n"),i, connInfo().iIapId, connInfo().iNetId); } } else { iEngine->Utils().LogIt(_L("Unable to enumerate number of connections, Error: %d"), err); } } }
/** @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; }
CHTTPSession::~CHTTPSession() { iSessionClosing = ETrue; while (iTransactions.Count()) iTransactions[iTransactions.Count() - 1]->Close(); iTransactions.Close(); // We need a RHTTPSession to give to the filters, so fake one up RHTTPSession s; s.iImplementation = this; // If there isn't a manager we must have failed to construct // the session so there can't be any filters. So it's safe not // to close them. if (iManager) { RStringPool strP = iManager->StringPool(); for (TInt i = 0; i < iFilterQueue.Count(); i++) { THTTPFilterHandle h; h.iValue = iFilterQueue[i].iHandle; iFilterQueue[i].iFilter->MHFUnload(s, h); strP.StringF(iFilterQueue[i].iHeader).Close(); strP.StringF(iFilterQueue[i].iName).Close(); } iFilterQueue.Close(); } delete iProtocolHandler; delete iConnectionInfo; delete iRequestSessionHeaders; delete iResponseSessionHeaders; delete iFilterConfigIter; // Flush and close the filter arrays iFilterInfoList.ResetAndDestroy(); iEComFilterInfoArray.ResetAndDestroy(); // No longer need the manager... the last session to close causes the manager // (and string pool) to be deleted. if (iManager) iManager->Release(); // force ECOM to release all - final clean-up REComSession::FinalClose(); }
/** This function is called to initiate the tests. It may leave with one of the system-wide error codes. */ void CTextModeTestPostBodyChunks::DoRunL() { // Open the HTTP session iSession.OpenL(); CleanupClosePushL(iSession); RStringPool strP = iSession.StringPool(); // Open a POST transactions, specifying this object as the request body // data supplier TUriParser8 up; HBufC8* newUrl8 = TSrvAddrVal::ReplaceHostNameL(KHttpPostBodyChunksUrl(), iIniSettingsFile); CleanupStack::PushL(newUrl8); TPtr8 newUrlPtr8 = newUrl8->Des(); up.Parse(newUrlPtr8); iTransaction = iSession.OpenTransactionL(up, *this, strP.StringF(HTTP::EPOST,RHTTPSession::GetTable())); RHTTPRequest rq = iTransaction.Request(); rq.SetBody(*this); RHTTPHeaders hdr = rq.GetHeaderCollection(); THTTPHdrVal length(OverallDataSize()); hdr.SetFieldL(strP.StringF(HTTP::EContentLength,RHTTPSession::GetTable()), length); THTTPHdrVal contType(strP.StringF(HTTP::EApplicationXWwwFormUrlEncoded, RHTTPSession::GetTable())); hdr.SetFieldL(strP.StringF(HTTP::EContentType, RHTTPSession::GetTable()), contType); // Create the delayed notifier iReleaseTimer = CDelayedBodyDataNotifier::NewL(iTransaction); CleanupStack::PushL(iReleaseTimer); CActiveScheduler::Add(iReleaseTimer); // Submit the transaction iTransaction.SubmitL(); iFailureError = KErrNone; CActiveScheduler::Start(); // Get the completion code and inform the engine. Anything other than // HTTP/200 status is a failure for this test. iEngine->SetCurrentStatusCode(iTransaction.Response().StatusCode()); iExpectedStatusCode = 200; // Close anything opened CleanupStack::PopAndDestroy(3, &iSession); // and iReleaseTimer, newUrl8; // Check for failure error codes caught in MHFRunL User::LeaveIfError(iFailureError); }
AMInt32 SetSessionConnectionInfo(AMPVoid session) { REINTERPRET( RHTTPSession*, temp, session ); // Set the sessions connection info... RStringPool strPool = temp->StringPool(); RHTTPConnectionInfo connInfo = temp->ConnectionInfo(); REINTERPRET( CNetworkAccessPoint*, NetworkAccessPoint, AMSocketIAPGet() ); // ...to use our socket server and connection connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable() ), THTTPHdrVal (NetworkAccessPoint->GetRSocketServ().Handle()) ); // ...to use our connection connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), THTTPHdrVal (REINTERPRET_CAST(TInt, &(NetworkAccessPoint->GetRConnection()))) ); }
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(); }
// ----------------------------------------------------------------------------- // TSdpTypedTime::EncodeL // Writes attributes in proper format to the stream // ----------------------------------------------------------------------------- // void TSdpTypedTime::EncodeL(RWriteStream& aStream) const { TBuf8<KMaxTInt64Digits> number; number.AppendNum( iValue ); aStream.WriteL( number ); RStringPool pool = SdpCodecStringPool::StringPoolL(); const TDesC8& timeDays = pool.StringF( SdpCodecStringConstants::ETimeUnitDays, SdpCodecStringConstants::Table).DesC(); const TDesC8& timeHours = pool.StringF( SdpCodecStringConstants::ETimeUnitHours, SdpCodecStringConstants::Table).DesC(); const TDesC8& timeMinutes = pool.StringF( SdpCodecStringConstants::ETimeUnitMinutes, SdpCodecStringConstants::Table).DesC(); const TDesC8& timeSeconds = pool.StringF( SdpCodecStringConstants::ETimeUnitSeconds, SdpCodecStringConstants::Table).DesC(); if (iUnit != ETimeUnitNone) { TBuf8<1> unit; if (iUnit == ETimeUnitDays) { unit.Append(timeDays); } else if (iUnit == ETimeUnitHours) { unit.Append(timeHours); } else if (iUnit == ETimeUnitMinutes) { unit.Append(timeMinutes); } else if (iUnit == ETimeUnitSeconds) { unit.Append(timeSeconds); } else {} aStream.WriteL(unit); } }
void UPPayHttpConnection::SetupConnectionL() { // iTimer.After(iStatus,10); // SetActive(); if ( iSocketConnection->OpenConnection()) { #ifdef F_ENCODE_URI if(iUriParser->Uri().Validate()) #else if (iUriParser.Validate()) #endif { RStringPool strPool = iSession.StringPool(); RHTTPConnectionInfo connInfo = iSession.ConnectionInfo(); TInt err = 0; //to use our socket server and connection TRAP(err,connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal(iSocketConnection->iSocketServ.Handle()))); if (!err) { TRAP(err,connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal(REINTERPRET_CAST(TInt, &(iSocketConnection->iConnection))))); if (!err) { TRAP(err,openConnection()); if (!err) { return; } else { //CommonUtils::WriteLogL(_L("openConnection() false err = "), err); } } } } } //CommonUtils::WriteLogL(_L("OpenConnection false "), _L("EHttpError")); if (iObserver) { iObserver->StateChange(EHttpError); } }
RHTTPTransaction CTestCase9::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) { __ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant()); // Change the session properties to be a HTTP/1.0 client if( aIndex == 0 ) { RHTTPConnectionInfo connInfo = aSession.ConnectionInfo(); RStringPool strPool = aSession.StringPool(); THTTPHdrVal http10( strPool.StringF( HTTP::EHttp10, RHTTPSession::GetTable() ) ); connInfo.SetPropertyL( strPool.StringF( HTTP::EHTTPVersion,RHTTPSession::GetTable() ), http10 ); } RStringF method = aSession.StringPool().StringF(HTTP::EGET, RHTTPSession::GetTable()); _LIT8(KTxtUri, "http://127.0.0.1"); TUriParser8 uri; uri.Parse(KTxtUri()); return aSession.OpenTransactionL(uri, aClient, method); }
/** * CSymbianTransportAgent::ConstructL() * Second phase construction. */ void CSymbianTransportAgent::ConstructL(URL& /* aUrl */) { // Open RHTTPSession with default protocol ("HTTP/TCP") // Note that RHTTPSession (and consequently the whole // of HTTP) depends on the active scheduler; a scheduler // must be installed when the session is opened and it // must be running if a transaction is actually to do anything. // Get the connection manager instance FConnection* connection = FConnection::getInstance(); if (!connection) { LOG.error("TransportAgent: no active connection; exiting"); setError(ERR_HTTP, "No active connection"); return; } // Session is owned by FConnection! RSocketServ* socketServ = connection->getSession(); RConnection* rConnection = connection->getConnection(); // reuse active connection, please see: // http://wiki.forum.nokia.com/index.php/CS000825_-_Using_an_already_active_connection TInt err; TRAP( err, iHttpSession.OpenL() ); User::LeaveIfError( err ); // Set the session's connection info... RStringPool strPool = iHttpSession.StringPool(); RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo(); // ...to use the socket server connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable() ), THTTPHdrVal (socketServ->Handle()) ); // ...to use the connection connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable() ), THTTPHdrVal (REINTERPRET_CAST(TInt, rConnection)) ); // Create the nested active scheduler // please see » Symbian OS v9.1 » Symbian OS reference » C++ component // reference » Base E32 » CActiveSchedulerWait iASWait = new (ELeave) CActiveSchedulerWait(); }
void CRefTestAgentManager::PrepareHTTPRequestHeadersL(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const { // Add the accept header for the reference test agent TBuf8 <KMaxDataTypeLength> mimeType; // Add accept header for Content only files mimeType.Copy(KRtaMimeContent()); RStringF valStr = aStringPool.OpenFStringL(mimeType); CleanupClosePushL(valStr); THTTPHdrVal val1(valStr); aRequestHeaders.SetFieldL(aStringPool.StringF(HTTP::EAccept, RHTTPSession::GetTable()), val1); CleanupStack::PopAndDestroy(&valStr); // Add accept header for content and rights files mimeType.Copy(KRtaMimeContentRights()); valStr = aStringPool.OpenFStringL(mimeType); CleanupClosePushL(valStr); THTTPHdrVal val2(valStr); aRequestHeaders.SetFieldL(aStringPool.StringF(HTTP::EAccept, RHTTPSession::GetTable()), val2); CleanupStack::PopAndDestroy(&valStr); }
void CHTTPTest::DoTestsL() { testHarness->StartTestL(_L("Creating the string pool")); RStringPool pool; pool.OpenL(table); testHarness->EndTest(0); testHarness->StartTestL(_L("Creating 'hello'")); STRDCI_L(hello, KHello); RStringF def; testHarness->EndTest(hello == def); testHarness->StartTestL(_L("Creating another 'hello'")); ASTRDCI_L(hello1, KHello1); testHarness->EndTest(!(hello == hello1.iObj)); testHarness->StartTestL(_L("Testing !=")); testHarness->EndTest(hello != hello1.iObj); testHarness->StartTestL(_L("Creating 'goodbye'")); STRDCI_L(goodbye, KGoodbye); testHarness->EndTest(hello == goodbye); testHarness->StartTestL(_L("Creating string tokens")); RStringTokenF h1, h2(hello), g; h1 = hello; testHarness->EndTest(h1 != h2); testHarness->StartTestL(_L("Testing == on string tokens")); testHarness->EndTest(!(h1 == h2)); testHarness->StartTestL(_L("Making a string from a token")); hello1.iObj = pool.StringF(h1); testHarness->EndTest(hello != hello1.iObj); testHarness->StartTestL(_L("Non-equal tokens")); g = goodbye; testHarness->EndTest(hello == goodbye); testHarness->StartTestL(_L("Operator != on non-equal tokens")); testHarness->EndTest(!(hello != goodbye)); testHarness->StartTestL(_L("Copy function")); hello1.iObj = hello.Copy(); testHarness->EndTest(hello != hello1.iObj); testHarness->StartTestL(_L("String extraction (same)")); testHarness->EndTest(static_cast<const TDesC8&>(hello).Compare(hello1.iObj)); testHarness->StartTestL(_L("String extraction (different)")); testHarness->EndTest(!static_cast<const TDesC8&>(hello).Compare(goodbye)); testHarness->StartTestL(_L("String extraction (original)")); testHarness->EndTest(static_cast<const TDesC8&>(hello).Compare(KHello)); testHarness->StartTestL(_L("Closing pool")); hello.Copy(); hello.Close(); hello.Close(); hello1.iObj.Close(); // The copys here have got a bit confused hello1.iObj.Close(); goodbye.Close(); pool.CloseAll(); testHarness->EndTest(0); }
// ----------------------------------------------------------------------------- // CHttpConnHandler::SetConnectionInfoL // ?implementation_description // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CHttpConnHandler::SetConnectionInfoL() { RStringPool strPool = iHttpSession.StringPool(); // Remove first session properties just in case. RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo(); // Clear RConnection and Socket Server instances connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable())); connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable())); // Clear the proxy settings // THTTPHdrVal proxyUsage(strPool.StringF(HTTP::EUseProxy,RHTTPSession::GetTable())); connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyUsage,RHTTPSession::GetTable())); connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable())); // RConnection and Socket Server connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal (iClientApp->Engine()->SocketServ().Handle()) ); TInt connPtr1 = REINTERPRET_CAST(TInt, &iConnection); connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), THTTPHdrVal (connPtr1) ); }
/** Removes all filter registrations of the specified name. @param aFilter Filter name to remove. */ EXPORT_C void RHTTPFilterCollection::RemoveFilter(RStringF aFilter) { // Iterate through the filters and remove all the ones with the // given name. (We do this backwards, so that indexes in the // unsearched part of the array aren't affected by deletions) RArray<THTTPFilterRegistration>& filterQueue = iImplementation->FilterQueue(); TInt i = filterQueue.Count() -1; RStringPool strP = Session().StringPool(); for (;i >= 0; --i) { if (filterQueue[i].iName == aFilter) { THTTPFilterHandle h; h.iValue = filterQueue[i].iHandle; filterQueue[i].iFilter->MHFUnload(Session(), h); strP.StringF(filterQueue[i].iHeader).Close(); strP.StringF(filterQueue[i].iName).Close(); filterQueue.Remove(i); } } }
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; }
void CRecvBufSizeTest1::DoRunL() { TUriParser8 up; up.Parse(KUrl()); iSession.OpenL(); CleanupClosePushL(iSession); RStringPool strP = iSession.StringPool(); RStringF method = strP.StringF(HTTP::EGET, RHTTPSession::GetTable()); RStringF recBufSizeStr = strP.StringF(HTTP::ERecvBufferSize, RHTTPSession::GetTable()); THTTPHdrVal val(KRecvBufSize); iSession.ConnectionInfo().SetPropertyL(recBufSizeStr, val); iTransaction = iSession.OpenTransactionL(up, *this, method); iTransaction.SubmitL(); CActiveScheduler::Start(); CleanupStack::PopAndDestroy(&iSession); //close iSession }
// ----------------------------------------------------------------------------- // CSdpOriginField::TypeMatchesWithFormat // Checks if address type is aligned with the address format // ----------------------------------------------------------------------------- // TBool CSdpOriginField::TypeMatchesWithFormat( const TDesC8& aAddress, const TDesC8& aType, RStringPool aPool ) const { RStringF addrTypeIP4 = aPool.StringF( SdpCodecStringConstants::EAddressTypeIP4, SdpCodecStringConstants::Table ); RStringF addrTypeIP6 = aPool.StringF( SdpCodecStringConstants::EAddressType, SdpCodecStringConstants::Table ); TBool valid( ETrue ); // Check that address type and address matches together TInetAddr addr; TBuf<KMaxAddressLength> address16; address16.Copy( aAddress ); TInt err = addr.Input( address16 ); if ( err == KErrNone && !addr.IsUnspecified()) { TBool ip4Type = ( addrTypeIP4.DesC().CompareF( aType ) == 0 ); TBool ip6Type = ( addrTypeIP6.DesC().CompareF( aType ) == 0 ); if ( ip4Type || ip6Type ) { if ( ( addr.Address() && !addr.IsV4Mapped() && !ip4Type ) || (addr.Address() && addr.IsV4Mapped() && !ip6Type) || ( !addr.Address() && !ip6Type ) ) { valid = EFalse; } } } return valid; }
TBool CTestTransaction::SetUserAgentL(RHTTPHeaders &aHeaders, RStringPool &aStrPool) { // get the DEFINE for UserAgent TBuf8<KMaxUserAgentSize> userAgentBuf; userAgentBuf.Copy(Machine()->GetDefine(KITHUserAgent)); TInt iLen = userAgentBuf.Length(); // assign the selection RStringF agent = (iLen == 0) ? aStrPool.OpenFStringL(KUserAgent) : aStrPool.OpenFStringL(userAgentBuf); THTTPHdrVal userAgent(agent); aHeaders.SetFieldL(aStrPool.StringF(HTTP::EUserAgent, RHTTPSession::GetTable()), userAgent); agent.Close(); return ETrue; }
// --------------------------------------------------------------------------- // SdpUtil::EncodeBufferL // Encodes headername and a value to the stream // --------------------------------------------------------------------------- // void SdpUtil::EncodeBufferL( const TDesC8& aValue, TInt aIndex, RWriteStream& aStream ) { if( aValue.Length() != 0 ) { RStringPool pool = SdpCodecStringPool::StringPoolL(); RStringF headername = pool.StringF( aIndex, SdpCodecStringPool::StringTableL() ); aStream.WriteL( headername.DesC() ); aStream.WriteL( aValue ); aStream.WriteL( KCRLFStr ); } }
void CHttpController::ConstructL( RConnection& aConnection, RSocketServ& aSocketServ ) { iPersistentHeaders = CHttpHeaders::NewL(); iSession.OpenL(); RHTTPConnectionInfo connectionInfo = iSession.ConnectionInfo(); RStringPool pool = iSession.StringPool(); connectionInfo.SetPropertyL( pool.StringF( HTTP::EHttpSocketServ, RHTTPSession::GetTable() ), THTTPHdrVal( aSocketServ.Handle() ) ); TInt connectionPtr = REINTERPRET_CAST(TInt, &aConnection); connectionInfo.SetPropertyL( pool.StringF( HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), THTTPHdrVal( connectionPtr ) ); iSession.FilterCollection().RemoveFilter( iSession.StringPool().StringF( HTTP::ERedirect, RHTTPSession::GetTable() ) ); iTimeoutTimer = CPeriodic::NewL( CActive::EPriorityIdle ); if ( !iOutputEncoder ) { //default content encoder iOutputEncoder = CMultipartEncoder::NewL(); } }
void CHeaderDecode::ProcessHeadersL(RHTTPTransaction aTrans) { RStringPool stringPool = aTrans.Session().StringPool(); RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); THTTPHdrVal hdrVal; //Check Content-Length header parameter is stored correctly RStringF contentLengthStr = stringPool.StringF(HTTP::EContentLength, aTrans.Session().GetTable()); User::LeaveIfError(headers.GetField(contentLengthStr,0,hdrVal)); if(headers.FieldPartsL(contentLengthStr) != 1) User::Leave(KErrArgument); if (hdrVal.Int() != 6) User::Leave(KErrArgument); }