OSDN Git Service

Add log messages and comments.
[ultramonkey-l7/sslproxy.git] / src / http_message.cpp
index 2b544f9..bf2ce09 100644 (file)
@@ -33,7 +33,7 @@ http_message::http_message()
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 1, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 1,
         "in/out_function : Constructor http_message::http_message(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -51,7 +51,7 @@ http_message::http_message(std::string header)
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 1, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 2,
         "in/out_function : Constructor http_message::http_message(std::string header) : "
         "header(%s)", header.c_str());
     }
@@ -66,7 +66,7 @@ http_message::~http_message()
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 2, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3,
         "in/out_function : Destructor http_message::~http_message(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -82,7 +82,7 @@ field_range http_message::header(std::string field_name) const
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 4,
         "in_function : field_range http_message::header(std::string field_name) : "
         "field_name(%s)", field_name.c_str());
     }
@@ -93,7 +93,7 @@ field_range http_message::header(std::string field_name) const
 
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 5,
         "out_function : field_range http_message::header(std::string field_name)");
     }
     /*------ DEBUG LOG END ------*/
@@ -112,7 +112,7 @@ void http_message::header(std::string field_name, std::string field_value)
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 6,
         "in_function : field_range http_message::header(std::string field_name, std::string field_value) : "
         "field_name(%s), field_value(%s)", field_name.c_str(), field_value.c_str());
     }
@@ -143,12 +143,13 @@ void http_message::header(std::string field_name, std::string field_value)
         }
     }
     catch (...) {
-        // XXX log: insert, replace (no throw by erase)
+        LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 1,
+        "Exception occured by inserting or replacing boost::multi_index.");
     }
 
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 7,
         "out_function : field_range http_message::header(std::string field_name, std::string field_value)");
     }
     /*------ DEBUG LOG END ------*/
@@ -163,9 +164,9 @@ std::string http_message::body() const
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 8,
         "in_function : std::string http_message::body(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 9,
         "out_function : std::string http_message::body(void) : "
         "return(%s)", this->_body.c_str());
     }
@@ -185,7 +186,7 @@ std::string http_message::body(std::string _body)
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 10,
         "in_function : std::string http_message::http_version(std::string _message) : "
         "_body(%s)", _body.c_str());
     }
@@ -197,7 +198,7 @@ std::string http_message::body(std::string _body)
 
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 11,
         "out_function : std::string http_message::body(std::string _body) : "
         "return(%s)", ret.c_str());
     }
@@ -215,7 +216,7 @@ std::string http_message::as_string()
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 12,
         "in_function : std::string http_message::as_string(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -225,7 +226,7 @@ std::string http_message::as_string()
 
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 13,
         "out_function : std::string http_message::as_string(void) : "
         "return(%s)", this->raw_message.c_str());
     }
@@ -243,7 +244,7 @@ void http_message::parse(std::string message)
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 14,
         "in_function : void http_message::parse(std::string message) : "
         "message(%s)", message.c_str());
     }
@@ -278,191 +279,170 @@ void http_message::parse(std::string message)
     std::string::iterator end = message.end();
     std::string::iterator start = ptr;
     std::pair<std::string, std::string> field_pair;
-    while (ptr != end) {
-        switch(pos) {
-        /*
-         * MESSAGE-HEADER   : field-name ":" [ field-value ]
-         * field-name       : token
-         * field-value      : *( field-content | LWS )
-         * field-content    : <the OCTETs making up the field-value and
-         *                    consisting of either *TEXT or combinations
-         *                    of token, separators, and quoted-string>
-         * TEXT             : <any OCTET except CTLs, but including LWS>
-         * quoted-string    : ( <"> *(qdtext | quoted-pair ) <"> )
-         * qdtext           : <any TEXT except <">>
-         * quoted-pair      : "\" CHAR
-         */
-        case MESSAGE_TOP:
-            if (isalpha(*ptr) || *ptr == '-' || isdigit(*ptr) || 
-                *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == '!' ||
-                *ptr == '$' || *ptr == '&' || *ptr == '*' || *ptr == '+' ||
-                *ptr == '%') {
-                start = ptr;
-                pos = MESSAGE_FIELD_NAME;
-            } else if (*ptr == '\r') { // CRLF + CRLF
-                pos = MESSAGE_LAST_CR;
-            } else {
-                /*-------- DEBUG LOG --------*/
-                if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-                    LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-                    "out_function : void http_message::parse(std::string message) : not CRLF");
-                }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case MESSAGE_CR:
-            // LF only
-            if (*ptr == '\n') {
-                pos = MESSAGE_LF;
-            } else {
-                /*-------- DEBUG LOG --------*/
-                if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-                    LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-                    "out_function : void http_request::parse(std::string request) : not CRLF");
-                }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case MESSAGE_LF:
-            if (isalpha(*ptr) || *ptr == '-' || isdigit(*ptr) || 
-                *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == '!' ||
-                *ptr == '$' || *ptr == '&' || *ptr == '*' || *ptr == '+' ||
-                *ptr == '%') {
-                if (field_pair.first.length()) {
-                    field_pair.first = convert_upper_camel_case(field_pair.first);
-                    boost::trim(field_pair.second);
-                    _header.get<field_map>().insert(field_pair);
-                    field_pair.first.clear();
+    try {
+        while (ptr != end) {
+            switch(pos) {
+            /*
+             * MESSAGE-HEADER   : field-name ":" [ field-value ]
+             * field-name       : token
+             * field-value      : *( field-content | LWS )
+             * field-content    : <the OCTETs making up the field-value and
+             *                    consisting of either *TEXT or combinations
+             *                    of token, separators, and quoted-string>
+             * TEXT             : <any OCTET except CTLs, but including LWS>
+             * quoted-string    : ( <"> *(qdtext | quoted-pair ) <"> )
+             * qdtext           : <any TEXT except <">>
+             * quoted-pair      : "\" CHAR
+             */
+            case MESSAGE_TOP:
+                if (isalpha(*ptr) || *ptr == '-' || isdigit(*ptr) || 
+                    *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == '!' ||
+                    *ptr == '$' || *ptr == '&' || *ptr == '*' || *ptr == '+' ||
+                    *ptr == '%') {
+                    start = ptr;
+                    pos = MESSAGE_FIELD_NAME;
+                } else if (*ptr == '\r') { // CRLF + CRLF
+                    pos = MESSAGE_LAST_CR;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 2,
+                    "Parse error: Invalid header field name.(%c)", *ptr);
+                    throw -1;
                 }
-                start = ptr;
-                pos = MESSAGE_FIELD_NAME;
-            } else if (*ptr == ' ' || *ptr == '\t') {
-                pos = MESSAGE_FIELD_VALUE;
-            } else if (*ptr == '\r') { // CRLF + CRLF
-                if (field_pair.first.length()) {
-                    field_pair.first = convert_upper_camel_case(field_pair.first);
-                    boost::trim(field_pair.second);
-                    _header.get<field_map>().insert(field_pair);
-                    field_pair.first.clear();
+                break;
+    
+            case MESSAGE_CR:
+                // LF only
+                if (*ptr == '\n') {
+                    pos = MESSAGE_LF;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 3,
+                    "Parse error: No LF.(%c)", *ptr);
+                    throw -1;
                 }
-                pos = MESSAGE_LAST_CR;
-            } else {
-                /*-------- DEBUG LOG --------*/
-                if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-                    LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-                    "out_function : void http_message::parse(std::string message) : not CRLF");
+                break;
+    
+            case MESSAGE_LF:
+                if (isalpha(*ptr) || *ptr == '-' || isdigit(*ptr) || 
+                    *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == '!' ||
+                    *ptr == '$' || *ptr == '&' || *ptr == '*' || *ptr == '+' ||
+                    *ptr == '%') {
+                    if (field_pair.first.length()) {
+                        field_pair.first = convert_upper_camel_case(field_pair.first);
+                        boost::trim(field_pair.second);
+                        _header.get<field_map>().insert(field_pair);
+                        field_pair.first.clear();
+                    }
+                    start = ptr;
+                    pos = MESSAGE_FIELD_NAME;
+                } else if (*ptr == ' ' || *ptr == '\t') {
+                    pos = MESSAGE_FIELD_VALUE;
+                } else if (*ptr == '\r') { // CRLF + CRLF
+                    if (field_pair.first.length()) {
+                        field_pair.first = convert_upper_camel_case(field_pair.first);
+                        boost::trim(field_pair.second);
+                        _header.get<field_map>().insert(field_pair);
+                        field_pair.first.clear();
+                    }
+                    pos = MESSAGE_LAST_CR;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 4,
+                    "Parse error: Invalid header field name.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case MESSAGE_FIELD_NAME:
-            // field-name end with ':'
-            if (*ptr == ':') {
-                pos = MESSAGE_FIELD_NAME_COLON;
-                field_pair.first.assign(start, ptr);
-            } else if (!isalpha(*ptr) && *ptr != '-' && !isdigit(*ptr) && 
-                *ptr != '.' && *ptr != '_' && *ptr != '~' && *ptr != '!' &&
-                *ptr != '$' && *ptr != '&' && *ptr != '*' && *ptr != '+' &&
-                *ptr != '%') {
-                /*-------- DEBUG LOG --------*/
-                if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-                    LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-                    "out_function : void http_message::parse(std::string message) : Invalid header field name.");
+                break;
+    
+            case MESSAGE_FIELD_NAME:
+                // field-name end with ':'
+                if (*ptr == ':') {
+                    pos = MESSAGE_FIELD_NAME_COLON;
+                    field_pair.first.assign(start, ptr);
+                } else if (!isalpha(*ptr) && *ptr != '-' && !isdigit(*ptr) && 
+                    *ptr != '.' && *ptr != '_' && *ptr != '~' && *ptr != '!' &&
+                    *ptr != '$' && *ptr != '&' && *ptr != '*' && *ptr != '+' &&
+                    *ptr != '%') {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 5,
+                    "Parse error: Invalid header field name.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case MESSAGE_FIELD_NAME_COLON:
-            if (*ptr == ' ' || isalpha(*ptr) || isdigit(*ptr) || *ptr == '-' ||
-                *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == ':' || 
-                *ptr == '@' || *ptr == '!' || *ptr == '$' || *ptr == '&' ||
-                *ptr == '(' || *ptr == ')' || *ptr == '*' || *ptr == '+' ||
-                *ptr == ',' || *ptr == ';' || *ptr == '=' || *ptr == '%' ||
-                *ptr == '<' || *ptr == '>' || *ptr == '[' || *ptr == ']' ||
-                *ptr == '{' || *ptr == '}' || *ptr == '?' || *ptr == '"' ||
-                *ptr == '|' || *ptr == '/' || *ptr == '\\' || *ptr == '\t') {
-                start = ptr;
-                pos = MESSAGE_FIELD_VALUE;
-            } else if (*ptr == '\r') { // omit field value
-                field_pair.second.clear();
-            } else {
-                /*-------- DEBUG LOG --------*/
-                if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-                    LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-                    "out_function : void http_message::parse(std::string message) : Invalid header field value.('%c')", *ptr);
+                break;
+    
+            case MESSAGE_FIELD_NAME_COLON:
+                if (*ptr == ' ' || isalpha(*ptr) || isdigit(*ptr) || *ptr == '-' ||
+                    *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == ':' || 
+                    *ptr == '@' || *ptr == '!' || *ptr == '$' || *ptr == '&' ||
+                    *ptr == '(' || *ptr == ')' || *ptr == '*' || *ptr == '+' ||
+                    *ptr == ',' || *ptr == ';' || *ptr == '=' || *ptr == '%' ||
+                    *ptr == '<' || *ptr == '>' || *ptr == '[' || *ptr == ']' ||
+                    *ptr == '{' || *ptr == '}' || *ptr == '?' || *ptr == '"' ||
+                    *ptr == '|' || *ptr == '/' || *ptr == '\\' || *ptr == '\t') {
+                    start = ptr;
+                    pos = MESSAGE_FIELD_VALUE;
+                } else if (*ptr == '\r') { // omit field value
+                    field_pair.second.clear();
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 6,
+                    "Parse error: Invalid header field value.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-            }
-            break;
-
-        case MESSAGE_FIELD_VALUE:
-            // field-value end with CR
-            if (*ptr == '\r') {
-                pos = MESSAGE_CR;
-                field_pair.second.assign(start, ptr);
-            } else if (*ptr != ' ' && !isalpha(*ptr) && !isdigit(*ptr) && *ptr != '-' &&
-                *ptr != '.' && *ptr != '_' && *ptr != '~' && *ptr != ':' && 
-                *ptr != '@' && *ptr != '!' && *ptr != '$' && *ptr != '&' &&
-                *ptr != '(' && *ptr != ')' && *ptr != '*' && *ptr != '+' &&
-                *ptr != ',' && *ptr != ';' && *ptr != '=' && *ptr != '%' &&
-                *ptr != '<' && *ptr != '>' && *ptr != '[' && *ptr != ']' &&
-                *ptr != '{' && *ptr != '}' && *ptr != '?' && *ptr != '"' &&
-                *ptr != '|' && *ptr != '/' && *ptr != '\\'&& *ptr != '\t' ) {
-                /*-------- DEBUG LOG --------*/
-                if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-                    LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-                    "out_function : void http_message::parse(std::string message) : Invalid header field value.('%c')", *ptr);
+                break;
+    
+            case MESSAGE_FIELD_VALUE:
+                // field-value end with CR
+                if (*ptr == '\r') {
+                    pos = MESSAGE_CR;
+                    field_pair.second.assign(start, ptr);
+                } else if (*ptr != ' ' && !isalpha(*ptr) && !isdigit(*ptr) && *ptr != '-' &&
+                    *ptr != '.' && *ptr != '_' && *ptr != '~' && *ptr != ':' && 
+                    *ptr != '@' && *ptr != '!' && *ptr != '$' && *ptr != '&' &&
+                    *ptr != '(' && *ptr != ')' && *ptr != '*' && *ptr != '+' &&
+                    *ptr != ',' && *ptr != ';' && *ptr != '=' && *ptr != '%' &&
+                    *ptr != '<' && *ptr != '>' && *ptr != '[' && *ptr != ']' &&
+                    *ptr != '{' && *ptr != '}' && *ptr != '?' && *ptr != '"' &&
+                    *ptr != '|' && *ptr != '/' && *ptr != '\\'&& *ptr != '\t' ) {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 7,
+                    "Parse error: Invalid header field value.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case MESSAGE_LAST_CR:
-            // LF only
-            if (*ptr == '\n') {
-                pos = MESSAGE_LAST_LF;
-            } else {
-                /*-------- DEBUG LOG --------*/
-                if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-                    LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-                    "out_function : void http_message::parse(std::string message) : not CRLF");
+                break;
+    
+            case MESSAGE_LAST_CR:
+                // LF only
+                if (*ptr == '\n') {
+                    pos = MESSAGE_LAST_LF;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 8,
+                    "Parse error: No LF.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
+                break;
+    
+            /*
+             * MESSAGE-BODY     : *OCTET
+             */
+            case MESSAGE_LAST_LF:
+                pos = MESSAGE_BODY;
+                start = ptr;
+                break;
+    
+            case MESSAGE_BODY:
+                break;
             }
-            break;
-
-        /*
-         * MESSAGE-BODY     : *OCTET
-         */
-        case MESSAGE_LAST_LF:
-            pos = MESSAGE_BODY;
-            start = ptr;
-            break;
-
+            ptr++;
+        }
+    
+        switch (pos) {
         case MESSAGE_BODY:
-            break;
+            this->_body.assign(start, ptr);
         }
-        ptr++;
     }
-
-    switch (pos) {
-    case MESSAGE_BODY:
-        this->_body.assign(start, ptr);
+    catch (...) {
+        LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 9,
+        "Exception occured by parsing HTTP message.");
     }
 
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 15,
         "out_function : void http_message::parse(std::string message)");
     }
     /*------ DEBUG LOG END ------*/
@@ -475,7 +455,7 @@ void http_message::rebuild()
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 16,
         "in_function : void http_message::rebuild()");
     }
     /*------ DEBUG LOG END ------*/
@@ -493,7 +473,7 @@ void http_message::rebuild()
 
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 17,
         "out_function : void http_message::rebuild()");
     }
     /*------ DEBUG LOG END ------*/
@@ -501,6 +481,10 @@ void http_message::rebuild()
 
 /*!
  * Field name convert function.
+ * Convert upper camelcase
+ *     ex. connecTION => Connection
+ *         usEr-aGeNT => User-Agent
+ *         p3p => P3P
  *
  * @param[in]   field_name  field name
  * @return  converted to camel case
@@ -509,7 +493,7 @@ std::string http_message::convert_upper_camel_case(std::string field_name) const
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 18,
         "in_function : std::string http_message::upper_camel_case(std::string field_name) : "
         "field_name(%s)", field_name.c_str());
     }
@@ -529,7 +513,7 @@ std::string http_message::convert_upper_camel_case(std::string field_name) const
 
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 19,
         "out_function : std::string http_message::upper_camel_case(std::string field_name) : "
         "return(%s)", ret.c_str());
     }