httpfilters/httpfilterproxy/Src/HttpFilterProxy.cpp
branchRCL_3
changeset 53 c59bddbfd7b9
parent 40 a0da872af3fa
equal deleted inserted replaced
40:a0da872af3fa 53:c59bddbfd7b9
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <http.h>
    21 #include <http.h>
    22 #include <es_sock.h>
    22 #include <es_sock.h>
    23 #include <cdbstore.h>
    23 #include <cdbstore.h>
    24 #include <commdbconnpref.h>
    24 #include <commdbconnpref.h>
       
    25 
    25 
    26 
    26 // User Includes
    27 // User Includes
    27 #include "HttpFilterProxy.h"
    28 #include "HttpFilterProxy.h"
    28 #include "httpfiltercommonstringsext.h"
    29 #include "httpfiltercommonstringsext.h"
    29 
    30 
   140     iSession->FilterCollection().AddFilterL(*this,   // The filter to add
   141     iSession->FilterCollection().AddFilterL(*this,   // The filter to add
   141                                             THTTPEvent::ESubmit,       // The event that triggers this filter
   142                                             THTTPEvent::ESubmit,       // The event that triggers this filter
   142                                             RStringF(),                // The header whose presence triggers this filter, or KNullDesC to trigger on any header
   143                                             RStringF(),                // The header whose presence triggers this filter, or KNullDesC to trigger on any header
   143                                             KAnyStatusCode,            // The status code that triggers this filter, or KAnyStatusCode to trigger on any status code
   144                                             KAnyStatusCode,            // The status code that triggers this filter, or KAnyStatusCode to trigger on any status code
   144                                             ECache - KProxyOrderOffset,// The position of the filter in the queue
   145                                             ECache - KProxyOrderOffset,// The position of the filter in the queue
   145                                             iStringPool.StringF(HttpFilterCommonStringsExt::EProxyFilter,HttpFilterCommonStringsExt::GetTable()));  //The name of the filter to add
   146                                             iStringPool.StringF(HttpFilterCommonStringsExt::EProxyFilter,RHTTPSession::GetTable()));  //The name of the filter to add
   146 
   147 
   147 	// register for notification of KErrNotReady error codes
   148 	// register for notification of KErrNotReady error codes
   148 	// this allows us to re-start the connection if it fails
   149 	// this allows us to re-start the connection if it fails
   149 	iSession->FilterCollection().AddFilterL(*this, KErrNotReady, MHTTPFilter::ETidyUp -1, iStringPool.StringF(HttpFilterCommonStringsExt::EProxyFilter,HttpFilterCommonStringsExt::GetTable()));
   150 	iSession->FilterCollection().AddFilterL(*this, KErrNotReady, MHTTPFilter::ETidyUp -1, iStringPool.StringF(HttpFilterCommonStringsExt::EProxyFilter,RHTTPSession::GetTable()));
   150 }
   151 }
   151 
   152 
   152 //---------------------------------------------------------------------------------------------
   153 //---------------------------------------------------------------------------------------------
   153 // Destructor
   154 // Destructor
   154 //----------------------------------------------------------------------------------------------
   155 //----------------------------------------------------------------------------------------------
   362                 // Now get the proxy address...
   363                 // Now get the proxy address...
   363                 iProxyAddress = proxyAddressVal.StrF().Copy();
   364                 iProxyAddress = proxyAddressVal.StrF().Copy();
   364                 iUsage = ETrue;
   365                 iUsage = ETrue;
   365             }
   366             }
   366         }
   367         }
   367 //      }
       
   368     }
   368     }
   369 
   369 
   370     // We should not use proxy if the uri matches to one of exceptions from the exception list
   370     // We should not use proxy if the uri matches to one of exceptions from the exception list
   371     // In this case the Origing server will be used
   371     // In this case the Origing server will be used
   372 
   372 
   373     ExcptionsCompare(aTransaction);
   373     ExcptionsCompare(aTransaction);
   374     
       
   375     // Respect proxy settings already defined by client or higher HTTP filter
   374     // Respect proxy settings already defined by client or higher HTTP filter
   376     THTTPHdrVal proxyUsage;  // Check if property present or not present, not the value.
   375     THTTPHdrVal proxyUsage;  // Check if property present or not present, not the value.
   377     if ( !iConnInfo.Property(iStringPool.StringF(HTTP::EProxyUsage,
   376     
   378                             RHTTPSession::GetTable()), proxyUsage)) 
   377     if ( iUsage) 
   379    	{ 
   378    		{ 
   380 
   379        
   381 		// Set the proxy address and proxy Usage
   380 		// Set the proxy address and proxy Usage
   382 		proxyAddress = THTTPHdrVal(iProxyAddress);
   381 		proxyAddress = THTTPHdrVal(iProxyAddress);
   383 
   382 		if (iConnInfo.Property(iStringPool.StringF(HTTP::EProxyUsage,
   384 		iConnInfo.RemoveProperty(iStringPool.StringF(HTTP::EProxyAddress,
   383 		                            RHTTPSession::GetTable()), proxyUsage))
       
   384         	{
       
   385 			iConnInfo.RemoveProperty(iStringPool.StringF(HTTP::EProxyAddress,
   385 		                        RHTTPSession::GetTable()));
   386 		                        RHTTPSession::GetTable()));
   386 		iConnInfo.SetPropertyL(iStringPool.StringF(HTTP::EProxyAddress,
   387 	
   387 		                      RHTTPSession::GetTable()), proxyAddress);
   388 			iConnInfo.RemoveProperty(iStringPool.StringF(HTTP::EProxyUsage,
   388 
       
   389 		iConnInfo.RemoveProperty(iStringPool.StringF(HTTP::EProxyUsage,
       
   390 		                        RHTTPSession::GetTable()));
   389 		                        RHTTPSession::GetTable()));
   391 		if (iUsage)
   390         	}
   392 		{
   391 
   393 		    iConnInfo.SetPropertyL(iStringPool.StringF(HTTP::EProxyUsage,
   392 		iConnInfo.SetPropertyL(iStringPool.StringF(HTTP::EProxyUsage,
   394 		                          RHTTPSession::GetTable()), iStringPool.StringF(HTTP::EUseProxy,
   393 		                          RHTTPSession::GetTable()), iStringPool.StringF(HTTP::EUseProxy,
   395 		                                  RHTTPSession::GetTable()));
   394 		                                  RHTTPSession::GetTable()));
       
   395 	
       
   396 		iConnInfo.SetPropertyL(iStringPool.StringF(HTTP::EProxyAddress,
       
   397 		                                RHTTPSession::GetTable()), proxyAddress);
       
   398 
   396 		}
   399 		}
   397 		else
   400 	else
   398 		{
   401 		{
   399 		    iConnInfo.SetPropertyL(iStringPool.StringF(HTTP::EProxyUsage,
   402 		iConnInfo.SetPropertyL(iStringPool.StringF(HTTP::EProxyUsage,
   400 		                          RHTTPSession::GetTable()), iStringPool.StringF(HTTP::EDoNotUseProxy,
   403 		                          RHTTPSession::GetTable()), iStringPool.StringF(HTTP::EDoNotUseProxy,
   401 		                                  RHTTPSession::GetTable()));
   404 		                                  RHTTPSession::GetTable()));
       
   405 		iConnInfo.RemoveProperty(iStringPool.StringF(HTTP::EProxyAddress,
       
   406 		                                    RHTTPSession::GetTable()));
       
   407 		    
   402 		}
   408 		}
   403     	
   409     	
   404    	}  
       
   405     
   410     
   406 
   411 
   407     // Cleanup strings.
   412     // Cleanup strings.
   408     iProxyAddress.Close();
   413     iProxyAddress.Close();
   409     iExceptions.Close();
   414     iExceptions.Close();