// ---------------------------------------------------------------------------- // CWmDrmDlaDefaultHttpManager::SubmitL // Handler for the states EOpen and EReconnect. // ---------------------------------------------------------------------------- void CWmDrmDlaDefaultHttpManager::SubmitL() { LOGFN( "CWmDrmDlaDefaultHttpManager::SubmitL" ); TConnectionInfo info; GetConnectionInfoL( info ); iIapNumber = info.iIapId; // Close old session: iHttpSession.Close(); // Open session iHttpSession.OpenL(); RStringPool pool = iHttpSession.StringPool(); // Associate HTTP session with connection RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo(); // Specify socket server SET_HTTP_PROPERTY( connInfo, pool, HTTP::EHttpSocketServ, iSocketServer.Handle() ); // Specify connectionn to use TInt connPtr = reinterpret_cast<TInt>(&iConnection); SET_HTTP_PROPERTY( connInfo, pool, HTTP::EHttpSocketConnection, connPtr ); // Install HTTP authentication filter InstallAuthenticationL( iHttpSession ); CHttpCookieFilter::InstallFilterL( iHttpSession ); RHTTPFilterCollection filterColl = iHttpSession.FilterCollection(); filterColl.RemoveFilter( iHttpSession.StringPool().StringF( HTTP::ERedirect, RHTTPSession::GetTable() ) ); CHttpUAProfFilterInterface::InstallFilterL( iHttpSession ); // Parse URI TUriParser8 srcAddress; User::LeaveIfError( srcAddress.Parse( *iSrcAddress ) ); // Open HTTP transaction iHttpTransaction = iHttpSession.OpenTransactionL( srcAddress, *this, HTTP_STRING( (EGet == iOperation) ? HTTP::EGET : HTTP::EPOST ) ); iTransactionOpen = ETrue; // Set the data supplier if a POST operation if ( EPost == iOperation ) { iHttpTransaction.Request().SetBody( *iDataSupplier ); } TInt pos = iSrcAddress->Locate( '?' ); // If no query ('?') pos is rightmost character pos = (pos != KErrNotFound) ? pos : iSrcAddress->Length(); TPtrC8 ptrUrl = iSrcAddress->Left( pos ); // Only print if there is a ('?') and something to print after it if ( pos < iSrcAddress->Length() ) { TPtrC8 ptrQs = iSrcAddress->Mid( pos ); } // Set HTTP headers for the transaction RHTTPHeaders hdr = iHttpTransaction.Request().GetHeaderCollection(); TInt nofheaders = iHdrValues.Count(); for ( TInt i = 0; i < nofheaders; i++ ) { TInt field = iHdrFields[i]; const TDesC8& fieldStr = HTTP_STRING( field ).DesC(); HBufC8* pValue = iHdrValues[i]; SetHeaderL( hdr, field, *pValue ); } // Submit HTTP transaction // This will set in motion the HTTP download iHttpTransaction.SubmitL(); iState = ESubmit; }
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; }