예제 #1
0
/**
	Set HTTP proxy information for the session.
	
	@param aProxyAddr [in] Proxy address to set for the session
 */	
void CTestWebBrowser::SetProxyL ( const TDesC8& aProxyAddr )
	{
	
	RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo();
	
	// Set the proxy usage property.
	THTTPHdrVal proxyUsage( iHttpSession.StringPool().StringF( HTTP::EUseProxy, RHTTPSession::GetTable() ) );
	connInfo.SetPropertyL( iHttpSession.StringPool().StringF( HTTP::EProxyUsage, RHTTPSession::GetTable() ), proxyUsage );
	
	RStringF proxyAddr = iHttpSession.StringPool ().OpenFStringL ( aProxyAddr );
	CleanupClosePushL ( proxyAddr );
	
	// Set the proxy address property.
	THTTPHdrVal proxyAddrHdr( proxyAddr );
    connInfo.SetPropertyL( iHttpSession.StringPool().StringF( HTTP::EProxyAddress, RHTTPSession::GetTable() ), proxyAddrHdr );
    
    CleanupStack::PopAndDestroy (); // Pop and destroy proxyAddr
	return;		
	}
예제 #2
0
// ---------------------------------------------------------
// 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 );
        }
    }