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

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

#1 add filter class

File size: 2.0 KB
Line 
1/**
2 * CRXProxy.h
3 */
4#ifndef __CRXPROXY_H__
5#define __CRXPROXY_H__
6
7#include "CRXException.h"
8#include "CRXSocket.h"
9#include "CRXHttpMessage.h"
10#include "CRXHttpRequest.h"
11#include "CRXHttpResponse.h"
12#include "CRXFilter.h"
13
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
20#define ERROR_PROXY_FAILED_TO_SET_RESPONSE ERROR_PROXY - 6
21
22
23class CRXProxy : public CRXException
24{
25private:
26 bool mIsIntercepted;
27
28 CRXSocket mClient;
29 CRXSocket mServer;
30
31 CRXHttpRequest mHttpRequest;
32 CRXHttpResponse mHttpResponse;
33
34 static CRXFilter mFilter;
35
36public:
37 CRXProxy (void);
38 ~CRXProxy (void);
39
40 static CRXProxy * GetNewInstance (void);
41
42public:
43 /* common utilities */
44 void ReleaseInstance (void);
45
46 void SetClientSocket (const int aSocket);
47 void Close (void);
48
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);
56
57public:
58 /* for communication */
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);
76};
77
78#endif // #ifndef __CRXPROXY_H__
Note: See TracBrowser for help on using the repository browser.