httpfilters/cookie/FilterSrc/CookieFilter.cpp
changeset 27 974c3ee9bf20
parent 0 b16258d2340f
equal deleted inserted replaced
23:ea9c9681bbaf 27:974c3ee9bf20
    32 const TInt KCookieFilterStackPosition = MHTTPFilter::EStatusCodeHandler - 10;
    32 const TInt KCookieFilterStackPosition = MHTTPFilter::EStatusCodeHandler - 10;
    33 _LIT8(KVersionValue, "$Version=1");
    33 _LIT8(KVersionValue, "$Version=1");
    34 _LIT8(KEmpty, "");
    34 _LIT8(KEmpty, "");
    35 _LIT8( KCookieUsage, "CookiesEnabled" );
    35 _LIT8( KCookieUsage, "CookiesEnabled" );
    36 _LIT8( KAppUid, "Appuid" );
    36 _LIT8( KAppUid, "Appuid" );
       
    37 _LIT8( KHttpConnectMethod, "CONNECT");
       
    38 _LIT8( KSecureHttpScheme, "https://");
       
    39 const TInt KSecureHttpSchemeLength = 8;
    37 
    40 
    38 // ---------------------------------------------------------
    41 // ---------------------------------------------------------
    39 // CCookieFilter::InstallFilterL
    42 // CCookieFilter::InstallFilterL
    40 // ---------------------------------------------------------
    43 // ---------------------------------------------------------
    41 //
    44 //
   246 	reqHeaders.RemoveField( iStringPool.StringF( HTTP::ECookie2,
   249 	reqHeaders.RemoveField( iStringPool.StringF( HTTP::ECookie2,
   247 												iStringTable ) );
   250 												iStringTable ) );
   248 
   251 
   249 	TBool cookie2Reqd = EFalse;
   252 	TBool cookie2Reqd = EFalse;
   250 	RPointerArray<CCookie> cookies(20);
   253 	RPointerArray<CCookie> cookies(20);
       
   254     HBufC8* requestUriBuf( NULL );
   251 	TPtrC8 requestUri( aTransaction.Request().URI().UriDes() );
   255 	TPtrC8 requestUri( aTransaction.Request().URI().UriDes() );
   252 
   256     TPtrC8 requestMethod( aTransaction.Request().Method().DesC() );
       
   257     if( (requestMethod.CompareF(KHttpConnectMethod) == 0) && (requestUri.Left(KSecureHttpSchemeLength).CompareF(KSecureHttpScheme) == 0))
       
   258         {
       
   259         // if we are performing an HTTP CONNECT to create tunnel for original https:// request, we
       
   260         // should not include secure cookies in this HTTP request since they will be in clear text.
       
   261         // to ensure that Cookie manager does not add these into cookie array, change scheme so
       
   262         // it appears as non-secure transaction
       
   263         requestUriBuf = requestUri.Alloc();
       
   264         CleanupStack::PushL(requestUriBuf);        
       
   265         TPtr8 requestUriPtr = requestUriBuf->Des();
       
   266         requestUriPtr.Delete(4, 1);  // remove char in pos 4 to change https:// to http:// 
       
   267         requestUri.Set(requestUriPtr);
       
   268         }
   253 	TBool ret;
   269 	TBool ret;
   254 	RStringF appuid = iStringPool.OpenFStringL( KAppUid );
   270 	RStringF appuid = iStringPool.OpenFStringL( KAppUid );
   255 	THTTPHdrVal hdrVal;
   271 	THTTPHdrVal hdrVal;
   256 	TUint32 appuidValue (0);
   272 	TUint32 appuidValue (0);
   257 	
   273 	
   258 	ret = aTransaction.PropertySet().Property(appuid,hdrVal);
   274 	ret = aTransaction.PropertySet().Property(appuid,hdrVal);
   259 	if(ret)
   275 	if(ret)
   260 	    {
   276 	    {
   261     	appuidValue = hdrVal.Int();    	       
   277     	appuidValue = hdrVal.Int();    	       
   262 	    }
   278 	    }
   263 	iCookieManager.SetAppUidL(appuidValue); 
   279 	//iCookieManager.SetAppUidL(appuidValue); 
   264     appuid.Close();
   280     appuid.Close();
   265     
   281     
   266     iCookieManager.GetCookiesL( requestUri, cookies, cookie2Reqd );
   282     iCookieManager.GetCookiesL( requestUri, cookies, cookie2Reqd,appuidValue );
       
   283     if( requestUriBuf )
       
   284         {
       
   285         CleanupStack::PopAndDestroy( requestUriBuf );
       
   286         }
   267 
   287 
   268 	TInt numCookies = cookies.Count();
   288 	TInt numCookies = cookies.Count();
   269 	for ( TInt ii = 0; ii < numCookies; ++ii )
   289 	for ( TInt ii = 0; ii < numCookies; ++ii )
   270         {
   290         {
   271 		cookies[ii]->AddToRequestL( reqHeaders, ii );
   291 		cookies[ii]->AddToRequestL( reqHeaders, ii );
   341     	ret = aTransaction.PropertySet().Property(appuid,hdrVal);
   361     	ret = aTransaction.PropertySet().Property(appuid,hdrVal);
   342     	if(ret)
   362     	if(ret)
   343     	    {
   363     	    {
   344     	    appuidValue = hdrVal.Int();                                     
   364     	    appuidValue = hdrVal.Int();                                     
   345     	    }	
   365     	    }	
   346         iCookieManager.SetAppUidL(appuidValue);    
   366         //iCookieManager.SetAppUidL(appuidValue);    
   347         appuid.Close();       
   367         appuid.Close();       
   348         
   368         
   349 		User::LeaveIfError( iCookieManager.StoreCookie( *cookie,
   369 		User::LeaveIfError( iCookieManager.StoreCookie( *cookie,
   350 														requestUri ) );
   370 														requestUri,appuidValue ) );
   351 
   371 
   352 		CleanupStack::PopAndDestroy();	// cookie
   372 		CleanupStack::PopAndDestroy();	// cookie
   353         }
   373         }
   354 
   374 
   355     CLOG( ( EFilter, 0,
   375     CLOG( ( EFilter, 0,