BazisLib::Network::Filters::BasicHTTPFilter Class Reference

Provides functionality for filtering HTTP connections. More...

#include <filter.h>

Inherits BazisLib::Win32::NetworkFilterBase.

Collaboration diagram for BazisLib::Network::Filters::BasicHTTPFilter:

Collaboration graph
[legend]

List of all members.

Classes

class  ConnectionContext
 Used internally to maintain connection context. More...

Public Member Functions

 BasicHTTPFilter ()

Protected Types

enum  Operation { DoNotFilterFile, GetHeaderAndFilter, SkipRequestAndFilter }
enum  { TrackHeadRequests = 0x02 }
enum  { MaximumFirstLineLength = 1024, MaximumHeaderSize = 131072 }

Protected Member Functions

std::string ExtractURLFromRequest (const std::string &HTTPRequestHeader)
 Extracts URL from a HTTP request body.
virtual Operation OnFileRequested (std::string &HTTPRequest, void *pSystemContext)
 Called when a HTTP request is issued.
virtual ManagedPointer< AIFileGetReplacementForFile (const std::string &HTTPRequest, const char *pHTTPReply, void *pSystemContext)
 Called to get a managed file to replace the original HTTP reply.

Protected Attributes

unsigned m_ModeFlags

Private Member Functions

virtual BazisLib::ActionStatus OnStartConnect (BazisLib::Network::_PlatformSpecificInternetAddress *pAddr, void **ppUserContext) override
virtual void OnDisconnect (void *pSystemContext, void *pUserContext) override
virtual size_t OnSend (void *pSystemContext, void *pSystemContext2, void *pBuf, size_t MaxSize, void *pUserContext, bool ForceBlockingMode) override
virtual size_t OnReceive (void *pSystemContext, void *pSystemContext2, void *pBuf, size_t MaxSize, void *pUserContext, bool ForceBlockingMode) override
virtual void FreeUserContext (void *pContext) override


Detailed Description

Provides functionality for filtering HTTP connections.

This class performs analyzis of intercepted network connections, extracts HTTP sessions and parses them in order to extract request headers and reply headers. Basically, it allows doing the following:

One of the applications for such a filter is a download catcher for a download manager. Such a catcher monitors all HTTP connections of a web browser and when it notices a big file being returned by the server, it sends the URL (and the header) to the download manager, and replaces server reply with a message that the file was successfully queued for downloading.

Member Enumeration Documentation

anonymous enum [protected]

Enumerator:
TrackHeadRequests 

anonymous enum [protected]

Enumerator:
MaximumFirstLineLength 
MaximumHeaderSize 

Enumerator:
DoNotFilterFile 
GetHeaderAndFilter 
SkipRequestAndFilter 


Constructor & Destructor Documentation

BazisLib::Network::Filters::BasicHTTPFilter::BasicHTTPFilter (  ) 


Member Function Documentation

std::string BazisLib::Network::Filters::BasicHTTPFilter::ExtractURLFromRequest ( const std::string &  HTTPRequestHeader  )  [inline, protected]

Extracts URL from a HTTP request body.

Here is the call graph for this function:

virtual void BazisLib::Network::Filters::BasicHTTPFilter::FreeUserContext ( void *  pContext  )  [override, private, virtual]

virtual ManagedPointer<AIFile> BazisLib::Network::Filters::BasicHTTPFilter::GetReplacementForFile ( const std::string &  HTTPRequest,
const char *  pHTTPReply,
void *  pSystemContext 
) [inline, protected, virtual]

Called to get a managed file to replace the original HTTP reply.

This method is called after OnFileRequested() call either immediately, or when a HTTP reply is fetched. If the call was immediate (OnFileRequested() returned SkipRequestAndFilter), the pHTTPReply parameter will be NULL, as no reply header is available in that case.

Parameters:
HTTPRequest Contains a HTTP request header (and body, if exists).
pHTTPReply Contains HTTP reply header (and no body). This parameter can be NULL, if SkipRequestAndFilter was returned by OnFileRequested(). Otherwise, it points to a NULL-terminated ASCII string containing the header.

virtual void BazisLib::Network::Filters::BasicHTTPFilter::OnDisconnect ( void *  pSystemContext,
void *  pUserContext 
) [override, private, virtual]

virtual Operation BazisLib::Network::Filters::BasicHTTPFilter::OnFileRequested ( std::string &  HTTPRequest,
void *  pSystemContext 
) [inline, protected, virtual]

Called when a HTTP request is issued.

This method is called by the filter when a HTTP request was detected. Child class can override it.

Parameters:
HTTPRequest Contains HTTP request (header + body, if one exists). Note that in current version modifying HTTPRequest from this method gives no effect, as the header was already sent to the server. In future versions this behaviour may change.
pSystemContext Contains system context that can be used to call OnSend()/OnReceive()/etc Note that in this version calling one of this functions from this handler can make the filter to become unstable if the hooked application uses asynchronous/non-blocking API.
Returns:
If the child class decides not to replace the file by its own content, it returns the DoNotFilterFile value. If it requires reply header to make the final decision, it should return GetHeaderAndFilter. If if is ready to replace the file now, it returns SkipRequestAndFilter. In the last case, the GetReplacementForFile() method will be called immediately after.

virtual size_t BazisLib::Network::Filters::BasicHTTPFilter::OnReceive ( void *  pSystemContext,
void *  pSystemContext2,
void *  pBuf,
size_t  MaxSize,
void *  pUserContext,
bool  ForceBlockingMode 
) [override, private, virtual]

virtual size_t BazisLib::Network::Filters::BasicHTTPFilter::OnSend ( void *  pSystemContext,
void *  pSystemContext2,
void *  pBuf,
size_t  MaxSize,
void *  pUserContext,
bool  ForceBlockingMode 
) [override, private, virtual]

virtual BazisLib::ActionStatus BazisLib::Network::Filters::BasicHTTPFilter::OnStartConnect ( BazisLib::Network::_PlatformSpecificInternetAddress pAddr,
void **  ppUserContext 
) [override, private, virtual]


Member Data Documentation


The documentation for this class was generated from the following file:
SourceForge.net Logo