Changeset 24 in cheroxy for trunk/include


Ignore:
Timestamp:
11/14/12 14:00:40 (12 years ago)
Author:
cheese
Message:

#1 change response, threading and proxy work-flow

Location:
trunk/include
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/CRXException.h

    r19 r24  
    3030
    3131public:
    32     CRXException        (void);
     32    CRXException            (void);
     33    virtual ~CRXException   (void);
    3334
    3435public:
  • trunk/include/CRXHttpMessage.h

    r18 r24  
    1717public:
    1818    CRXHttpMessage              (void);
     19    virtual ~CRXHttpMessage     (void);
    1920
    2021protected:
     
    2526    std::string     GetMessage  (void) const;
    2627
    27     virtual CRXHttpMessage &    operator =              (const char * aHttpMessage);
     28    void            Reset       (void);
     29
     30    virtual CRXHttpMessage &    operator =  (const char * aHttpMessage);
    2831};
    2932
  • trunk/include/CRXHttpRequest.h

    r17 r24  
    2424
    2525public:
    26     void                SetRequest  (const char * aHttpRequest);
    27     std::string         GetRequest  (void) const;
     26    void                SetHeader   (const char * aHttpRequest);
     27    std::string         GetHeader   (void) const;
    2828
    2929    CRXHttpRequest &    operator =  (const char * aHttpRequest);
  • trunk/include/CRXHttpResponse.h

    r5 r24  
    77#include "CRXHttpMessage.h"
    88
     9#define ERROR_HTTP_RESPONSE                                 -4000
     10#define ERROR_HTTP_RESPONSE_INVALID_LENGTH                  ERROR_HTTP_RESPONSE - 1
     11#define ERROR_HTTP_RESPONSE_INVALID_FORMAT                  ERROR_HTTP_RESPONSE - 2
     12#define ERROR_HTTP_RESPONSE_FAILED_TO_MEMORY_ALLOCATION     ERROR_HTTP_RESPONSE - 3
     13#define ERROR_HTTP_RESPONSE_FAILED_TO_PARSE_CONTENT         ERROR_HTTP_RESPONSE - 4
     14
    915class CRXHttpResponse : public CRXHttpMessage
    1016{
     
    1218    int         mStatusCode;
    1319    std::string mStatusString;
     20    bool        mIsChunked;     /* Transfer-Encoding */
     21    int         mContentLength;
     22
     23    struct __content_body__ {
     24        char    * mBody;
     25        int     mLength;
     26    } mContent;
    1427
    1528public:
    16     CRXHttpResponse                 (void);
     29    CRXHttpResponse     (void);
     30    ~CRXHttpResponse    (void);
    1731
    1832private:
    19     void                Parse       (void);
     33    void                Parse               (void);
     34    int                 ParseContent        (const char * aContent,
     35                                             const int  aLength);
     36    void                ResetContent        (void);
    2037
    2138public:
    22     void                SetResponse (const char * aHttpResponse);
    23     std::string         GetResponse (void) const;
     39    int                 GetStatusCode       (void) const;
    2440
    25     CRXHttpResponse &   operator =  (const char * aHttpResponse);
     41    int                 SetResponse         (const char * aHttpResponse,
     42                                             const int  aResponseLength);
     43    std::string         GetHeader           (void) const;
     44    const char *        GetContentBody      (void) const;
     45    int                 GetContentLength    (void) const;
    2646
    27 public:
    28     int                 GetStatusCode (void) const;
     47    CRXHttpResponse &   operator =          (const char * aHttpResponse);
    2948};
    3049
  • trunk/include/CRXProxy.h

    r20 r24  
    66
    77#include "CRXException.h"
     8#include "CRXSocket.h"
     9#include "CRXHttpMessage.h"
     10#include "CRXHttpRequest.h"
     11#include "CRXHttpResponse.h"
    812
    9 class CRXSocket;
     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;
    1026
    1127class CRXProxy : public CRXException
     
    1329private:
    1430    CRXSocket           mClient;
     31    CRXSocket           mServer;
     32
     33    CRXHttpRequest      mHttpRequest;
     34    CRXHttpResponse     mHttpResponse;
     35
     36    E_CRX_PROXY_STATUS  mProxyStatus;
    1537
    1638public:
    17     CRXProxy            (const int aSocket = 0);
     39    CRXProxy            (void);
     40    ~CRXProxy           (void);
     41
     42    static CRXProxy *   GetNewInstance  (void);
    1843
    1944public:
    20     static CRXProxy *   GetNewInstance  (const int aSocket = 0);
     45    void    ReleaseInstance             (void);
     46
     47    void    SetClientSocket             (const int  aSocket);
     48    void    Close                       (void);
     49
     50    int     GetStatus                   (void);
    2151
    2252public:
    23     int                 Forward         (void);
    24     int                 ForwardMT       (void);
     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);
    2570};
    2671
  • trunk/include/CRXSocket.h

    r18 r24  
    5555     * @return available : true, else : false.
    5656     */
    57     inline bool IsCreated       (void) const;
     57    bool        IsCreated       (void) const;
    5858
    59     inline bool IsReady         (void) const;
     59    bool        IsReady         (void) const;
    6060
    6161    /**
     
    8787    CRXSocket   & operator =    (int aSocket);
    8888
     89    int         SetTimeout      (const int aTimeout);
     90
    8991    /**
    9092     * for server
     
    107109     * for communication
    108110     */
    109     int Send                    (char   * aBuffer,
    110                                  int    aSize);
     111    int Send                    (const char * aBuffer,
     112                                 int        aSize);
    111113
    112114    int Receive                 (char   * aBuffer,
Note: See TracChangeset for help on using the changeset viewer.