Implementing the MHTTPDataOptimiser Interface

To enable support for Web Acceleration, you must implement your own custom encoding and decoding mechanisms by implementing the functions of the interface MHTTPDataOptimiser . The following code illustrates the MHTTPDataOptimiser interface that consists of the EncodeL() and DecodeL() methods:

      
       
      
      class MHTTPDataOptimiser
{

public:

virtual void EncodeL(const TDesC8& aHTTPData, HBufC8*& aEncodedData) = 0;
    
virtual void DecodeL(const TDesC8& aData, HBufC8*& aHTTPData, TBool&     aTransFail) = 0;

};
     

The EncodeL() method

This method converts HTTP request data (to your selected network optimisation protocol format) before it is sent across the TCP connection. This method has the following parameters:

  • aHTTPData: Contains HTTP request data in standard HTTP format.

  • aEncodedData: On return contains encoded HTTP request data in a network optimisation protocol format.

Note: It is assumed that you define a custom optimisation mechanism to encode the HTTP request data by implementing the EncodeL() method.

The DecodeL() method

This method converts the HTTP response data in your selected network optimisation protocol format back to the standard HTTP response data format. This method has the following parameters:

  • aData: Contains the raw data in a network optimisation protocol format received over the TCP connection.

  • aHTTPData: On return of this method the aHTTPData parameter contains the HTTP response data.

  • aTransFail: When you set this parameter value to ETrue it sends the KErrHTTPOptimiserFailsTrans event to the mobile browser application.

Note: In a scenario where the HTTP response data is split across various packets (for example, when the network bandwidth is low), the MHTTPDataOptimiser::DecodeL() method is called for every data packet received. In this scenario, to ensure successful parsing of the HTTP response data, the aTransFail parameter must be set to EFalse for every call made to MHTTPDataOptimiser::DecodeL() , until the final transaction is encountered.