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

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

#1 a interface to set timeout to server socket is added to CRXProxy

File size: 2.2 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:
[20]26 CRXSocket mClient;
[24]27 CRXSocket mServer;
[18]28
[36]29 int mServerTimeout;
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);
[36]47 void SetServerTimeout (const int aTimeout = TCPSOCKET_NO_TIMEOUT);
[24]48 void Close (void);
49
[28]50public:
51 /* interface to filter */
52 void SetRequestFilter (const E_CRX_FILTER_REQUEST aType,
53 const bool aIsMatched,
54 const std::string aValue);
55 void RemoveRequestFilter (const E_CRX_FILTER_REQUEST aType);
56 bool CheckRequestFilter (const E_CRX_FILTER_REQUEST aType);
[24]57
[20]58public:
[28]59 /* for communication */
[24]60 int Forward (void);
61
[36]62 int ReceiveRequest (void);
63 int SendRequest (void);
64
65 int ReceiveResponse (void);
66 int SendResponse (void);
67
68public:
69 /* HTTP data */
[24]70 void SetHttpRequest (const char * aHttpRequest);
71 char * GetHttpRequest (char * aBuffer,
72 const int aBufferSize) const;
73 int GetHttpRequestLength (void) const;
74
75 void SetHttpResponse (const char * aHttpResponse);
[35]76 char * GetHttpResponseHeader (char * aBuffer,
[24]77 const int aBufferSize) const;
[35]78 int GetHttpResponseHeaderLength (void) const;
79 char * GetHttpResponseBody (char * aBuffer,
80 const int aBufferSize) const;
81 int GetHttpResponseBodyLength (void) const;
[24]82
[18]83};
84
85#endif // #ifndef __CRXPROXY_H__
Note: See TracBrowser for help on using the repository browser.