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


Ignore:
Timestamp:
11/20/12 19:06:30 (12 years ago)
Author:
cheese
Message:

#1 add debugging message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/CRXProxy.cpp

    r34 r35  
    9999    {
    100100        aResult = ERROR_PROXY_FAILED_TO_RECEIVE_REQUEST;
    101         CRX_ERROR (aResult, "Failed to receive from client");
     101        CRX_ERROR_SET (aResult, "Failed to receive from client.");
    102102    }
    103103
     
    106106    {
    107107        aResult = ERROR_PROXY_FAILED_TO_SEND_REQUEST;
    108         CRX_ERROR (aResult, "Failed to send to server");
     108        CRX_ERROR_SET (aResult, "Failed to send to server.");
    109109        return aResult;
    110110    }
     
    114114    {
    115115        aResult = ERROR_PROXY_FAILED_TO_RECEIVE_RESPONSE;
    116         CRX_ERROR (aResult, "Failed to receive from server");
     116        CRX_ERROR_SET (aResult, "Failed to receive from server.");
    117117    }
    118118
     
    121121    {
    122122        aResult = ERROR_PROXY_FAILED_TO_SEND_RESPONSE;
    123         CRX_ERROR (aResult, "Failed to send to client");
     123        CRX_ERROR_SET (aResult, "Failed to send to client.");
    124124        return aResult;
    125125    }
     
    177177
    178178char *
    179 CRXProxy::GetHttpResponse (char         * aBuffer,
    180                           const int    aBufferSize) const
     179CRXProxy::GetHttpResponseHeader (char       * aBuffer,
     180                                const int  aBufferSize) const
    181181{
    182182    void        * aPtr = static_cast<void *> (aBuffer);
     
    185185    int         aRemainLength   = aBufferSize;
    186186    const int   aHeaderLength   = mHttpResponse.GetHeader ().length ();
    187     const int   aContentLength  = mHttpResponse.GetContentLength ();
    188187
    189188    /*----------------------------------------------------------------*/
     
    194193    if (aCopyLength > 0)
    195194        memcpy (aPtr, mHttpResponse.GetHeader ().c_str (), aCopyLength);
    196 
    197     aRemainLength -= aCopyLength;
     195    /*----------------------------------------------------------------*/
     196
     197    return aBuffer;
     198}
     199
     200int
     201CRXProxy::GetHttpResponseHeaderLength (void) const
     202{
     203    /*----------------------------------------------------------------*/
     204    /*----------------------------------------------------------------*/
     205
     206    return mHttpResponse.GetHeader ().length ();
     207}
     208
     209char *
     210CRXProxy::GetHttpResponseBody (char         * aBuffer,
     211                               const int    aBufferSize) const
     212{
     213    void        * aPtr = static_cast<void *> (aBuffer);
     214
     215    int         aCopyLength     = 0;
     216    int         aRemainLength   = aBufferSize;
     217    const int   aContentLength  = mHttpResponse.GetContentLength ();
     218
     219    /*----------------------------------------------------------------*/
     220    if (aPtr == NULL)
     221        return NULL;
    198222
    199223    aCopyLength = aRemainLength < aContentLength ? aRemainLength : aContentLength;
     
    206230
    207231int
    208 CRXProxy::GetHttpResponseLength (void) const
    209 {
    210     /*----------------------------------------------------------------*/
    211     /*----------------------------------------------------------------*/
    212 
    213     return mHttpResponse.GetHeader ().length ()
    214          + mHttpResponse.GetContentLength ();
     232CRXProxy::GetHttpResponseBodyLength (void) const
     233{
     234    /*----------------------------------------------------------------*/
     235    /*----------------------------------------------------------------*/
     236
     237    return mHttpResponse.GetContentLength ();
    215238}
    216239
     
    228251    {
    229252        aResult = ERROR_PROXY_FAILED_TO_RECEIVE_REQUEST;
    230         CRX_ERROR_ADD (mClient.GetErrorMessage ().c_str ());
    231         CRX_ERROR (aResult, "Failed to receive from client");
     253        CRX_ADD_SUBCLASS_ERROR (mClient);
     254        CRX_ERROR_SET (aResult, "Failed to receive from client.");
    232255        return aResult;
    233256    }
     
    254277        {
    255278            aResult = ERROR_PROXY_FAILED_TO_CONNECT_TO_SERVER;
    256             CRX_ERROR_ADD (mServer.GetErrorMessage ().c_str ());
    257             CRX_ERROR (aResult, "Failed to connect to server <%s>", mHttpRequest.GetURL ().c_str ());
     279            CRX_ADD_SUBCLASS_ERROR (mServer);
     280            CRX_ERROR_SET (aResult, "Failed to connect to server <%s>.", mHttpRequest.GetURL ().c_str ());
    258281            return aResult;
    259282        }
     
    263286    if (aResult != aSize)
    264287    {
    265         CRX_ERROR_ADD (mServer.GetErrorMessage ().c_str ());
    266         CRX_ERROR (aResult, "Failed to send to server <%s>", mHttpRequest.GetURL ().c_str ());
     288        CRX_ADD_SUBCLASS_ERROR (mServer);
     289        CRX_ERROR_SET (aResult, "Failed to send to server <%s>.", mHttpRequest.GetURL ().c_str ());
    267290    }
    268291    /*----------------------------------------------------------------*/
     
    290313        {
    291314            aResult = ERROR_PROXY_FAILED_TO_RECEIVE_REQUEST;
    292             CRX_ERROR_ADD (mServer.GetErrorMessage ().c_str ());
    293             CRX_ERROR (aResult, "Failed to receive from server");
     315            CRX_ADD_SUBCLASS_ERROR (mServer);
     316            CRX_ERROR_SET (aResult, "Failed to receive from server.");
    294317            return aResult;
    295318        }
     
    303326        {
    304327            aResult = ERROR_PROXY_FAILED_TO_SET_RESPONSE;
    305             CRX_ERROR (aResult, "Failed to set response");
     328            CRX_ERROR_SET (aResult, "Failed to set response.");
    306329            return aResult;
     330        }
     331
     332        if (!CheckRequestFilter (CRX_FILTER_REQUEST_FILE_EXTENSION) &&
     333            mHttpResponse.GetContentLength () > 0)
     334        {
     335            CRX_DEBUG_TRACE_BIN (mHttpResponse.GetContentBody (),
     336                                 mHttpResponse.GetContentLength (),
     337                                 "");
    307338        }
    308339    }
     
    323354    if (aResult != aSize)
    324355    {
    325         CRX_ERROR_ADD (mClient.GetErrorMessage ().c_str ());
    326         CRX_ERROR (aResult, "Failed to send to client");
     356        CRX_ADD_SUBCLASS_ERROR (mClient);
     357        CRX_ERROR_SET (aResult, "Failed to send to client.");
    327358        return aResult;
    328359    }
     
    332363    if (aResult != aSize)
    333364    {
    334         CRX_ERROR_ADD (mClient.GetErrorMessage ().c_str ());
    335         CRX_ERROR (aResult, "Failed to send to client");
     365        CRX_ADD_SUBCLASS_ERROR (mClient);
     366        CRX_ERROR_SET (aResult, "Failed to send to client.");
    336367    }
    337368    /*----------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.