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++; } }
/** Create a new transaction. Generate the full uri from a partial uri. Also, generates the file path where the contents to be saved. Adds the transaction object into array. @param aUri [in] URI to download. @param aParseHtml [in] Parse the downloaded HTML content. Default value: EFalse. ETrue value to parse the HTML content. Typically the value will be set to ETrue only for the main page. */ void CTestWebBrowser::CreateTransactionL ( const TDesC8& aUri, TBool aParseHtml /* = EFalse */ ) { TUriParser8 baseUri; baseUri.Parse ( iBaseUri->Des() ); TUriParser8 refUri; refUri.Parse ( aUri ); // Resolve uri CUri8* uriPtr = CUri8::ResolveL( baseUri, refUri ); CleanupStack::PushL ( uriPtr ); // Generate the file path from the full http uri. HBufC* filePath = GenerateFilePathL ( uriPtr->Uri() ); CleanupStack::PushL ( filePath ); // Create a new HTTP transaction object. CBrowserTransaction* newTrans = CBrowserTransaction::NewL ( iHttpSession, iTestUtils, this, *filePath, aParseHtml ); CleanupStack::PopAndDestroy ( filePath ); CleanupStack::PushL ( newTrans ); iTransArray.AppendL ( newTrans ); // Open and submit the transaction. newTrans->CreateTransactionL ( uriPtr->Uri().UriDes() ); newTrans->StartTransactionL (); CleanupStack::Pop ( newTrans ); CleanupStack::PopAndDestroy ( uriPtr ); return; }
// ----------------------------------------------------------------------------- // 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; }
void CMCETestUIEngineOutRefer::FillProfileRegistrar() { // trying to get profile registrar TUriParser8 parser; const TDesC8& aor = iProfile->Aor(); parser.Parse( aor ) ; CUri8* uri8 = CUri8::NewLC( parser ); const TDesC8& registrar = uri8->Uri().Extract( EUriHost ) ; HBufC*registrar16 = HBufC16::NewLC( KRecipent().Length() + registrar.Length() ); TPtr registrarPtr = registrar16->Des(); registrarPtr.Copy( registrar ); iReferParams.iRecipentAddress.Append(KRecipent) ; iReferParams.iRecipentAddress.Append(*registrar16) ; iReferParams.iReferTo.Append(KRecipent) ; iReferParams.iReferTo.Append(*registrar16) ; CleanupStack::PopAndDestroy( registrar16 ); registrar16 = NULL; CleanupStack::PopAndDestroy( uri8 ); uri8 = NULL; // profile registrar end ..... }
void UT_CMceEventReferMoEstablishedState::SetupFullL( ) { iEventState = 0; iReceived = 0; iState = new( ELeave ) CMceEventReferMoEstablishedState(); SIPStrings::OpenL(); iSipProfile = CSIPProfile::NewL(); iConnection = CMceSipConnection::NewL( *iSipProfile ); iSIPEvent = CMceSipEvent::NewL( *iConnection, *this ); iSIPEvent->SetEventStateType( EMoRefer ); MCE_DELETE( iSIPEvent->iEvent ); iEvent = CMceComEvent::NewL( *iSIPEvent, KDefaultExpires ); iSIPEvent->iEvent = iEvent; iSIPEvent->SetCurrentState( KMceEstablishedEventStateIndex ); // create dialog CSIPReferDialogAssoc* referDlg = CSIPReferDialogAssoc::NewL(); iSIPEvent->SetDialog( referDlg ); // Create server transaction CSIPServerTransaction* serverTran = CSIPServerTransaction::NewL(); serverTran->SetType( 3 ); // NOTIFY iSIPEvent->iRequest = serverTran; // Create request elements TUriParser8 uriParser; User::LeaveIfError( uriParser.Parse( KRemoteUri() ) ); CUri8* remoteUri = CUri8::NewL(uriParser); CleanupStack::PushL(remoteUri); CSIPRequestElements* elem =CSIPRequestElements::NewL( remoteUri ); CleanupStack::Pop( remoteUri ); serverTran->SetRequestElements( elem ); iMsgElem = &elem->MessageElements(); }
//Parse the URI void CExampleInetProtUtil::ParseUriL() { //Create a Uri _LIT(KText6, "\n\n\nParsing the Uri for....\n"); iConsole->Printf ( KText6 ); _LIT(KFullUriName,"K:\\ws\\direct\\direct.mmp"); TBuf<40> desFullUriName(KFullUriName); iConsole->Printf ( desFullUriName ); //Convert from Unicode format to UTF-8 format HBufC8* convert8 = EscapeUtils::ConvertFromUnicodeToUtf8L(desFullUriName); TUriParser8 parser; //Parse the Uri TInt errResult = parser.Parse(*convert8); if (errResult==KErrNone) { _LIT(KTextParsing, "\nThis Uri has been parsed successfully"); iConsole->Printf ( KTextParsing ); } delete convert8; iConsole->Getch(); }
void CHttpTestCaseGet12::OpenTestSessionL() { iSession.OpenL(); iEngine->Utils().LogIt(_L("Session Created(Iteration 2 Get Test 12)")); iEngine->Utils().LogIt(_L("Session parameters: Default")); InstallAuthenticationL(iSession); iMyStrP = iSession.StringPool(); // Literals used in the function _LIT8(KUrlPath, "/http_tests/rc/401/private/index.html"); // Replace the host name in the URL HBufC8* newUrl8 = TSrvAddrVal::ReplaceHostNameL(KWapTestIPSection(), iIniSettingsFile); CleanupStack::PushL(newUrl8); TPtr8 newUrlPtr8 = newUrl8->Des(); newUrlPtr8.Append(KUrlPath()); TUriParser8 testURI; testURI.Parse(newUrlPtr8); iTransaction = iSession.OpenTransactionL(testURI, *this, iMyStrP.StringF(HTTP::EGET,RHTTPSession::GetTable())); iEngine->Utils().LogIt(_L("Transaction Created in Session")); iOpenTransactionCount++; //Get a handle of the request in iTransaction RHTTPRequest myRequest = iTransaction.Request(); RHTTPHeaders myHeaders = myRequest.GetHeaderCollection(); //provide some headers THTTPHdrVal acceptHdr(iMyStrP.StringF(HTTP::EAnyAny, RHTTPSession::GetTable())); myHeaders.SetFieldL(iMyStrP.StringF(HTTP::EAccept, RHTTPSession::GetTable()),acceptHdr); TSrvAddrVal::LogUsing8BitDesL(iEngine, newUrlPtr8); iEngine->Utils().LogIt(_L("Method:GET")); CleanupStack::PopAndDestroy(newUrl8); }
void CXmlHandler::ExecuteL() { __ASSERT_ALWAYS(iModel.iState == eStateComplete, User::Panic(KModuleName, EAlreadyRunning)); __ASSERT_ALWAYS(iModel.iQuery.iSearch != NULL, User::Panic(KModuleName, ENoQueryTerm)); iModel.iState = eStateStarting; // next create a http transaction TUriParser8 uri; uri.Parse(KMpowerUrl); // Set the transaction method to post as we will be submitting an xml soap request RStringF method = iSession.StringPool().StringF(HTTP::EPOST, RHTTPSession::GetTable()); iTransaction.Close(); iTransaction = iSession.OpenTransactionL(uri, *this, method); // Set headers for request; user agent, accepted content type and body's content type. AddRequestHeaderL(HTTP::EUserAgent, KUserAgent); AddRequestHeaderL(HTTP::EAccept, KAccept); AddRequestHeaderL(HTTP::EContentType, KPlainText); // set the body text handler iTransaction.Request().SetBody(*this); // and start it iTransaction.SubmitL(); iModel.iState = eStateConnecting; }
COCSPTransportDefault::TTransportScheme COCSPTransportDefault::IdentifySchemeL(const TDesC8& aURI) { TTransportScheme ret = ETransportSchemeNotSupported; TUriParser8 uri; TInt error = uri.Parse(aURI); if (error != KErrNone || !uri.IsPresent(EUriScheme)) { return ret; } const TPtrC8 scheme = uri.Extract(EUriScheme); RStringPool stringPool; stringPool.OpenL(); CleanupClosePushL(stringPool); RStringF schemeF = stringPool.OpenFStringL(scheme); CleanupClosePushL(schemeF); RStringF httpF = stringPool.OpenFStringL(KHttpString); CleanupClosePushL(httpF); if (schemeF == httpF) { ret = ETransportSchemeHTTP; } CleanupStack::PopAndDestroy(3); // close httpF, schemeF, stringPool return ret; }
// ---------------------------------------------------------------------------- // CClientEngine::IssueHTTPGetL() // // Start a new HTTP GET transaction. // ---------------------------------------------------------------------------- void CClientEngine::IssueHTTPGetL(const TDesC8& aUri) { SetupConnectionL(); // Parse string to URI (as defined in RFC2396) TUriParser8 uri; uri.Parse(aUri); // Get request method string for HTTP GET RStringF method = iSession.StringPool().StringF(HTTP::EGET, RHTTPSession::GetTable()); // Open transaction with previous method and parsed uri. This class will // receive transaction events in MHFRunL and MHFRunError. iTransaction = iSession.OpenTransactionL(uri, *this, method); // Set headers for request; user agent and accepted content type RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection(); SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); SetHeaderL(hdr, HTTP::EAccept, KAccept); // Submit the transaction. After this the framework will give transaction // events via MHFRunL and MHFRunError. iTransaction.SubmitL(); iRunning = ETrue; _LIT(KConnecting,"Connecting..."); iObserver.ClientEvent(KConnecting); }
//--------------------------------------------------------------- // CNativeMmsUtility::resolvedByContentIdL // @see header //--------------------------------------------------------------- TBool CNativeMmsUtility::resolvedByContentIdL(const TPtrC8& contentidptr, const CUri16& targeturi) { #ifdef _DEBUG_TRACES_ qDebug() << " Enter CNativeMmsUtility::resolvedByContentIdL"; #endif TBool result = EFalse; TUriParser8 parser; CUri16* contIdUri = NULL; HBufC8* contentId = NULL; //get content-id uri if (contentidptr.Length()) { //Copy string to 8-bit descriptor contentId = HBufC8::NewLC(contentidptr.Length()); if (contentId->Find(KCidLeftAngle) == 0 && contentId->Find(KCidRightAngle) == contentId->Length() - 1) { // When comparing against cid, remove "<" and ">" contentId->Des().Copy(contentidptr.Mid(1, contentidptr.Length() - 2)); } else { contentId->Des().Copy(contentidptr); } parser.Parse(*contentId); contIdUri = UriUtils::ConvertToDisplayFormL(parser); CleanupStack::PushL(contIdUri); } //compare content-id against the target uri if ( (contentidptr.Length()) && (targeturi.Uri().UriDes().CompareF(contIdUri->Uri().UriDes()) == 0)) { #ifdef _DEBUG_TRACES_ qDebug() << " Exit CNativeMmsUtility::resolvedByContentIdL"; #endif result = ETrue; } //do some cleanup if (contentId) { CleanupStack::PopAndDestroy(2, contentId); // contentId, contIdUri } #ifdef _DEBUG_TRACES_ qDebug() << " Exit CNativeMmsUtility::resolvedByContentIdL"; #endif return result; }
void CTestMessageComposer::ConstructL() { iSession.OpenL(); iStringPool = iSession.StringPool(); iMessageComposer.OpenL(*this); TUriParser8 up; up.Parse(KUri); iTransaction = iSession.OpenTransactionL(up, *this, iSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable())); }
void CHttpClientTransactionImpl::ConstructL(CHttpService& aClient, const TDesC8& aMethod, const TDesC8& aUri) { TUriParser8 parser; User::LeaveIfError(parser.Parse(aUri)); RHTTPSession sess = aClient.Session(); RStringF method = iStringPool.OpenFStringL(aMethod); CleanupClosePushL(method); iTransaction = sess.OpenTransactionL(parser, *this, method); CleanupStack::PopAndDestroy(); // method }
RHTTPTransaction CINC052596::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) { __ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant()); 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); }
// ---------------------------------------------------------------------------- // CURIContainer::CreateUri8L // ---------------------------------------------------------------------------- // CUri8* CURIContainer::CreateUri8L(const TDesC8& aValue) { TUriParser8 parser; User::LeaveIfError(parser.Parse(aValue)); TPtrC8 scheme(parser.Extract(EUriScheme)); if (scheme.CompareF(SIPStrings::StringF(SipStrConsts::ESip).DesC()) == 0) { User::LeaveIfError(parser.Validate()); } return CUri8::NewL(parser); }
void CHttpController::SendRequestL( TInt aMethodIndex, const TDesC8& aUri, CHttpHeaders* aHeaders ) { if ( !iObserver ) { User::Leave( KErrHttpInvalidObserver ); } RStringF method = iSession.StringPool().StringF( aMethodIndex, RHTTPSession::GetTable() ); TUriParser8 uri; uri.Parse( aUri ); iTransaction = iSession.OpenTransactionL( uri, *this, method ); RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection(); RArray< TInt > addedElements; CleanupClosePushL( addedElements ); SetHeaderL( HTTP::EUserAgent, hdr, KUserAgent, addedElements ); SetHeaderL( HTTP::EConnection, hdr, KClose, addedElements ); SetHeaderL( HTTP::EAccept, hdr, KAccept, addedElements ); SetHeaderL( HTTP::EHost, hdr, uri.Extract( EUriHost ), addedElements ); TInt count( iPersistentHeaders->Count() ); for ( TInt i( 0 ); i < count; ++i ) { if ( addedElements.FindInOrder( i ) >= 0 ) { continue; } SetHeaderL( hdr, iPersistentHeaders->Key( i ), iPersistentHeaders->Value( i ) ); } CleanupStack::PopAndDestroy( &addedElements ); if ( aHeaders ) { TInt count( aHeaders->Count() ); for ( TInt i( 0 ); i < count; ++i ) { SetHeaderL( hdr, aHeaders->Key( i ), aHeaders->Value( i ) ); } } if ( aMethodIndex == HTTP::EPOST ) { const TInt KMaxContentLenBufferLength = 100; TBuf8< KMaxContentLenBufferLength > contentLength; contentLength.Num( iOutputEncoder->OverallDataSize() ); SetHeaderL( hdr, HTTP::EContentLength, contentLength ); SetHeaderL( hdr, HTTP::EContentType, KUrlEncodedContentType ); iTransaction.Request().SetBody( *iOutputEncoder ); } iTransaction.SubmitL(); StartTimeout(); iState = EHttpActive; }
/** Converts a 16-bit format uri into its internet form. Any Unicode characters are converted into Utf8 representation and then any excluded characters are escape encoded. Reserved characters specified in RFC2396 will not be escape encoded however, these include ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ",". For example http://localhost will not be encoded to http%3A%2F%2Flocalhost. @since 6.0 @deprecated Deprecated in 9.1 @leave KUriUtilsCannotConvert. When the input data cannot be converted. @leave KUriUtilsErr16BitChar. When the input data has a 16-Bit character to be escape encoded. @param aUri The 16-bit format uri. @return A pointer to a newly created 8-bit uri. */ EXPORT_C CUri8* UriUtils::ConvertToInternetFormL(const TUriC16& aUri) { // Need to convert to utf8 HBufC8* utf8Buf = EscapeUtils::ConvertFromUnicodeToUtf8L(aUri.UriDes()); CleanupStack::PushL(utf8Buf); // Ok need to parse for the uri without the fragment TUriParser8 parser; parser.Parse(*utf8Buf); TPtrC8 uriNoFragment; parser.UriWithoutFragment(uriNoFragment); // Now escape encode the uri without the fragment HBufC8* escapedBuf = EscapeUtils::EscapeEncodeL(uriNoFragment, EscapeUtils::EEscapeNormal); CleanupStack::PushL(escapedBuf); // Now escape encode the fragment if there is one... HBufC8* escapedFragmentBuf = NULL; if( parser.IsPresent(EUriFragment) ) { escapedFragmentBuf = EscapeUtils::EscapeEncodeL(parser.Extract(EUriFragment), EscapeUtils::EEscapeNormal); CleanupStack::PushL(escapedFragmentBuf); } // Parse and then create the CUri8 object parser.Parse(*escapedBuf); CUri8* netForm = CUri8::NewL(parser); // Set the fragment if there was one... if( escapedFragmentBuf != NULL ) { CleanupStack::PushL(netForm); netForm->SetComponentL(*escapedFragmentBuf, EUriFragment); CleanupStack::Pop(netForm); CleanupStack::PopAndDestroy(escapedFragmentBuf); } // Cleanup and return CleanupStack::PopAndDestroy(2, utf8Buf); // utf8Buf, escapedBuf return netForm; }
void CHttpTestCase8::DoRunL() { // Literals used in the function _LIT8(KWapTestUrl, "http://WapTestIP/perl/protected/dumpform.pl"); // Replace the host name in the URL HBufC8* newUrl8 = TSrvAddrVal::ReplaceHostNameL(KWapTestUrl(), iIniSettingsFile); CleanupStack::PushL(newUrl8); TPtr8 newUrlPtr8 = newUrl8->Des(); TUriParser8 testURI; testURI.Parse(newUrlPtr8); //open a Session RHTTPSession mySession; mySession.OpenL(); CleanupClosePushL(mySession); iEngine->Utils().LogIt(_L("Session Created(TC8)")); iEngine->Utils().LogIt(_L("Session parameters: Default")); // Install the authorisation plugin. InstallAuthenticationL(mySession); //Get the mySession'string pool handle; iMyStrP = mySession.StringPool(); //Create , open and push in the CS a Transaction in mySession RHTTPTransaction myTransaction; myTransaction = mySession.OpenTransactionL(testURI, *this, mySession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable())); CleanupClosePushL(myTransaction); iEngine->Utils().LogIt(_L("Transaction Created in mySession")); //Get a handle of the request in myTransaction RHTTPRequest myRequest = myTransaction.Request(); RHTTPHeaders myHeaders = myRequest.GetHeaderCollection(); // provide some headers THTTPHdrVal v2(iMyStrP.OpenFStringL(_L8("text/plain"))); THTTPHdrVal v3(iMyStrP.OpenFStringL(_L8("text/html"))); THTTPHdrVal v4(6); myHeaders.SetFieldL(iMyStrP.OpenFStringL(_L8("Accept")),v2 ); myHeaders.SetFieldL(iMyStrP.OpenFStringL(_L8("Content-Type")), v3); myHeaders.SetFieldL(iMyStrP.StringF(HTTP::EContentLength, RHTTPSession::GetTable()),v4); iEngine->Utils().LogIt(_L("Testing Authentication. Method:Post")); myRequest.SetBody(*this); myTransaction.SubmitL(); CActiveScheduler::Start(); myTransaction.Close(); iEngine->Utils().LogIt(_L("Transaction terminated\n")); mySession.Close(); iEngine->Utils().LogIt(_L("Session terminated")); if (iTestFail==1) { User::Leave(-1); } CleanupStack::Pop(2); // mySession,myTansaction CleanupStack::PopAndDestroy(newUrl8); }
void CTextModeTestMultiTransMalformedStatusLine::CreateSingleTransactionL(RStringF aGet) { // create the transaction and submit TUriParser8 urlParser; urlParser.Parse(*iHostName); RHTTPTransaction tr = iSession.OpenTransactionL(urlParser, *this, aGet); CleanupClosePushL(tr); User::LeaveIfError(iTransArray.Append(tr)); CleanupStack::Pop(&tr); tr.SubmitL(); iOpenTransactionCount++; }
// ---------------------------------------------------------------------------- // CSipHeaderStrategyBase::ConvertRequestUriL // ---------------------------------------------------------------------------- // CUri8* CSipHeaderStrategyBase::ConvertRequestUriL( CSIPRequest& aRequest ) { CUri8* uri8 = NULL; __ASSERT_ALWAYS(aRequest.RequestURI(), User::Leave(KErrCorrupt)); HBufC8* temp = aRequest.RequestURI()->ToTextL(); CleanupStack::PushL( temp ); TUriParser8 parser; User::LeaveIfError( parser.Parse( *temp) ); uri8 = CUri8::NewL( parser ); CleanupStack::PopAndDestroy( temp ); return uri8; }
// ----------------------------------------------------------------------------- // LocalHostCheckL // If the host is a local host. Returns ETrue // if the transaction request URI was for a localhost. // ----------------------------------------------------------------------------- // TBool LocalHostCheckL(RHTTPTransaction& aTransaction) { _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) { return ETrue; } return EFalse; }
void CHttpTestCase9::OpenTestSessionL() { // Literals used in the function _LIT8(KWapTestUrl, "http://WapTestIP/perl/wrong_resource.txt"); // Replace the host name in the URL HBufC8* newUrl8 = TSrvAddrVal::ReplaceHostNameL(KWapTestUrl(), iIniSettingsFile); CleanupStack::PushL(newUrl8); TPtr8 newUrlPtr8 = newUrl8->Des(); TUriParser8 testURI; testURI.Parse(newUrlPtr8); //open a Session iSession.OpenL(); iEngine->Utils().LogIt(_L("Session Created(9) (Default parameters")); //Get the iSession'string pool handle; iMyStrP = iSession.StringPool(); //open string this testcase needs RStringF textPlain = iMyStrP.StringF(HTTP::ETextPlain, RHTTPSession::GetTable()); RStringF textHtml = iMyStrP.StringF(HTTP::ETextHtml, RHTTPSession::GetTable()); RStringF mimeType = iMyStrP.StringF(HTTP::EApplicationXWwwFormUrlEncoded, RHTTPSession::GetTable()); //Create , open in the CS a Transaction in iSession iTransaction = iSession.OpenTransactionL(testURI, *this, iMyStrP.StringF(HTTP::EPOST,RHTTPSession::GetTable())); iEngine->Utils().LogIt(_L("Transaction Created in Session")); //Get a handle of the request in iTransaction RHTTPRequest myRequest = iTransaction.Request(); RHTTPHeaders myHeaders = myRequest.GetHeaderCollection(); //provide some headers THTTPHdrVal v2(textPlain); THTTPHdrVal v3(textHtml); THTTPHdrVal v4(6); THTTPHdrVal v5(mimeType); myHeaders.SetFieldL(iMyStrP.StringF(HTTP::EAccept, RHTTPSession::GetTable()),v2); myHeaders.SetFieldL(iMyStrP.StringF(HTTP::EAccept, RHTTPSession::GetTable()),v3); myHeaders.SetFieldL(iMyStrP.StringF(HTTP::EContentLength, RHTTPSession::GetTable()),v4); myHeaders.SetFieldL(iMyStrP.StringF(HTTP::EContentType, RHTTPSession::GetTable()), v5); TSrvAddrVal::LogUsing8BitDesL(iEngine, newUrlPtr8); iEngine->Utils().LogIt(_L("Method:Post")); iEngine->Utils().LogIt(_L("Accept:test/plain,text/html")); iEngine->Utils().LogIt(_L("Content-Type: application/x-www-form-urlencoded")); iEngine->Utils().LogIt(_L("Content-Length: 6")); myRequest.SetBody(*this); CleanupStack::PopAndDestroy(newUrl8); }
void CSTTrackerConnection::HTTPSessionOpenedL(TBool aResult, RHTTPSession& /*aHTTPSession*/) { if (aResult) { // starts listening before connecting to the tracker // TODO this should be called from the torrent / torrentmanager iTorrent.TorrentMgr()->NetworkManager()->StartListeningL( 0, iTorrent.Preferences()->IncomingPort()); CreateUriL(); // Parse string to URI (as defined in RFC2396) TUriParser8 uri; uri.Parse(*iUri); // Get request method string for HTTP GET RStringF method = iSession.StringPool().StringF(HTTP::EGET, RHTTPSession::GetTable()); // Open transaction with previous method and parsed uri. This class will // receive transaction events in MHFRunL and MHFRunError. iTransaction = iSession.OpenTransactionL(uri, *this, method); // Set headers for request; user agent and accepted content type RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection(); SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); SetHeaderL(hdr, HTTP::EAccept, KAccept); // Submit the transaction. After this the framework will give transaction // events via MHFRunL and MHFRunError. LWRITE(iLog, _L("[Trackerconnection] Starting transaction: GET ")); LWRITELN(iLog, *iUri); iTransaction.SubmitL(); iRunning = ETrue; iConnectionTimeout->Reset(KMaxTrackerAnnounceTime * 1000); } else { LWRITE(iLog, _L("[Trackerconnection] Failed ")); if (iObserver) iObserver->TrackerConnectionFailedL(); /*iTorrent.SetFailedL(_L("Failed to establish network connection."));*/ } }
/** 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); }
//--------------------------------------------------------------- // CNativeMmsUtility::resolvedByContentLocL // @see header //--------------------------------------------------------------- TBool CNativeMmsUtility::resolvedByContentLocL(const TPtrC& contentlocptr, const CUri16& targeturi) { #ifdef _DEBUG_TRACES_ qDebug() << " Enter CNativeMmsUtility::resolvedByContentLocL"; #endif TBool result = EFalse; TUriParser8 parser; CUri16* contLocUri = NULL; HBufC8* contentLoc = NULL; //get content-location uri if (contentlocptr.Length()) { //Copy string to 8-bit descriptor contentLoc = HBufC8::NewLC(contentlocptr.Length()); contentLoc->Des().Copy(contentlocptr); parser.Parse(*contentLoc); contLocUri = UriUtils::ConvertToDisplayFormL(parser); CleanupStack::PushL(contLocUri); } //compare content-loc against the target uri if ( (contentlocptr.Length()) && (targeturi.Uri().UriDes().CompareF(contLocUri->Uri().UriDes()) == 0)) { #ifdef _DEBUG_TRACES_ qDebug() << " Exit CNativeMmsUtility::resolvedByContentLocL"; #endif result = ETrue; } //do some cleanup if (contentLoc) { CleanupStack::PopAndDestroy(2, contentLoc); // contentLoc, contLocUri } #ifdef _DEBUG_TRACES_ qDebug() << " Exit CNativeMmsUtility::resolvedByContentLocL"; #endif return result; }
/** Create a new CUri8 object from a Unicode descriptor. @param aUri a Unicode string containing the URI to parse. @return the new CUri8 object @leave EUriUtilsParserErrInvalidUri if the descriptor is an invalid URI. */ EXPORT_C CUri8* UriUtils::CreateUriL(const TDesC& aUri) { // convert to UTF8 HBufC8* unsafe8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aUri); CleanupStack::PushL(unsafe8); // escape encode only those characters that cannot be in a URI. assume all %hh are %encoded already HBufC8* uri8desc = EscapeUtils::ReEscapeEncodeL(*unsafe8); CleanupStack::PopAndDestroy(unsafe8); CleanupStack::PushL(uri8desc); TUriParser8 parser; // parse the descriptor into a URI, Leave if it cannot be parsed User::LeaveIfError( parser.Parse(*uri8desc) ); CUri8* uri8 = CUri8::NewL(parser); CleanupStack::PopAndDestroy(uri8desc); return uri8; }
RHTTPTransaction CPipeliningConfigTest::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) { if (aIndex >= iTransactionUris.Count()) { User::Invariant(); } CheckAndSetSessionSettingsL(aSession); RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()); TUriParser8 uri; uri.Parse(*(iTransactionUris[aIndex])); return aSession.OpenTransactionL(uri, aClient, method); }
RHTTPTransaction CTestCase21::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) { __ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant()); RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()); _LIT8(KTxtUri, "http://127.0.0.1"); TUriParser8 uri; uri.Parse(KTxtUri()); // Buffer size needs to be reduced in the session property before the first transaction. if( aIndex == 0 ) { RHTTPConnectionInfo connInfo = aSession.ConnectionInfo(); connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EBatchingBufferSize,RHTTPSession::GetTable()), KBufferSize); } return aSession.OpenTransactionL(uri, aClient, method); }
RHTTPTransaction CTestCase2::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) { __ASSERT_ALWAYS(aIndex<TotalTransactionCount(), User::Invariant()); RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()); _LIT8(KTxtUri, "http://127.0.0.1"); TUriParser8 uri; uri.Parse(KTxtUri()); if( aIndex==2 ) { RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); AddConnectionCloseHeaderL(trans); return trans; } return aSession.OpenTransactionL(uri, aClient, method); }
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); }