Hi,

I try to implement an HTTP filter based on MHTTPFilter:

In order to do that, I have created an extension of MHHTPFilter that implements the virtual methods as follows:

in *.h

#include <http\MHTTPFilter.h>

...

class CMyHttpFilter;

...

private:

...

CMyHttpFilter iFilter;

...

class CMyHttpFilter: public CBase, public MHTTPFilter
{

public:

virtual ~CMyHttpFilter();

static CMyHttpFilter* NewLC();

static CMyHttpFilter* NewL();

virtual void MHFUnload(RHTTPSession aSession, THTTPFilterHandle aHandle);

virtual void MHFLoad(RHTTPSession aSession, THTTPFilterHandle aHandle);

virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent);

virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent &aEvent);

virtual void MHFSessionRunL(const THTTPSessionEvent &aEvent);

virtual TInt MHFSessionRunError(TInt aError, const THTTPSessionEvent &aEvent);

protected:

CMyHttpFilter();

void ConstructL();

};


In the *.cpp file I specify the Filter and use it in the main code as follows:

In the main ConstructL():


iSess.OpenL();

iFilterName = iSess.StringPool().StringF(HTTP::EClient,RHTTPSession::GetTable());

iSess.FilterCollection().AddFilterL(iFilter, THTTPEvent::EAll, MHTTPFilter::EClient, iFilterName);


In my destructor:

iSess.FilterCollection().RemoveFilter(iFilterName);

iSess.Close();



CMyHttpFilter::CMyHttpFilter()

{

}



CMyHttpFilter::~CMyHttpFilter()

{

}

CMyHttpFilter* CMyHttpFilter::NewLC()

{

CMyHttpFilter* me = new(ELeave) CMyHttpFilter();

CleanupStack::PushL(me);

me->ConstructL();

return me;

}

CMyHttpFilter* CMyHttpFilter::NewL()

{

CMyHttpFilter* me = NewLC();

CleanupStack::Pop(me);

return me;

}

void CMyHttpFilter::ConstructL()

{

}

void CMyHttpFilter::MHFUnload(RHTTPSession aSession, THTTPFilterHandle aHandle)

{

return;

}

void CMyHttpFilter::MHFLoad(RHTTPSession aSession, THTTPFilterHandle aHandle)

{

return;

}



void CMyHttpFilter::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent)

{

return;

}

TInt CMyHttpFilter::MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent &aEvent)

{

return KErrNone;

}

void CMyHttpFilter::MHFSessionRunL(const THTTPSessionEvent &aEvent)

{

return;

}

TInt CMyHttpFilter::MHFSessionRunError(TInt aError, const THTTPSessionEvent &aEvent)

{

return KErrNone;

}


When I compile, it is indicated that the "field 'iFilter' has an incomplete type" ... Any idea....
Otherwise, if somebody has a sample of MHTTPFilter usage... it would be welcome.

Thanks

nprunel