Enabling MHTTPDataOptimiser for a session

You must use the RHTTPSession::SetupHTTPDataOptimiser() function of the RHTTPSession class to enable the MHTTPDataOptimiser implementation for a session. The following code illustrates the RHTTPSession class:

class RHTTPSession 
{
public:
……    

RHTTPSession::SetupHTTPDataOptimiser (MHTTPDataOptimiser& aHTTPOptimiser);

MHTTPDataOptimiser* RHTTPSession::HTTPDataOptimiser ();

};

For a session, if you want to prevent a transaction from using the MHTTPDataOptimiser implementation, see the Overriding the optimiser for a session section.

Note: For more information about how to enable the MHTTPDataOptimiser implementation for a session, see the HTTP Whole Message Filter example section.

Overriding the optimiser for a session

By default, if the MHTTPDataOptimiser implementation is enabled for a session, it applies to all transactions within the session when the MHTTPDataOptimiser implementation is not enabled for individual transactions. In a scenario where you want to prevent a particular transaction (for which MHTTPDataOptimiser implementation is not enabled) of a session from using the MHTTPDataOptimiser implementation of the session, set the EHTTPTransOptimiser property with the value EDisableHTTPTransOptimiser on that transaction.

The following code illustrates how to set the EHTTPTransOptimiser property:

// HTTP session object
RHTTPSession sess; 

// The MHTTPDataOptimiser implementation is enabled for a session.
sess.SetupHttpDataOptimiser(*this); 

// HTTP transaction object
RHTTPTransaction trans = sess.OpenTransactionL(const TUriC8&, MHTTPTransactionCallback&, RStringF);
THTTPHdrVal disableOptimiser(sess.StringPool().StringF(HTTP::EDisableHTTPTransOptimiser,    RHTTPSession::GetTable()));
trans.PropertySet().SetPropertyL(sess.StringPool().StringF(HTTP::EHTTPTransOptimiser,    RHTTPSession::GetTable()), disableOptimiser);