source: cheroxy/trunk/include/CRXProxy.h@ 28

Last change on this file since 28 was 28, checked in by cheese, 12 years ago

#1 add filter class

File size: 2.0 KB
RevLine 
[18]1/**
2 * CRXProxy.h
3 */
4#ifndef __CRXPROXY_H__
5#define __CRXPROXY_H__
6
7#include "CRXException.h"
[24]8#include "CRXSocket.h"
9#include "CRXHttpMessage.h"
10#include "CRXHttpRequest.h"
11#include "CRXHttpResponse.h"
[28]12#include "CRXFilter.h"
[18]13
[24]14#define ERROR_PROXY -10000
15#define ERROR_PROXY_FAILED_TO_RECEIVE_REQUEST ERROR_PROXY - 1
16#define ERROR_PROXY_FAILED_TO_SEND_REQUEST ERROR_PROXY - 2
17#define ERROR_PROXY_FAILED_TO_RECEIVE_RESPONSE ERROR_PROXY - 3
18#define ERROR_PROXY_FAILED_TO_SEND_RESPONSE ERROR_PROXY - 4
19#define ERROR_PROXY_FAILED_TO_CONNECT_TO_SERVER ERROR_PROXY - 5
[28]20#define ERROR_PROXY_FAILED_TO_SET_RESPONSE ERROR_PROXY - 6
[18]21
[24]22
[18]23class CRXProxy : public CRXException
24{
25private:
[28]26 bool mIsIntercepted;
27
[20]28 CRXSocket mClient;
[24]29 CRXSocket mServer;
[18]30
[24]31 CRXHttpRequest mHttpRequest;
32 CRXHttpResponse mHttpResponse;
33
[28]34 static CRXFilter mFilter;
[24]35
[18]36public:
[24]37 CRXProxy (void);
38 ~CRXProxy (void);
[18]39
[24]40 static CRXProxy * GetNewInstance (void);
41
[18]42public:
[28]43 /* common utilities */
[24]44 void ReleaseInstance (void);
[20]45
[24]46 void SetClientSocket (const int aSocket);
47 void Close (void);
48
[28]49public:
50 /* interface to filter */
51 void SetRequestFilter (const E_CRX_FILTER_REQUEST aType,
52 const bool aIsMatched,
53 const std::string aValue);
54 void RemoveRequestFilter (const E_CRX_FILTER_REQUEST aType);
55 bool CheckRequestFilter (const E_CRX_FILTER_REQUEST aType);
[24]56
[20]57public:
[28]58 /* for communication */
[24]59 int Forward (void);
60
61 void SetHttpRequest (const char * aHttpRequest);
62 char * GetHttpRequest (char * aBuffer,
63 const int aBufferSize) const;
64 int GetHttpRequestLength (void) const;
65
66 void SetHttpResponse (const char * aHttpResponse);
67 char * GetHttpResponse (char * aBuffer,
68 const int aBufferSize) const;
69 int GetHttpResponseLength (void) const;
70
71 int ReceiveRequest (void);
72 int SendRequest (void);
73
74 int ReceiveResponse (void);
75 int SendResponse (void);
[18]76};
77
78#endif // #ifndef __CRXPROXY_H__
Note: See TracBrowser for help on using the repository browser.