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

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

#1 change response, threading and proxy work-flow

File size: 1.7 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
13#define ERROR_PROXY -10000
14#define ERROR_PROXY_FAILED_TO_RECEIVE_REQUEST ERROR_PROXY - 1
15#define ERROR_PROXY_FAILED_TO_SEND_REQUEST ERROR_PROXY - 2
16#define ERROR_PROXY_FAILED_TO_RECEIVE_RESPONSE ERROR_PROXY - 3
17#define ERROR_PROXY_FAILED_TO_SEND_RESPONSE ERROR_PROXY - 4
18#define ERROR_PROXY_FAILED_TO_CONNECT_TO_SERVER ERROR_PROXY - 5
19#define ERROR_PROXY_FAILED_TO_SET_RESPONSE ERROR_PROXY - 5
20
21typedef enum {
22 CRX_PROXY_STATUS_ERROR = -1,
23 CRX_PROXY_STATUS_IDLE,
24 CRX_PROXY_STATUS_BUSY
25} E_CRX_PROXY_STATUS;
26
27class CRXProxy : public CRXException
28{
29private:
30 CRXSocket mClient;
31 CRXSocket mServer;
32
33 CRXHttpRequest mHttpRequest;
34 CRXHttpResponse mHttpResponse;
35
36 E_CRX_PROXY_STATUS mProxyStatus;
37
38public:
39 CRXProxy (void);
40 ~CRXProxy (void);
41
42 static CRXProxy * GetNewInstance (void);
43
44public:
45 void ReleaseInstance (void);
46
47 void SetClientSocket (const int aSocket);
48 void Close (void);
49
50 int GetStatus (void);
51
52public:
53 int Forward (void);
54
55 void SetHttpRequest (const char * aHttpRequest);
56 char * GetHttpRequest (char * aBuffer,
57 const int aBufferSize) const;
58 int GetHttpRequestLength (void) const;
59
60 void SetHttpResponse (const char * aHttpResponse);
61 char * GetHttpResponse (char * aBuffer,
62 const int aBufferSize) const;
63 int GetHttpResponseLength (void) const;
64
65 int ReceiveRequest (void);
66 int SendRequest (void);
67
68 int ReceiveResponse (void);
69 int SendResponse (void);
70};
71
72#endif // #ifndef __CRXPROXY_H__
Note: See TracBrowser for help on using the repository browser.