Changeset 44 in cheroxy for trunk/src/CRXHttpResponse.cpp


Ignore:
Timestamp:
11/22/12 15:21:02 (11 years ago)
Author:
cheese
Message:

#1 change logic more detail

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/CRXHttpResponse.cpp

    r28 r44  
    1212#include <string.h>
    1313
    14 #define CRLF                "\r\n"
    15 #define CRLF2               "\r\n\r\n" 
    16 
    1714#define CONTENT_LENGTH      "Content-Length: "
    1815#define TRANSFER_ENCODING   "Transfer-Encoding: "
     
    5653
    5754int
    58 CRXHttpResponse::SetResponse (const char    * aHttpResponse,
    59                               const int     aResponseLength)
     55CRXHttpResponse::SetResponseAll (const char * aHttpResponse,
     56                                 const int  aResponseLength)
    6057{
    6158    int             aResult = 0;
     
    7067        return ERROR_HTTP_RESPONSE_INVALID_LENGTH;
    7168
    72     if (GetHeader ().length () == 0)
     69    if (GetHeader ().rfind (CRLF2) == std::string::npos)
    7370    {
    7471        aEndOfHeader = strstr (aHttpResponse, CRLF2);
     
    8077        aHeader.assign (aHttpResponse, aHeaderLength);
    8178
    82         SetMessage (aHeader.c_str ());
    83     }
    84 
    85     aResult = ParseContent (aHttpResponse + aHeaderLength, aResponseLength - aHeaderLength);
     79        SetHeader (aHeader.c_str ());
     80    }
     81
     82    aResult = SetContent (aHttpResponse + aHeaderLength, aResponseLength - aHeaderLength);
    8683    if (aResult)
    8784    {
    88         return ERROR_HTTP_RESPONSE_FAILED_TO_PARSE_CONTENT;
     85        aResult = ERROR_HTTP_RESPONSE_FAILED_TO_PARSE_CONTENT;
    8986    }
    9087    /*----------------------------------------------------------------*/
     
    9390}
    9491
    95 CRXHttpResponse &
    96 CRXHttpResponse::operator = (const char * aHttpMessage)
     92void
     93CRXHttpResponse::SetHeader (const char * aHttpMessage)
    9794{
    9895    /*----------------------------------------------------------------*/
    9996    SetMessage (aHttpMessage);
    10097    /*----------------------------------------------------------------*/
    101 
    102     return *this;
    10398}
    10499
     
    166161
    167162int
    168 CRXHttpResponse::ParseContent (const char   * aContent,
     163CRXHttpResponse::SetContent (const char * aContent,
    169164                               const int    aLength)
    170165{
     
    207202
    208203int             CRXHttpResponse::GetStatusCode      (void) const { return mStatusCode; }
     204bool            CRXHttpResponse::IsChunked          (void) const { return mIsChunked; }
    209205int             CRXHttpResponse::GetContentLength   (void) const { return mContentLength; }
    210206const char *    CRXHttpResponse::GetContentBody     (void) const { return mContent.mBody; }
Note: See TracChangeset for help on using the changeset viewer.