Changeset 45 in cheroxy for trunk/src/CRXProxy.cpp


Ignore:
Timestamp:
11/22/12 18:38:07 (11 years ago)
Author:
cheese
Message:

#1 change access modifier of filter and http messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/CRXProxy.cpp

    r44 r45  
    99CRXFilter   CRXProxy::mFilter;
    1010
    11 CRXProxy::CRXProxy (void)
    12     : mClient (0),
    13       mServer (0),
    14       mServerTimeout (0)
    15 {
    16     /*----------------------------------------------------------------*/
     11CRXProxy::CRXProxy (const int aSocket)
     12    : mServerTimeout (0)
     13{
     14    /*----------------------------------------------------------------*/
     15    if (aSocket < 0)
     16        return ;
     17
     18    mClient = aSocket;
    1719    /*----------------------------------------------------------------*/
    1820}
     
    2224    /*----------------------------------------------------------------*/
    2325    Close ();
    24     /*----------------------------------------------------------------*/
    25 }
    26 
    27 void
    28 CRXProxy::SetClientSocket (const int aSocket)
    29 {
    30     /*----------------------------------------------------------------*/
    31     if (aSocket <= 0)
    32         return ;
    33 
    34     mClient = aSocket;
    3526    /*----------------------------------------------------------------*/
    3627}
     
    5142    mClient.Close ();
    5243    /*----------------------------------------------------------------*/
    53 }
    54 
    55 void
    56 CRXProxy::SetRequestFilter (const E_CRX_FILTER_REQUEST  aType,
    57                             const bool                  aIsMatched,
    58                             const std::string           aValue)
    59 {
    60     /*----------------------------------------------------------------*/
    61     mFilter.SetRequestFilter (aType, aIsMatched, aValue);
    62     /*----------------------------------------------------------------*/
    63 }
    64 
    65 void
    66 CRXProxy::RemoveRequestFilter (const E_CRX_FILTER_REQUEST aType)
    67 {
    68     /*----------------------------------------------------------------*/
    69     mFilter.RemoveRequestFilter (aType);
    70     /*----------------------------------------------------------------*/
    71 }
    72 
    73 bool
    74 CRXProxy::CheckRequestFilter (const E_CRX_FILTER_REQUEST aType)
    75 {
    76     /*----------------------------------------------------------------*/
    77     /*----------------------------------------------------------------*/
    78 
    79     return mFilter.CheckRequestFilter (aType, this->mHttpRequest);
    8044}
    8145
     
    12084}
    12185
    122 void
    123 CRXProxy::SetHttpRequest (const char * aHttpRequest)
    124 {
    125     /*----------------------------------------------------------------*/
    126     mHttpRequest.SetHeader (aHttpRequest);
    127     /*----------------------------------------------------------------*/
    128 }
    129 
    130 char *
    131 CRXProxy::GetHttpRequest (char      * aBuffer,
    132                           const int aBufferSize) const
    133 {
    134     void        * aPtr = static_cast<void *> (aBuffer);
    135 
    136     int         aCopyLength     = 0;
    137     int         aRemainLength   = aBufferSize;
    138     const int   aHeaderLength   = mHttpRequest.GetHeader ().length ();
    139 
    140     /*----------------------------------------------------------------*/
    141     if (aPtr == NULL)
    142         return NULL;
    143 
    144     aCopyLength = aRemainLength < aHeaderLength ? aBufferSize : aHeaderLength;
    145     if (aCopyLength > 0)
    146         memcpy (aPtr, mHttpRequest.GetHeader ().c_str (), aCopyLength);
    147     /*----------------------------------------------------------------*/
    148 
    149     return aBuffer;
    150 }
    151 
    152 int
    153 CRXProxy::GetHttpRequestLength (void) const
    154 {
    155     /*----------------------------------------------------------------*/
    156     /*----------------------------------------------------------------*/
    157 
    158     return mHttpRequest.GetHeader().length ();
    159 }
    160 
    161 void
    162 CRXProxy::SetHttpResponse (const char * aHttpResponse)
    163 {
    164     /*----------------------------------------------------------------*/
    165     mHttpResponse.SetHeader (aHttpResponse);
    166     /*----------------------------------------------------------------*/
    167 }
    168 
    169 char *
    170 CRXProxy::GetHttpResponseHeader (char       * aBuffer,
    171                                  const int  aBufferSize) const
    172 {
    173     void        * aPtr = static_cast<void *> (aBuffer);
    174 
    175     int         aCopyLength     = 0;
    176     int         aRemainLength   = aBufferSize;
    177     const int   aHeaderLength   = mHttpResponse.GetHeader ().length ();
    178 
    179     /*----------------------------------------------------------------*/
    180     if (aPtr == NULL)
    181         return NULL;
    182 
    183     aCopyLength = aRemainLength < aHeaderLength ? aBufferSize : aHeaderLength;
    184     if (aCopyLength > 0)
    185         memcpy (aPtr, mHttpResponse.GetHeader ().c_str (), aCopyLength);
    186     /*----------------------------------------------------------------*/
    187 
    188     return aBuffer;
    189 }
    190 
    191 int
    192 CRXProxy::GetHttpResponseHeaderLength (void) const
    193 {
    194     /*----------------------------------------------------------------*/
    195     /*----------------------------------------------------------------*/
    196 
    197     return mHttpResponse.GetHeader ().length ();
    198 }
    199 
    200 char *
    201 CRXProxy::GetHttpResponseBody (char         * aBuffer,
    202                                const int    aBufferSize) const
    203 {
    204     void        * aPtr = static_cast<void *> (aBuffer);
    205 
    206     int         aCopyLength     = 0;
    207     int         aRemainLength   = aBufferSize;
    208     const int   aContentLength  = mHttpResponse.GetContentLength ();
    209 
    210     /*----------------------------------------------------------------*/
    211     if (aPtr == NULL)
    212         return NULL;
    213 
    214     aCopyLength = aRemainLength < aContentLength ? aRemainLength : aContentLength;
    215     if (aCopyLength > 0)
    216         memcpy (aPtr, mHttpResponse.GetContentBody (), aCopyLength);
    217     /*----------------------------------------------------------------*/
    218 
    219     return aBuffer;
    220 }
    221 
    222 int
    223 CRXProxy::GetHttpResponseBodyLength (void) const
    224 {
    225     /*----------------------------------------------------------------*/
    226     /*----------------------------------------------------------------*/
    227 
    228     return mHttpResponse.GetContentLength ();
    229 }
    230 
    23186int
    23287CRXProxy::ReceiveRequest (void)
     
    315170
    316171        aResult = mHttpResponse.SetResponseAll (aBuffer, aResult);
    317         if (aResult)
     172        if (aResult < 0)
    318173        {
    319174            aResult = ERROR_PROXY_FAILED_TO_SET_RESPONSE;
     
    354209    return aResult < 0 ? aResult : 0;
    355210}
     211
     212CRXFilter &
     213CRXProxy::GetFilter (void) const
     214{
     215    /*----------------------------------------------------------------*/
     216    /*----------------------------------------------------------------*/
     217
     218    return mFilter;
     219}
     220
     221CRXHttpRequest &
     222CRXProxy::GetHttpRequest (void)
     223{
     224    /*----------------------------------------------------------------*/
     225    /*----------------------------------------------------------------*/
     226
     227    return mHttpRequest;
     228}
     229
     230CRXHttpResponse &
     231CRXProxy::GetHttpResponse (void)
     232{
     233    /*----------------------------------------------------------------*/
     234    /*----------------------------------------------------------------*/
     235
     236    return mHttpResponse;
     237}
Note: See TracChangeset for help on using the changeset viewer.