// ----------------------------------------------------------------------------- // 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) ); }
void CHttpHdrTest::TestRemoveParamL() { // Open strings needed in this test RStringF qStr = iStrP.StringF(HTTP::EQ,RHTTPSession::GetTable()); RStringF textHtmlStr = iStrP.StringF(HTTP::ETextHtml,RHTTPSession::GetTable()); // CHeaderFieldPart* htmlPt = CHeaderFieldPart::NewL(THTTPHdrVal(textHtmlStr)); CleanupStack::PushL(htmlPt); THTTPHdrVal::TQConv q(0.2); CHeaderFieldParam* headerParam = CHeaderFieldParam::NewL(qStr, THTTPHdrVal(q)); CleanupStack::PushL(headerParam); htmlPt->AddParamL(headerParam); CleanupStack::Pop(headerParam); // // now remove the params CHeaderFieldParam* qP = htmlPt->Parameter(qStr); htmlPt->RemoveParam(qP); // Attempting to remove a non-existent parameter should fail somehow TestL(htmlPt->RemoveParam(qP) == KErrNotFound); // Now just destroy that lot CleanupStack::PopAndDestroy(htmlPt); }
void CHttpHdrTest::TestRemovePartL() { // 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.2); CHeaderFieldParam* headerParam = CHeaderFieldParam::NewL(qStr, THTTPHdrVal(q)); CleanupStack::PushL(headerParam); htmlPt->AddParamL(headerParam); CleanupStack::Pop(headerParam); accept->AddPartL(htmlPt); CleanupStack::Pop(htmlPt); // htmlPt - now owned by the header // CHeaderFieldPart* plainPt = CHeaderFieldPart::NewL(THTTPHdrVal(textPlainStr)); CleanupStack::PushL(plainPt); headerParam = CHeaderFieldParam::NewL(qStr, THTTPHdrVal(q)); CleanupStack::PushL(headerParam); plainPt->AddParamL(headerParam); CleanupStack::Pop(headerParam); accept->AddPartL(plainPt); CleanupStack::Pop(plainPt); // plainPt - now owned by the header // CHeaderFieldPart* headerPart = CHeaderFieldPart::NewL(anyAnyStr); CleanupStack::PushL(headerPart); accept->AddPartL(headerPart); CleanupStack::Pop(headerPart); // now remove the parts TestL(accept->RemovePartL(0) == KErrNone); // removes htmlPt TestL(accept->RemovePartL(1) == KErrNone); // removes '*/*' part... // Attempting to remove a non-existent part should fail somehow TestL(accept->RemovePartL(2) == KErrNotFound); // remove the final part TestL(accept->RemovePartL(0) == KErrNone); // removes plainPt // Now just destroy that lot CleanupStack::PopAndDestroy(); // accept }
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); }
void CHttpHdrTest::TestAddMultiPartL() { // Open strings needed in this test RStringF accChSetStr = iStrP.StringF(HTTP::EAcceptCharset,RHTTPSession::GetTable()); RStringF usAsciiStr = iStrP.OpenFStringL(_L8("us-ascii")); CleanupClosePushL(usAsciiStr); RStringF utf8Str = iStrP.OpenFStringL(_L8("utf-8")); CleanupClosePushL(utf8Str); RStringF accLangStr = iStrP.StringF(HTTP::EAcceptLanguage,RHTTPSession::GetTable()); RStringF enGbStr = iStrP.OpenFStringL(_L8("en-gb")); CleanupClosePushL(enGbStr); RStringF frStr = iStrP.OpenFStringL(_L8("fr")); CleanupClosePushL(frStr); // // Accept-Charset: us-ascii, utf-8 // CHeaderField* accChSet = CHeaderField::NewL(accChSetStr, *iHdrColl); CleanupStack::PushL(accChSet); // create first part ; ownership transferred CHeaderFieldPart* headerPart = CHeaderFieldPart::NewL(THTTPHdrVal(usAsciiStr)); CleanupStack::PushL(headerPart); accChSet->AddPartL(headerPart); CleanupStack::Pop(headerPart); // create second part ; ownership transferred headerPart = CHeaderFieldPart::NewL(THTTPHdrVal(utf8Str)); CleanupStack::PushL(headerPart); accChSet->AddPartL(headerPart); CleanupStack::Pop(headerPart); // Accept-Language: en-gb. fr // // quick method to get first part CHeaderField* accLang = CHeaderField::NewL(accLangStr, *iHdrColl, THTTPHdrVal(enGbStr)); CleanupStack::PushL(accLang); // create second part ; ownership transferred headerPart = CHeaderFieldPart::NewL(THTTPHdrVal(frStr)); CleanupStack::PushL(headerPart); accLang->AddPartL(headerPart); CleanupStack::Pop(headerPart); // Now just destroy that lot CleanupStack::PopAndDestroy(6); }
void CHttpHdrTest::TestLookupParamL() { // Open strings needed in this test RStringF qStr = iStrP.StringF(HTTP::EQ,RHTTPSession::GetTable()); RStringF textHtmlStr = iStrP.StringF(HTTP::ETextHtml,RHTTPSession::GetTable()); RStringF user1Str = iStrP.OpenFStringL(_L8("user1")); CleanupClosePushL(user1Str); RStringF value1Str = iStrP.OpenFStringL(_L8("value1")); CleanupClosePushL(value1Str); RStringF user2Str = iStrP.OpenFStringL(_L8("user2")); CleanupClosePushL(user2Str); RStringF value2Str = iStrP.OpenFStringL(_L8("value2")); CleanupClosePushL(value2Str); // CHeaderFieldPart* htmlPt = CHeaderFieldPart::NewL(THTTPHdrVal(textHtmlStr)); CleanupStack::PushL(htmlPt); THTTPHdrVal::TQConv q(0.2); CHeaderFieldParam* headerParam = CHeaderFieldParam::NewL(qStr, THTTPHdrVal(q)); CleanupStack::PushL(headerParam); htmlPt->AddParamL(headerParam); CleanupStack::Pop(headerParam); headerParam = CHeaderFieldParam::NewL(user1Str, THTTPHdrVal(value1Str)); CleanupStack::PushL(headerParam); htmlPt->AddParamL(headerParam); CleanupStack::Pop(headerParam); headerParam = CHeaderFieldParam::NewL(user2Str, THTTPHdrVal(value2Str)); CleanupStack::PushL(headerParam); htmlPt->AddParamL(headerParam); CleanupStack::Pop(headerParam); // // now lookup the params CHeaderFieldParam* qP = htmlPt->Parameter(qStr); RStringF qPstr = qP->Name(); TestL(qPstr.Index(RHTTPSession::GetTable()) == qStr.Index(RHTTPSession::GetTable())); // qP = htmlPt->Parameter(user1Str); qPstr = qP->Name(); TestL(qPstr.Index(RHTTPSession::GetTable()) == user1Str.Index(RHTTPSession::GetTable())); // qP = htmlPt->Parameter(user2Str); qPstr = qP->Name(); TestL(qPstr.Index(RHTTPSession::GetTable()) == user2Str.Index(RHTTPSession::GetTable())); // Now just destroy that lot CleanupStack::PopAndDestroy(5); }
void CHttpClientFilter::EnsureContentLengthL(RHTTPTransaction aTransaction) { RHTTPRequest request = aTransaction.Request(); if( request.HasBody() ) { THTTPHdrVal hdrVal; RStringF teName = iStringPool.StringF(HTTP::ETransferEncoding, iStringTable); // Get rid of Content-Length header if present // NOTE - cannot use a local variable for the Content-Length as causes a // compiler bug in thumb builds - grand! : ( RHTTPHeaders headers = request.GetHeaderCollection(); headers.RemoveField(iStringPool.StringF(HTTP::EContentLength, iStringTable)); TInt bodySize = request.Body()->OverallDataSize(); if( bodySize != KErrNotFound ) { // Size is known - set the ContentLength header. headers.SetFieldL(iStringPool.StringF(HTTP::EContentLength, iStringTable), THTTPHdrVal(bodySize)); } else if( headers.GetField(teName, 0, hdrVal) == KErrNotFound ) { // Size is unknown and there's been no Encoding indicated by the // client - set the 'TransferEncoding: chunked' hdrVal.SetStrF(iStringPool.StringF(HTTP::EChunked, iStringTable)); headers.SetFieldL(teName, hdrVal); } } }
void CHttpHdrTest::TestAddSinglePartQuickL() { RStringF accStr = iStrP.StringF(HTTP::EAccept,RHTTPSession::GetTable()); RStringF textHtmlStr = iStrP.StringF(HTTP::ETextHtml,RHTTPSession::GetTable()); RStringF expiresStr = iStrP.StringF(HTTP::EExpires,RHTTPSession::GetTable()); RStringF maxForwardsStr = iStrP.StringF(HTTP::EMaxForwards,RHTTPSession::GetTable()); // // Accept: text/html // // creates a single stringtoken part CHeaderField* accept = CHeaderField::NewL(accStr, *iHdrColl, THTTPHdrVal(textHtmlStr)); CleanupStack::PushL(accept); // // Expires: Mon, 15 Jan 2001 10:30:25 GMT // // creates a single date/time part, using an implicit case CHeaderField* expires = CHeaderField::NewL(expiresStr, *iHdrColl, TDateTime(2001, EJanuary, 15, 10, 30, 25, 0)); CleanupStack::PushL(expires); // // Max-Forwards: 3 // // creates a single integer part, using an implicit case CHeaderField* maxfwds = CHeaderField::NewL(maxForwardsStr, *iHdrColl, 3); CleanupStack::PushL(maxfwds); // Now just destroy that lot CleanupStack::PopAndDestroy(3); }
void CHttpHdrTest::TestBasicsL() { // Open strings needed in this test RStringF accStr = iStrP.StringF(HTTP::EAccept,RHTTPSession::GetTable()); RStringF textHtmlStr = iStrP.StringF(HTTP::ETextHtml,RHTTPSession::GetTable()); RStringF qStr = iStrP.StringF(HTTP::EQ,RHTTPSession::GetTable()); CHeaderField* hdr = CHeaderField::NewL(accStr, *iHdrColl); delete hdr; // CHeaderFieldPart* part = CHeaderFieldPart::NewL(THTTPHdrVal(textHtmlStr)); delete part; // THTTPHdrVal::TQConv q(0.2); CHeaderFieldParam* param = CHeaderFieldParam::NewL(qStr, THTTPHdrVal(q)); delete param; }
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::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); } }
/** * 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 CHttpHdrTest::TestAddSinglePartLongL() { // Open strings needed in this test RStringF accStr = iStrP.StringF(HTTP::EAccept,RHTTPSession::GetTable()); RStringF textHtmlStr = iStrP.StringF(HTTP::ETextHtml,RHTTPSession::GetTable()); RStringF expiresStr = iStrP.StringF(HTTP::EExpires,RHTTPSession::GetTable()); RStringF maxForwardsStr = iStrP.StringF(HTTP::EMaxForwards,RHTTPSession::GetTable()); CHeaderFieldPart* headerPart = NULL; // // Accept: text/html // CHeaderField* accept = CHeaderField::NewL(accStr, *iHdrColl); CleanupStack::PushL(accept); headerPart = CHeaderFieldPart::NewL(THTTPHdrVal(textHtmlStr)); CleanupStack::PushL(headerPart); accept->AddPartL(headerPart); // string part added; ownership given to header CleanupStack::Pop(headerPart); CleanupStack::PopAndDestroy(accept); // // Expires: Mon, 15 Jan 2001 10:30:25 GMT // CHeaderField* expires = CHeaderField::NewL(expiresStr, *iHdrColl); CleanupStack::PushL(expires); headerPart = CHeaderFieldPart::NewL(THTTPHdrVal(TDateTime(2001, EJanuary, 15, 10, 30, 25, 0))); CleanupStack::PushL(headerPart); expires->AddPartL(headerPart); // date/time added; ownership given to header CleanupStack::Pop(headerPart); CleanupStack::PopAndDestroy(expires); // // Max-Forwards: 3 // CHeaderField* maxfwds = CHeaderField::NewL(maxForwardsStr, *iHdrColl); CleanupStack::PushL(maxfwds); headerPart = CHeaderFieldPart::NewL(3); CleanupStack::PushL(headerPart); maxfwds->AddPartL(headerPart); // integer part added; ownership given to header CleanupStack::Pop(headerPart); CleanupStack::PopAndDestroy(maxfwds); }
void CHttpHdrTest::TestAddParamL() { // 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); // now owned by htmlPt accept->AddPartL(htmlPt); CleanupStack::Pop(); // htmlPt - now owned by the header // CHeaderFieldPart* plainPt = CHeaderFieldPart::NewL(THTTPHdrVal(textPlainStr)); CleanupStack::PushL(plainPt); headerParam = CHeaderFieldParam::NewL(qStr, THTTPHdrVal(q)); CleanupStack::PushL(headerParam); htmlPt->AddParamL(headerParam); CleanupStack::Pop(headerParam); // now owned by htmlPt accept->AddPartL(plainPt); CleanupStack::Pop(); // plainPt - now owned by the header // accept->AddPartL(CHeaderFieldPart::NewL(THTTPHdrVal(anyAnyStr))); // Now just destroy that lot CleanupStack::PopAndDestroy(); // accept }
void CTestFilter::EncodeBasicAuthL(RString& aUsername, RString& aPW, RHTTPTransaction& aTransaction) { // Standard, plain-text HTTP - Base 64 the name and password TBase64 codec; HBufC8* nameAndPW = HBufC8::NewMaxLC(aUsername.DesC().Length() + aPW.DesC().Length() + 1); _LIT8(KBasicAuthFormatString, "%S:%S"); nameAndPW->Des().Format(KBasicAuthFormatString, &aUsername.DesC(), &aPW.DesC()); // Conservatively allocate a buffer twice as big as the unencoded // buffer for the encoded string. HBufC8* encoded = HBufC8::NewMaxLC(nameAndPW->Des().Length() * 2); TPtr8 encodedPtr(encoded->Des()); codec.Encode(*nameAndPW, encodedPtr); RString encodedString = iStringPool.OpenStringL(*encoded); CleanupStack::PopAndDestroy(2, nameAndPW); CleanupClosePushL(encodedString); RHTTPHeaders requestHeaders(aTransaction.Request().GetHeaderCollection()); requestHeaders.RemoveField(iStringPool.StringF(HTTP::EAuthorization,RHTTPSession::GetTable())); requestHeaders.SetFieldL(iStringPool.StringF(HTTP::EAuthorization,RHTTPSession::GetTable()), THTTPHdrVal(iStringPool.StringF(HTTP::EBasic,RHTTPSession::GetTable()))); requestHeaders.SetFieldL(iStringPool.StringF(HTTP::EAuthorization,RHTTPSession::GetTable()), THTTPHdrVal(encodedString)); aTransaction.PropertySet().SetPropertyL(iStringPool.StringF(HTTP::EAuthorization,RHTTPSession::GetTable()), THTTPHdrVal(encodedString)); CleanupStack::PopAndDestroy(&encodedString); }
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(); } }
// ----------------------------------------------------------------------------- // CHttpFilterProxy::SetProxyL // Function to handle Submit events. // Set proxy properties (EUseProxy and EProxyAddress) in order to get connected throught // proxy when a new HTTP session will be in effect. The Proxy data will be taken from // the CommDb if a new connection has been used. If a proxy property has already been // set by a higher filter or by the client, then those settings are preferred over // CommsDB. // ----------------------------------------------------------------------------- // void CHttpFilterProxy::SetProxyL(const RHTTPTransaction aTransaction) { THTTPHdrVal isNewConn, proxyAddress; // If connection has been disconnected the user could change Access Point, so let's // check if a new connection has been used. TBool ret = iConnInfo.Property (iStringPool.StringF(HttpFilterCommonStringsExt::EHttpNewConnFlag, HttpFilterCommonStringsExt::GetTable()), isNewConn); if (ret && isNewConn.Type() == THTTPHdrVal::KTIntVal && (isNewConn.Int() == 1)) { iUsage = EFalse; // Read proxy info from the CommDB ReadProxyInfoL(iStringPool, iUsage, iProxyAddress, iExceptions); } else { TBool useProxy( ETrue ); THTTPHdrVal proxyUsageVal; // Is the property for proxy usage set? TBool hasUsageValue = iConnInfo.Property(iStringPool.StringF(HTTP::EProxyUsage, RHTTPSession::GetTable()), proxyUsageVal); // If the property is set, is it EUseProxy if (hasUsageValue) { useProxy = ( proxyUsageVal.StrF().Index(RHTTPSession::GetTable()) == HTTP::EUseProxy); } // Use proxy if the property value is EUseProxy or no property is set. if (useProxy || !hasUsageValue) { THTTPHdrVal proxyAddressVal; TBool hasValue = iConnInfo.Property(iStringPool.StringF(HTTP::EProxyAddress, RHTTPSession::GetTable()), proxyAddressVal); if (!hasValue) { // The proxyAddress has not been set, so Read proxy info from the CommDB ReadProxyInfoL(iStringPool, iUsage, iProxyAddress, iExceptions); } else { // Now get the proxy address... iProxyAddress = proxyAddressVal.StrF().Copy(); iUsage = ETrue; } } // } } // We should not use proxy if the uri matches to one of exceptions from the exception list // In this case the Origing server will be used ExcptionsCompare(aTransaction); // Respect proxy settings already defined by client or higher HTTP filter THTTPHdrVal proxyUsage; // Check if property present or not present, not the value. if ( !iConnInfo.Property(iStringPool.StringF(HTTP::EProxyUsage, RHTTPSession::GetTable()), proxyUsage)) { // Set the proxy address and proxy Usage proxyAddress = THTTPHdrVal(iProxyAddress); iConnInfo.RemoveProperty(iStringPool.StringF(HTTP::EProxyAddress, RHTTPSession::GetTable())); iConnInfo.SetPropertyL(iStringPool.StringF(HTTP::EProxyAddress, RHTTPSession::GetTable()), proxyAddress); iConnInfo.RemoveProperty(iStringPool.StringF(HTTP::EProxyUsage, RHTTPSession::GetTable())); if (iUsage) { iConnInfo.SetPropertyL(iStringPool.StringF(HTTP::EProxyUsage, RHTTPSession::GetTable()), iStringPool.StringF(HTTP::EUseProxy, RHTTPSession::GetTable())); } else { iConnInfo.SetPropertyL(iStringPool.StringF(HTTP::EProxyUsage, RHTTPSession::GetTable()), iStringPool.StringF(HTTP::EDoNotUseProxy, RHTTPSession::GetTable())); } } // Cleanup strings. iProxyAddress.Close(); iExceptions.Close(); }
TBool CConnectionManager::SetupConnection() { TInt iCurrentProfileId; iBearerFilter = EApBearerTypeAllBearers; ASSERT(iRepository); // Check whether we are offline or online iRepository->Get(KProEngActiveProfile, iCurrentProfileId); // Close the connection only if // a) this is not the first time and // b) the profile has changed and // c) either the previous or the current profile is Offline (5 = Offline) if (iPreviousProfileId != -1 && iPreviousProfileId != iCurrentProfileId && (iPreviousProfileId == EConnectionStatus::Disconnected || iCurrentProfileId == EConnectionStatus::Disconnected)) { // Close and uninitialize iConnectionSetup = EFalse; iSessionHttp .Close(); iConnection .Close(); iServerSocket.Close(); } // Save current profile id iPreviousProfileId = iCurrentProfileId; // Try to find an existing connection. If connection has not been set up, // iConnection is not initialized and FindExistingConnection() fails. // Thus, in that case, finding must not be carried out. if (iConnectionSetup && !FindExistingConnection()) { iConnectionSetup = EFalse; } if (iConnectionSetup) { // Connection setup is done iNewConnection = EFalse; return ETrue; } // Open RHTTPSession with default protocol ("HTTP/TCP") iSessionHttp.OpenL(); // Install this class as the callback for authentication requests. When // page requires authentication the framework calls GetCredentialsL to get // user name and password. InstallAuthenticationL(iSessionHttp); // In offline, only WLAN connections are available if (iCurrentProfileId == EConnectionStatus::Disconnected) { iBearerFilter = EApBearerTypeWLAN; } // Show IAP selection dialog /*CActiveApDb* aDb = CActiveApDb::NewL(); CleanupStack::PushL(aDb); CApSettingsHandler* settings = CApSettingsHandler::NewLC ( *aDb , ETrue , EApSettingsSelListIsPopUp , EApSettingsSelMenuSelectNormal , KEApIspTypeAll , iBearerFilter , KEApSortNameAscending , 0 , EVpnFilterBoth , ETrue ); TInt iapRet = settings->RunSettingsL(0, iSelectedConnectionId); CleanupStack::PopAndDestroy(settings); CleanupStack::PopAndDestroy(aDb); if (iapRet != KApUiEventSelected) { // Exit no selection User::Leave(KErrNotReady); } else*/ // open the IAP communications database CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP); CleanupStack::PushL(commDB); // initialize a view CCommsDbConnectionPrefTableView* commDBView = commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown); // go to the first record User::LeaveIfError(commDBView->GotoFirstRecord()); CCommsDbConnectionPrefTableView::TCommDbIapBearer bearer; bearer.iBearerSet = iBearerFilter; // Declare a prefTableView Object. CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref; pref.iBearer = bearer; pref.iDirection = ECommDbConnectionDirectionOutgoing; // read the connection preferences commDBView->ReadConnectionPreferenceL(pref); iSelectedConnectionId = pref.iBearer.iIapId; // pop and destroy the IAP View CleanupStack::PopAndDestroy(commDBView); // pop and destroy the database object CleanupStack::PopAndDestroy(commDB); iNewConnection = ETrue; // IAP Selected // Open socket server and start the connection User::LeaveIfError(iServerSocket.Connect(KESockDefaultMessageSlots)); User::LeaveIfError(iConnection.Open(iServerSocket, KConnectionTypeDefault)); // Now we have the iap Id. Use it to connect for the connection TCommDbConnPref connectPref; // Setup preferences connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); // Sets the CommDb ID of the IAP to use for this connection connectPref.SetIapId(iSelectedConnectionId); // Sets direction connectPref.SetDirection(ECommDbConnectionDirectionOutgoing); connectPref.SetBearerSet(iBearerFilter); // Start connection User::LeaveIfError(iConnection.Start(connectPref)); //TInt retval = iConnection.Start(); //User::LeaveIfError(retval); // Set the sessions connection info... RStringPool strPool = iSessionHttp.StringPool(); RHTTPConnectionInfo connInfo = iSessionHttp.ConnectionInfo(); // ...to use our socket server and connection connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal (iServerSocket.Handle())); // ...to use our connection connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection)))); iConnectionSetup = ETrue; return ETrue; }
// ---------------------------------------------------------------------------- // CClientEngine::SetupConnectionL() // // The method set the internet access point and connection setups. // ---------------------------------------------------------------------------- void CClientEngine::SetupConnectionL() { if( iConnectionSetupDone ) return; iConnectionSetupDone = ETrue; //open socket server and start the connection User::LeaveIfError(iSocketServ.Connect()); User::LeaveIfError(iConnection.Open(iSocketServ)); TCommDbConnPref connectPref; TUint32 iapID; if(iSetIap == EFalse) { // open the IAP communications database CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP); CleanupStack::PushL(commDB); // initialize a view CCommsDbConnectionPrefTableView* commDBView = commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown); // go to the first record User::LeaveIfError(commDBView->GotoFirstRecord()); // Declare a prefTableView Object. CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref; // read the connection preferences commDBView->ReadConnectionPreferenceL(pref); iapID = pref.iBearer.iIapId; // pop and destroy the IAP View CleanupStack::PopAndDestroy(commDBView); // pop and destroy the database object CleanupStack::PopAndDestroy(commDB); // setup preferences connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); connectPref.SetDirection(ECommDbConnectionDirectionUnknown); connectPref.SetBearerSet(ECommDbBearerGPRS); //Sets the CommDb ID of the IAP to use for this connection connectPref.SetIapId(iapID); }else{ connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); connectPref.SetDirection(ECommDbConnectionDirectionUnknown); connectPref.SetBearerSet(ECommDbBearerGPRS); //Sets the CommDb ID of the IAP to use for this connection connectPref.SetIapId(iIapId); } User::LeaveIfError(iConnection.Start(connectPref)); //set the sessions connection info RStringPool strPool = iSession.StringPool(); RHTTPConnectionInfo connInfo = iSession.ConnectionInfo(); //to use our socket server and connection connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable() ), THTTPHdrVal (iSocketServ.Handle()) ); connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection))) ); }
void CTestMessageComposer::SetHeaderL(TInt aNumberofHeaders) { switch (aNumberofHeaders) { case 1: { // Open strings used in this test //1.Accept header---- Accept: text/html; q=0.8, text/vnd.wap.wml; q=0.2; extended=value, text/*); RStringF textHtml = iStringPool.StringF(HTTP::ETextHtml,RHTTPSession::GetTable()); RStringF textWml = iStringPool.StringF(HTTP::ETextVndWapWml,RHTTPSession::GetTable()); RStringF textAny = iStringPool.StringF(HTTP::ETextAny,RHTTPSession::GetTable()); RStringF extended = iStringPool.OpenFStringL(_L8("extended")); CleanupClosePushL(extended); RStringF extendVal = iStringPool.OpenFStringL(_L8("value")); CleanupClosePushL(extendVal); iHTTPHeaders = iTransaction.Request().GetHeaderCollection(); RStringF accept = iStringPool.StringF(HTTP::EAccept,RHTTPSession::GetTable()); THTTPHdrVal accVal(textHtml); THTTPHdrVal q1(THTTPHdrVal::TQConv(0.8)); iHTTPHeaders.SetFieldL(accept, accVal, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q1); accVal.SetStrF(textWml); q1.SetInt(THTTPHdrVal::TQConv(0.2)); iHTTPHeaders.SetFieldL(accept, accVal, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q1); q1.SetStrF(extendVal); iHTTPHeaders.SetFieldL(accept, accVal, extended, q1); accVal.SetStrF(textAny); iHTTPHeaders.SetFieldL(accept, accVal); CleanupStack::PopAndDestroy(2, &extended); //2.Accept-Charset header-- Accept-Charset: iso-8859-5, unicode-1-1; q=0.8 RStringF iso8859_5 = iStringPool.OpenFStringL(_L8("iso-8859-5")); CleanupClosePushL(iso8859_5); RStringF unicode1_1 = iStringPool.OpenFStringL(_L8("unicode-1-1")); CleanupClosePushL(unicode1_1); RStringF accChSet= iStringPool.StringF(HTTP::EAcceptCharset,RHTTPSession::GetTable()); THTTPHdrVal accChSetVal(iso8859_5); iHTTPHeaders.SetFieldL(accChSet, accChSetVal); // accChSetVal.SetStrF(unicode1_1); THTTPHdrVal q2(THTTPHdrVal::TQConv(0.8)); iHTTPHeaders.SetFieldL(accChSet, accChSetVal, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q2); CleanupStack::PopAndDestroy(2, &iso8859_5); //3.User-Agent headers-- User-Agent: CERN-LineMode/2.15 libwww/2.17b3 // Open strings used in this test RStringF ua1Str = iStringPool.OpenFStringL(_L8("CERN-LineMode/2.15")); CleanupClosePushL(ua1Str); RStringF ua2Str = iStringPool.OpenFStringL(_L8("libwww/2.17b3")); CleanupClosePushL(ua2Str); // RStringF uaStr = iStringPool.StringF(HTTP::EUserAgent,RHTTPSession::GetTable()); THTTPHdrVal uaVal(ua1Str); iHTTPHeaders.SetFieldL(uaStr, uaVal); // sets part 1 uaVal.SetStrF(ua2Str); iHTTPHeaders.SetFieldL(uaStr, uaVal); // sets part 2 CleanupStack::PopAndDestroy(2,&ua1Str); //4.Connection Header -- Connection: close, keep-alive RStringF otherToken = iStringPool.StringF(HTTP::EKeepAlive,RHTTPSession::GetTable()); RStringF connStr = iStringPool.StringF(HTTP::EConnection,RHTTPSession::GetTable()); THTTPHdrVal connVal(iStringPool.StringF(HTTP::EClose,RHTTPSession::GetTable())); iHTTPHeaders.SetFieldL(connStr, connVal); // sets part 1 THTTPHdrVal keepAlive(otherToken); iHTTPHeaders.SetFieldL(connStr, keepAlive); // sets part 2 //5.content type header-- Content-Type: text/vnd.wap.wml; charset=utf-8; transcode=yes RStringF textWml1 = iStringPool.StringF(HTTP::ETextVndWapWml,RHTTPSession::GetTable()); RStringF utf8 = iStringPool.OpenFStringL(_L8("utf-8")); CleanupClosePushL(utf8); RStringF extended1 = iStringPool.OpenFStringL(_L8("transcode")); CleanupClosePushL(extended1); RStringF extendVal1 = iStringPool.OpenFStringL(_L8("yes")); CleanupClosePushL(extendVal1); // RStringF contType = iStringPool.StringF(HTTP::EContentType,RHTTPSession::GetTable()); THTTPHdrVal ctVal(textWml1); THTTPHdrVal chSet(utf8); iHTTPHeaders.SetFieldL(contType, ctVal, iStringPool.StringF(HTTP::ECharset,RHTTPSession::GetTable()), chSet); chSet.SetStrF(extendVal1); iHTTPHeaders.SetFieldL(contType, ctVal, extended1, chSet); CleanupStack::PopAndDestroy(3,&utf8); //6.host type header-- Host: nokia.com RStringF host1Str = iStringPool.OpenFStringL(_L8("www.nokia.com")); CleanupClosePushL(host1Str); RStringF host = iStringPool.StringF(HTTP::EHost,RHTTPSession::GetTable()); THTTPHdrVal hostVal(host1Str); iHTTPHeaders.SetFieldL(host, hostVal); CleanupStack::PopAndDestroy(&host1Str); //7.upgrade type header-- Upgrade: HTTP/2.0, SHTTP/1.3 RStringF http = iStringPool.OpenFStringL(_L8("HTTP/2.0")); CleanupClosePushL(http); RStringF shttp = iStringPool.OpenFStringL(_L8("SHTTP/1.3")); CleanupClosePushL(shttp); RStringF upgradeStr = iStringPool.StringF(HTTP::EUpgrade, RHTTPSession::GetTable()); THTTPHdrVal val(http); THTTPHdrVal val2(shttp); iHTTPHeaders.SetFieldL(upgradeStr, val); iHTTPHeaders.SetFieldL(upgradeStr, val2); CleanupStack::PopAndDestroy(2); //8.Cache control -- Cache-Control: public, no-cache=\"wibble,wobble\" _LIT8(KPublic, "public"); _LIT8(KNoCache, "no-cache=\"wibble,wobble\""); RStringF publicStr = iStringPool.OpenFStringL(KPublic); CleanupClosePushL(publicStr); RStringF noCacheStr = iStringPool.OpenFStringL(KNoCache); CleanupClosePushL(noCacheStr); RStringF cc = iStringPool.StringF(HTTP::ECacheControl,RHTTPSession::GetTable()); iHTTPHeaders.SetFieldL(cc, THTTPHdrVal(publicStr)); iHTTPHeaders.SetFieldL(cc, THTTPHdrVal(noCacheStr)); CleanupStack::PopAndDestroy(2,&publicStr); //9.Authorization-- Authorization: Basic c3ltYmlhbjpmMXN5bmNtbA== RString basicCred = iStringPool.OpenStringL(_L8("c3ltYmlhbjpmMXN5bmNtbA==")); CleanupClosePushL(basicCred); RStringF authStr = iStringPool.StringF(HTTP::EAuthorization,RHTTPSession::GetTable()); THTTPHdrVal authVal(iStringPool.StringF(HTTP::EBasic,RHTTPSession::GetTable())); iHTTPHeaders.SetFieldL(authStr, authVal); // sets part 1 THTTPHdrVal credVal(basicCred); iHTTPHeaders.SetFieldL(authStr, credVal); // sets part 2 CleanupStack::PopAndDestroy(&basicCred); break; } case 2: { //1. Connection: Keep-Alive\r\n RStringF keep = iStringPool.StringF(HTTP::EKeepAlive,RHTTPSession::GetTable()); iHTTPHeaders = iTransaction.Request().GetHeaderCollection(); RStringF Connection= iStringPool.StringF(HTTP::EConnection,RHTTPSession::GetTable()); THTTPHdrVal keepalive(keep); iHTTPHeaders.SetFieldL(Connection,keepalive); //2.Host: 192.168.100.100\r\n _LIT8(KHostIp, "192.168.100.100"); RStringF host2Str = iStringPool.OpenFStringL(KHostIp); CleanupClosePushL(host2Str); RStringF host2= iStringPool.StringF(HTTP::EHost,RHTTPSession::GetTable()); THTTPHdrVal hostip(host2Str); iHTTPHeaders.SetFieldL(host2,hostip); CleanupStack::PopAndDestroy(&host2Str); //3.Accept: */*\r\n _LIT8(KAccept2, "*/*"); RStringF acceptall = iStringPool.OpenFStringL(KAccept2); CleanupClosePushL(acceptall); RStringF accept2= iStringPool.StringF(HTTP::EAccept,RHTTPSession::GetTable()); THTTPHdrVal acceptvalue(acceptall); iHTTPHeaders.SetFieldL(accept2,acceptvalue); CleanupStack::PopAndDestroy(&acceptall); //4.Accept-Charset: iso-8859-1,utf-8;q=0.7,*;q=0.7\r\n RStringF iso8859 = iStringPool.OpenFStringL(_L8("iso-8859-1")); CleanupClosePushL(iso8859); RStringF utf8_1 = iStringPool.OpenFStringL(_L8("utf-8")); CleanupClosePushL(utf8_1); RStringF all = iStringPool.OpenFStringL(_L8("*")); CleanupClosePushL(all); RStringF accChSet1= iStringPool.StringF(HTTP::EAcceptCharset,RHTTPSession::GetTable()); THTTPHdrVal accChSetVal1(iso8859); iHTTPHeaders.SetFieldL(accChSet1, accChSetVal1); accChSetVal1.SetStrF(utf8_1); THTTPHdrVal q3(THTTPHdrVal::TQConv(0.7)); iHTTPHeaders.SetFieldL(accChSet1, accChSetVal1, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q3); accChSetVal1.SetStrF(all); iHTTPHeaders.SetFieldL(accChSet1, accChSetVal1, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q3); CleanupStack::PopAndDestroy(3,&iso8859); //5.Accept-Encoding: gzip, deflate, x-gzip, identity; q=0.9\r\n RStringF gzip = iStringPool.OpenFStringL(_L8("gzip")); CleanupClosePushL(gzip); RStringF deflate = iStringPool.OpenFStringL(_L8("deflate")); CleanupClosePushL(deflate); RStringF xgzip = iStringPool.OpenFStringL(_L8("x-gzip")); CleanupClosePushL(xgzip); RStringF identity = iStringPool.OpenFStringL(_L8("identity")); CleanupClosePushL(identity); RStringF acceptencoding1= iStringPool.StringF(HTTP::EAcceptEncoding,RHTTPSession::GetTable()); THTTPHdrVal aevalue(gzip); iHTTPHeaders.SetFieldL(acceptencoding1, aevalue); aevalue.SetStrF(deflate); iHTTPHeaders.SetFieldL(acceptencoding1, aevalue); aevalue.SetStrF(xgzip); iHTTPHeaders.SetFieldL(acceptencoding1, aevalue); aevalue.SetStrF(identity); THTTPHdrVal q4(THTTPHdrVal::TQConv(0.9)); iHTTPHeaders.SetFieldL(acceptencoding1, aevalue, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q4); CleanupStack::PopAndDestroy(4,&gzip); //6.Accept-Language: en;q=1.0,bg;q=0.5,nl;q=0.5,fr;q=0.5\r\n RStringF en = iStringPool.OpenFStringL(_L8("en")); CleanupClosePushL(en); RStringF bg = iStringPool.OpenFStringL(_L8("bg")); CleanupClosePushL(bg); RStringF nl = iStringPool.OpenFStringL(_L8("nl")); CleanupClosePushL(nl); RStringF fr = iStringPool.OpenFStringL(_L8("fr")); CleanupClosePushL(fr); RStringF acceptlanguage1= iStringPool.StringF(HTTP::EAcceptLanguage,RHTTPSession::GetTable()); THTTPHdrVal alvalue(en); THTTPHdrVal q5(THTTPHdrVal::TQConv(1.0)); iHTTPHeaders.SetFieldL(acceptlanguage1, alvalue, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q5); THTTPHdrVal q6(THTTPHdrVal::TQConv(0.5)); alvalue.SetStrF(bg); iHTTPHeaders.SetFieldL(acceptlanguage1, alvalue, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q6); alvalue.SetStrF(nl); iHTTPHeaders.SetFieldL(acceptlanguage1, alvalue, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q6); alvalue.SetStrF(fr); iHTTPHeaders.SetFieldL(acceptlanguage1, alvalue, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q6); CleanupStack::PopAndDestroy(4,&en); //7.Referer: http://192.168.100.100/il/index.html\r\n RStringF referer = iStringPool.OpenFStringL(_L8("http://192.168.100.100/il/index.html")); CleanupClosePushL(referer); RStringF refer= iStringPool.StringF(HTTP::EReferer,RHTTPSession::GetTable()); THTTPHdrVal referval(referer); iHTTPHeaders.SetFieldL(refer,referval); CleanupStack::PopAndDestroy(&referer); //8.User-Agent: Mozilla/5.0 AppleWebKit/525 RStringF ua1Str1 = iStringPool.OpenFStringL(_L8("Mozilla/5.0")); CleanupClosePushL(ua1Str1); RStringF ua2Str2 = iStringPool.OpenFStringL(_L8("AppleWebKit/525")); CleanupClosePushL(ua2Str2); RStringF uaString = iStringPool.StringF(HTTP::EUserAgent,RHTTPSession::GetTable()); THTTPHdrVal uaVal1(ua1Str1); iHTTPHeaders.SetFieldL(uaString, uaVal1); // sets part 1 uaVal1.SetStrF(ua2Str2); iHTTPHeaders.SetFieldL(uaString, uaVal1); // sets part 2 CleanupStack::PopAndDestroy(2,&ua1Str1); break; } default: break; } }
TBool CConnectionManager::SetupConnection() { TInt iCurrentProfileId; iBearerFilter = EApBearerTypeAllBearers; ASSERT(iRepository); // Check whether we are offline or online iRepository->Get(KProEngActiveProfile, iCurrentProfileId); // Close the connection only if // a) this is not the first time and // b) the profile has changed and // c) either the previous or the current profile is Offline (5 = Offline) if (iPreviousProfileId != -1 && iPreviousProfileId != iCurrentProfileId && (iPreviousProfileId == EConnectionStatus::Disconnected || iCurrentProfileId == EConnectionStatus::Disconnected)) { // Close and uninitialize iConnectionSetup = EFalse; iSessionHttp .Close(); iConnection .Close(); iServerSocket.Close(); } // Save current profile id iPreviousProfileId = iCurrentProfileId; // Try to find an existing connection. If connection has not been set up, // iConnection is not initialized and FindExistingConnection() fails. // Thus, in that case, finding must not be carried out. if (iConnectionSetup && !FindExistingConnection()) { iConnectionSetup = EFalse; } if (iConnectionSetup) { // Connection setup is done iNewConnection = EFalse; return ETrue; } // Open RHTTPSession with default protocol ("HTTP/TCP") iSessionHttp.OpenL(); // Install this class as the callback for authentication requests. When // page requires authentication the framework calls GetCredentialsL to get // user name and password. InstallAuthenticationL(iSessionHttp); // In offline, only WLAN connections are available if (iCurrentProfileId == EConnectionStatus::Disconnected) { iBearerFilter = EApBearerTypeWLAN; } // Show IAP selection dialog if ( gSelectedConnectionId == -1 ) gSelectedConnectionId = SelectIAP(); iSelectedConnectionId = gSelectedConnectionId; iNewConnection = ETrue; // IAP Selected // Open socket server and start the connection User::LeaveIfError(iServerSocket.Connect(KESockDefaultMessageSlots)); User::LeaveIfError(iConnection.Open(iServerSocket, KConnectionTypeDefault)); // Now we have the iap Id. Use it to connect for the connection TCommDbConnPref connectPref; // Setup preferences connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); // Sets the CommDb ID of the IAP to use for this connection connectPref.SetIapId(iSelectedConnectionId); // Sets direction connectPref.SetDirection(ECommDbConnectionDirectionOutgoing); connectPref.SetBearerSet(iBearerFilter); // Start connection User::LeaveIfError(iConnection.Start(connectPref)); //TInt retval = iConnection.Start(); //User::LeaveIfError(retval); // Set the sessions connection info... RStringPool strPool = iSessionHttp.StringPool(); RHTTPConnectionInfo connInfo = iSessionHttp.ConnectionInfo(); // ...to use our socket server and connection connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal (iServerSocket.Handle())); // ...to use our connection connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection)))); iConnectionSetup = ETrue; return ETrue; }
CResourceManager::EHttpSessionState CResourceManager::OpenHttpSessionIfNeededL(void* aKernel) { if (!m_IAPSeted || !m_IAPReady) { ((CNBrKernel*)aKernel)->RequestAP(); if (!m_IAPSeted) return ENotSetIAP; if (m_IAPSeted && !m_IAPReady) return ENotReady; } if (!m_sessionRunning) { m_httpSession.OpenL(KHttpProtString); m_sessionRunning = true; RStringPool strP = m_httpSession.StringPool(); const TStringTable& stringTable = RHTTPSession::GetTable(); RHTTPConnectionInfo connInfo = m_httpSession.ConnectionInfo(); if (m_bUseOutNetSettting) { // 使用外壳提供的连接 if (iSocketServ) connInfo.SetPropertyL( strP.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal(iSocketServ->Handle()) ); if (iConnection) connInfo.SetPropertyL( strP.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal(REINTERPRET_CAST(TInt, iConnection)) ); } else { // 使用内部连接 connInfo.SetPropertyL( strP.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal(m_socketServ.Handle())); connInfo.SetPropertyL( strP.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal(REINTERPRET_CAST(TInt, &(m_connection)))); } if (m_isWap) { RStringF iPrxAddr = strP.OpenFStringL(KHttpProxy); CleanupClosePushL(iPrxAddr); THTTPHdrVal iPrxUsage(strP.StringF(HTTP::EUseProxy, RHTTPSession::GetTable())); connInfo.SetPropertyL(strP.StringF(HTTP::EProxyUsage, RHTTPSession::GetTable()), iPrxUsage); connInfo.SetPropertyL(strP.StringF(HTTP::EProxyAddress, RHTTPSession::GetTable()), iPrxAddr); CleanupStack::PopAndDestroy(); } // set shutdown THTTPHdrVal immediateShutdown = strP.StringF(HTTP::ESocketShutdownImmediate, stringTable); connInfo.SetPropertyL(strP.StringF(HTTP::ESocketShutdownMode, stringTable), immediateShutdown); // // set pipelining // RStringF maxConnection = strP.StringF(HTTP::EMaxNumTransportHandlers, stringTable); // connInfo.SetPropertyL(maxConnection, THTTPHdrVal(KHttpMaxConnectionNum)); // // RStringF maxToPipeline = strP.StringF(HTTP::EMaxNumTransactionsToPipeline, stringTable); // connInfo.SetPropertyL(maxToPipeline, THTTPHdrVal(KHttpMaxTransactionNumPerConnection)); // // Set optimal pipelining // RStringF strOptimalPipelineVal = strP.StringF(HTTP::EHttpEnableOptimalPipelining, RHTTPSession::GetTable()); // connInfo.SetPropertyL(strP.StringF(HTTP::EHttpOptimalPipelining, RHTTPSession::GetTable()), strOptimalPipelineVal); // set HTTP receive Buffer Size property // RStringF receiveBuffSize = strP.StringF(HTTP::ERecvBufferSize, stringTable); // connInfo.SetPropertyL(receiveBuffSize, THTTPHdrVal(KHttpReceiveBuffSize)); // // set HTTP batching enable // THTTPHdrVal batchingSupport(strP.StringF(HTTP::EEnableBatching, RHTTPSession::GetTable())); // connInfo.SetPropertyL(strP.StringF(HTTP::EHttpBatching, RHTTPSession::GetTable()), batchingSupport); // // set HTTP batching Buffer Size property // RStringF batchingBuffSize = strP.StringF(HTTP::EBatchingBufferSize, stringTable); // connInfo.SetPropertyL(batchingBuffSize, THTTPHdrVal(KHttpBatchingBuffSize)); RHTTPFilterCollection filtColl = m_httpSession.FilterCollection(); RStringF filterName = m_httpSession.StringPool().StringF(HTTP::ERedirect,RHTTPSession::GetTable()); filtColl.RemoveFilter(filterName); } return EReady; }
void CHTTPSession::ConstructL(const TDesC8& aProtocol, MHTTPFilterCreationCallback* aSessionCallback) { THTTPHdrVal v; iConnectionInfo = CHeaderFieldPart::NewL(v); iManager = CHTTPManager::CreateOrFindL(); // Set the session closing flag session property. This property is a pointer to the // TBool flag (iSessionClosing) used as a flag to indicate when the session is closing. TInt sessionClosingFlagPtr = reinterpret_cast<TInt>(&iSessionClosing); ConnectionInfo().SetPropertyL( (iManager->StringPool()).StringF(HTTP::ESessionClosing, RHTTPSession::GetTable() ), THTTPHdrVal (sessionClosingFlagPtr) ); // Create the protocol handler CreateProtocolHandlerL(aProtocol); // Build filter lists and install mandatory and implicit filters InitializeFiltersL(aProtocol); // If the client requires a callback to be able to configure the filters, call it now if( aSessionCallback != NULL ) { iFilterConfigIter = new(ELeave) TFilterConfigurationIterator(this); } }
// --------------------------------------------------------- // CMmsSession::OpenL // --------------------------------------------------------- // EXPORT_C void CMmsSession::OpenL( const TDesC8& aProxyAddress, const TBool aUseProxy, const TInt32 aMaxReceiveSize, const TInt32 aMaxSendSize, TRequestStatus& aStatus ) { LOG( _L("CMmsSession::OpenL") ); __ASSERT_DEBUG( iSessionStatus == ESessionIdle, gPanic( EMmsAlreadyBusy ) ); iError = KErrNone; iRequestStatus = &aStatus; // // Setting max send/receive sizes. 0 means not limited. // Values always come from CMmsSettings. // iMaxReceiveSize = aMaxReceiveSize; iMaxSendSize = aMaxSendSize; // Get pointer HTTP session headers iSessionHeaders = iHTTPSession.RequestSessionHeadersL(); iHeadersCreated = ETrue; // Check if we are connected already if ( iConnected ) { aStatus = KRequestPending; User::RequestComplete( iRequestStatus, KMmsErrorSessionAlreadyOpen ); } else { // set the session properties // the handle comes from iHTTP session. I think we should not close it. RStringPool strPool = iHTTPSession.StringPool(); RHTTPConnectionInfo connInfo = iHTTPSession.ConnectionInfo(); connInfo.SetPropertyL( strPool.StringF( HTTP::EHttpSocketServ, RHTTPSession::GetTable() ), THTTPHdrVal( iSocketServ->Handle() ) ); TInt connPtr = REINTERPRET_CAST( TInt, iConnection ); connInfo.SetPropertyL( strPool.StringF( HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), THTTPHdrVal( connPtr ) ); // Add proxy usage if requested if ( aUseProxy ) { THTTPHdrVal proxyUsage( strPool.StringF( HTTP::EUseProxy, RHTTPSession::GetTable() ) ); connInfo.SetPropertyL( strPool.StringF( HTTP::EProxyUsage, RHTTPSession::GetTable() ), proxyUsage ); RStringF proxyString = strPool.OpenFStringL( aProxyAddress ); CleanupClosePushL( proxyString ); THTTPHdrVal proxyAddr( proxyString ); connInfo.SetPropertyL( strPool.StringF( HTTP::EProxyAddress, RHTTPSession::GetTable() ), proxyAddr ); CleanupStack::PopAndDestroy( &proxyString ); } // Install MMS X-id header filter if required FeatureManager::InitializeLibL(); if ( FeatureManager::FeatureSupported( KFeatureIdMmsXidHeaderHttpFilter ) ) { // Install the MMS X-id header filter explicitly, since only MMS requires this filter. const TUid KHttpFilterMmsXidHeaderImplementationUid = { 0x1020738D }; CEComFilter::InstallFilterL(iHTTPSession, KHttpFilterMmsXidHeaderImplementationUid); } FeatureManager::UnInitializeLib(); // Install UAProf filter TInt error = KErrNotFound; TRAP( error, CHttpUAProfFilterInterface::InstallFilterL( iHTTPSession ) ); if ( error != KErrNone ) { LOG2( _L("ERROR: UAProf filter left with code %d. Using hardcoded UserAgent string.."), error ); // Manually set UA string SetFixedUserAgentL(); // UserAgent header must be added always - either hard coded string or string from ini file SetHeaderL( iSessionHeaders, HTTP::EUserAgent, iUserAgent->Des() ); // Add UAProf if available if ( iUaProf && iUaProf->Length() > 0 ) { RStringF tempString = strPool.OpenFStringL( iUaProf->Des() ); CleanupClosePushL( tempString ); RStringF tempString2 = strPool.OpenFStringL( KXProfile ); CleanupClosePushL( tempString2 ); iSessionHeaders.SetFieldL( tempString2, tempString ); CleanupStack::PopAndDestroy( &tempString2 ); CleanupStack::PopAndDestroy( &tempString ); } } // Accept headers moved to transaction as global filter overrides // session headers // HTTP session, no need for separate connect procedure iConnected = ETrue; // We may or may not get iHTTPSession.SetSessionEventCallback( this ); aStatus = KRequestPending; User::RequestComplete( iRequestStatus, KErrNone ); } }