OSDN Git Service

Add log messages and comments.
authorKohei TANUMA <tanuma@users.sourceforge.jp>
Thu, 11 Jun 2009 14:47:42 +0000 (23:47 +0900)
committerKohei TANUMA <tanuma@users.sourceforge.jp>
Thu, 11 Jun 2009 14:47:42 +0000 (23:47 +0900)
src/http_message.cpp
src/http_request.cpp
src/http_response.cpp
src/packet_editor.cpp
src/sslproxymain.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());
     }
index ee71198..dc769f0 100644 (file)
@@ -31,7 +31,7 @@ http_request::http_request()
 {
     /*-------- 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, 20,
         "in/out_function : Constructor http_request::http_request(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -47,7 +47,7 @@ http_request::http_request(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, 21,
         "in/out_function : Constructor http_request::http_request(std::string header) : "
         "header(%s)", header.c_str());
     }
@@ -62,7 +62,7 @@ http_request::~http_request()
 {
     /*-------- 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, 22,
         "in/out_function : Destructor http_request::~http_request(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -77,9 +77,9 @@ std::string http_request::method() 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, 23,
         "in_function : std::string http_request::method(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 24,
         "out_function : std::string http_request::method(void) : "
         "return(%s)", this->_method.c_str());
     }
@@ -99,7 +99,7 @@ std::string http_request::method(std::string _method)
 {
     /*-------- 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, 25,
         "in_function : std::string http_request::method(std::string _method) : "
         "_method(%s)", _method.c_str());
     }
@@ -111,7 +111,7 @@ std::string http_request::method(std::string _method)
 
     /*-------- 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, 26,
         "out_function : std::string http_request::method(std::string _method) : "
         "return(%s)", ret.c_str());
     }
@@ -129,9 +129,9 @@ std::string http_request::request_uri() 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, 27,
         "in_function : std::string http_request::request_uri(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 28,
         "out_function : std::string http_request::request_uri(void) : "
         "return(%s)", this->_request_uri.c_str());
     }
@@ -151,7 +151,7 @@ std::string http_request::request_uri(std::string _request_uri)
 {
     /*-------- 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, 29,
         "in_function : std::string http_request::request_uri(std::string _request_uri) : "
         "_request_uri(%s)", _request_uri.c_str());
     }
@@ -163,7 +163,7 @@ std::string http_request::request_uri(std::string _request_uri)
 
     /*-------- 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, 30,
         "out_function : std::string http_request::_request_uri(std::string _request_uri) : "
         "return(%s)", ret.c_str());
     }
@@ -181,9 +181,9 @@ std::string http_request::http_version() 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, 31,
         "in_function : std::string http_request::http_version(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 32,
         "out_function : std::string http_request::http_version(void) : "
         "return(%s)", this->_http_version.c_str());
     }
@@ -203,7 +203,7 @@ std::string http_request::http_version(std::string _http_version)
 {
     /*-------- 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, 33,
         "in_function : std::string http_request::http_version(std::string _http_version) : "
         "_http_version(%s)", _http_version.c_str());
     }
@@ -215,7 +215,7 @@ std::string http_request::http_version(std::string _http_version)
 
     /*-------- 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, 34,
         "out_function : std::string http_request::http_version(std::string _http_version) : "
         "return(%s)", ret.c_str());
     }
@@ -233,7 +233,7 @@ std::string http_request::request_line() 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, 35,
         "in_function : std::string http_request::request_line(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -242,7 +242,7 @@ std::string http_request::request_line() 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, 36,
         "out_function : std::string http_request::request_line(void) : "
         "return(%s)", ret.c_str());
     }
@@ -260,7 +260,7 @@ std::string http_request::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, 37,
         "in_function : std::string http_request::as_string(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -270,7 +270,7 @@ std::string http_request::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, 38,
         "out_function : std::string http_request::as_string(void) : "
         "return(%s)", this->raw_message.c_str());
     }
@@ -288,7 +288,7 @@ void http_request::parse(std::string request)
 {
     /*-------- 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, 39,
         "in_function : void http_request::parse(std::string request) : "
         "request(%s)", request.c_str());
     }
@@ -322,276 +322,230 @@ void http_request::parse(std::string request)
     std::string::iterator end = request.end();
     std::string::iterator start = ptr;
     std::pair<std::string, std::string> field_pair;
-    while (ptr != end) {
-        switch(pos) {
-        /*
-         * REQUEST-LINE :
-         *      METHOD SP REQUEST-URI SP HTTP-VERSION CRLF
-         */
-        /*
-         * METHOD : token
-         */
-        case REQUEST_METHOD:
-            if (*ptr == ' ') { // METHOD end with SP
-                this->_method.assign(start, ptr);
-                pos = REQUEST_METHOD_SP;
-            } else if (!isalpha(*ptr) && !isdigit(*ptr)) { // XXX not enough
-                /*-------- 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) : Invalid Method");
+    try {
+        while (ptr != end) {
+            switch(pos) {
+            /*
+             * REQUEST-LINE :
+             *      METHOD SP REQUEST-URI SP HTTP-VERSION CRLF
+             */
+            /*
+             * METHOD : token
+             */
+            case REQUEST_METHOD:
+                if (*ptr == ' ') { // METHOD end with SP
+                    this->_method.assign(start, ptr);
+                    pos = REQUEST_METHOD_SP;
+                } else if (!isalpha(*ptr) && !isdigit(*ptr)) { // XXX not enough
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 10,
+                    "Parse error: Invalid request method.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-        /*
-         * REQUEST-URI : * | absolute-URI | path-absolute | authority
-         *
-         * RFC3986
-         *  absolute-URI    : scheme ":" hier-part [ "?" query ]
-         *  path-absolute   : "/" [ segment-nz *( "/" segment ) ]
-         *  authority       : [ userinfo "@" ] host [ ":" port ]
-         *  scheme          : ALPHA *( ALPHA | DIGIT | "+" | "-" | "." )
-         *  hier-part       : "//" authority path-abempty
-         *                  / path-absolute
-         *                  / path-rootless
-         *                  / path-empty
-         *  query           : *( pchar | "/" | "?" )
-         *  path-abempty    : *( "/" segment )
-         *  path-rootless   : segment-nz *( "/" segment )
-         *  path-empty      : no char
-         *  segment-nz      : 1*pchar
-         *  segment         : *pchar
-         *  userinfo        : *( unreserved | pct-encoded | sub-delims | ":" )
-         *  host            : IP-literal | IPv4address | reg-name
-         *  port            : *DIGIT
-         *  unreserved      : ALPHA | DIGIT | "-" | "." | "_" | "~"
-         *  pct-encoded     : "%" HEXDIG HEXDIG
-         *  sub-delims      : !$&'()*+,;=
-         *  pchar           : unreserved | pct-encoded | subdelims | ":" | "@"
-         *  IP-literal      : "[" ( IPv6address | IPvFuture ) "]"
-         *  IPvFuture       : "v" 1*HEXDIG "." 1*( unreserved | sub-delims | ":" )
-         *  IPv6address     :                            6( h16 ":" ) ls32
-         *                  /                       "::" 5( h16 ":" ) ls32
-         *                  / [               h16 ] "::" 4( h16 ":" ) ls32
-         *                  / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
-         *                  / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
-         *                  / [ *3( h16 ":" ) h16 ] "::"    h16 ":"   ls32
-         *                  / [ *4( h16 ":" ) h16 ] "::"              ls32
-         *                  / [ *5( h16 ":" ) h16 ] "::"              h16
-         *                  / [ *6( h16 ":" ) h16 ] "::"
-         *  h16             : 1*4HEXDIG
-         *  ls32            : ( h16 ":" h16 ) | IPv4address
-         *  IPv4address     : dec-octet "." dec-octet "." dec-octet "." dec-octet
-         *  dec-octet       : 0-255
-         *  reg-name        : *( unreserved | pct-encoded | sub-delims )
-         */
-        case REQUEST_METHOD_SP:
-            // Request-URI start
-            // XXX not enough?
-            if (*ptr == '/' || isalpha(*ptr) || isdigit(*ptr) || *ptr == '-' ||
-                *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == ':' || 
-                *ptr == '@' || *ptr == '!' || *ptr == '$' || *ptr == '&' ||
-                *ptr == '(' || *ptr == ')' || *ptr == '*' || *ptr == '+' ||
-                *ptr == ',' || *ptr == ';' || *ptr == '=' || *ptr == '%') {
-                pos = REQUEST_REQUEST_URI;
-                start = ptr;
-            } 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) : Invalid Request-URI");
+                break;
+            /*
+             * REQUEST-URI : * | absolute-URI | path-absolute | authority
+             *
+             * RFC3986
+             *  absolute-URI    : scheme ":" hier-part [ "?" query ]
+             *  path-absolute   : "/" [ segment-nz *( "/" segment ) ]
+             *  authority       : [ userinfo "@" ] host [ ":" port ]
+             *  scheme          : ALPHA *( ALPHA | DIGIT | "+" | "-" | "." )
+             *  hier-part       : "//" authority path-abempty
+             *                  / path-absolute
+             *                  / path-rootless
+             *                  / path-empty
+             *  query           : *( pchar | "/" | "?" )
+             *  path-abempty    : *( "/" segment )
+             *  path-rootless   : segment-nz *( "/" segment )
+             *  path-empty      : no char
+             *  segment-nz      : 1*pchar
+             *  segment         : *pchar
+             *  userinfo        : *( unreserved | pct-encoded | sub-delims | ":" )
+             *  host            : IP-literal | IPv4address | reg-name
+             *  port            : *DIGIT
+             *  unreserved      : ALPHA | DIGIT | "-" | "." | "_" | "~"
+             *  pct-encoded     : "%" HEXDIG HEXDIG
+             *  sub-delims      : !$&'()*+,;=
+             *  pchar           : unreserved | pct-encoded | subdelims | ":" | "@"
+             *  IP-literal      : "[" ( IPv6address | IPvFuture ) "]"
+             *  IPvFuture       : "v" 1*HEXDIG "." 1*( unreserved | sub-delims | ":" )
+             *  IPv6address     :                            6( h16 ":" ) ls32
+             *                  /                       "::" 5( h16 ":" ) ls32
+             *                  / [               h16 ] "::" 4( h16 ":" ) ls32
+             *                  / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
+             *                  / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
+             *                  / [ *3( h16 ":" ) h16 ] "::"    h16 ":"   ls32
+             *                  / [ *4( h16 ":" ) h16 ] "::"              ls32
+             *                  / [ *5( h16 ":" ) h16 ] "::"              h16
+             *                  / [ *6( h16 ":" ) h16 ] "::"
+             *  h16             : 1*4HEXDIG
+             *  ls32            : ( h16 ":" h16 ) | IPv4address
+             *  IPv4address     : dec-octet "." dec-octet "." dec-octet "." dec-octet
+             *  dec-octet       : 0-255
+             *  reg-name        : *( unreserved | pct-encoded | sub-delims )
+             */
+            case REQUEST_METHOD_SP:
+                // Request-URI start
+                // XXX not enough?
+                if (*ptr == '/' || isalpha(*ptr) || isdigit(*ptr) || *ptr == '-' ||
+                    *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == ':' || 
+                    *ptr == '@' || *ptr == '!' || *ptr == '$' || *ptr == '&' ||
+                    *ptr == '(' || *ptr == ')' || *ptr == '*' || *ptr == '+' ||
+                    *ptr == ',' || *ptr == ';' || *ptr == '=' || *ptr == '%') {
+                    pos = REQUEST_REQUEST_URI;
+                    start = ptr;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 11,
+                    "Parse error: Invalid request-uri.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_REQUEST_URI:
-            if (*ptr == ' ') { // Request-URI end with SP
-                this->_request_uri.assign(start, ptr);
-                pos = REQUEST_REQUEST_URI_SP;
-            } else if (!isalpha(*ptr) && !isdigit(*ptr) && *ptr != '/' && // XXX not enough?
-                *ptr != '.' && *ptr != '=' && *ptr != '%' && *ptr != '?' &&
-                *ptr != '&' && *ptr != '+' && *ptr != '~' && *ptr != ',' && 
-                *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_request::parse(std::string request) : Invalid Request-URI");
+                break;
+    
+            case REQUEST_REQUEST_URI:
+                if (*ptr == ' ') { // Request-URI end with SP
+                    this->_request_uri.assign(start, ptr);
+                    pos = REQUEST_REQUEST_URI_SP;
+                } else if (!isalpha(*ptr) && !isdigit(*ptr) && *ptr != '/' && // XXX not enough?
+                    *ptr != '.' && *ptr != '=' && *ptr != '%' && *ptr != '?' &&
+                    *ptr != '&' && *ptr != '+' && *ptr != '~' && *ptr != ',' && 
+                    *ptr != '@' && *ptr != '!' && *ptr != '$' && *ptr != '-' &&
+                    *ptr != '(' && *ptr != ')' && *ptr != '*' && *ptr != '_' &&
+                    *ptr != ':' && *ptr != ';') {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 12,
+                    "Parse error: Invalid request-uri.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        /*
-         * HTTP-VERSION     : "HTTP" "/" 1*DIGIT "." 1*DIGIT
-         */
-        case REQUEST_REQUEST_URI_SP:
-            // HTTP-VERSION start
-            if (*ptr == 'H') {
-                pos = REQUEST_HTTP_VERSION_H;
-                start = ptr;
-            } 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) : Invalid HTTP-Version");
+                break;
+    
+            /*
+             * HTTP-VERSION     : "HTTP" "/" 1*DIGIT "." 1*DIGIT
+             */
+            case REQUEST_REQUEST_URI_SP:
+                // HTTP-VERSION start
+                if (*ptr == 'H') {
+                    pos = REQUEST_HTTP_VERSION_H;
+                    start = ptr;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 13,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_HTTP_VERSION_H:
-            // HTTP-VERSION next
-            if (*ptr == 'T') {
-                pos = REQUEST_HTTP_VERSION_T1;
-            } 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) : Invalid HTTP-Version");
+                break;
+    
+            case REQUEST_HTTP_VERSION_H:
+                // HTTP-VERSION next
+                if (*ptr == 'T') {
+                    pos = REQUEST_HTTP_VERSION_T1;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 14,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_HTTP_VERSION_T1:
-            // HTTP-VERSION next
-            if (*ptr == 'T') {
-                pos = REQUEST_HTTP_VERSION_T2;
-            } 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) : Invalid HTTP-Version");
+                break;
+    
+            case REQUEST_HTTP_VERSION_T1:
+                // HTTP-VERSION next
+                if (*ptr == 'T') {
+                    pos = REQUEST_HTTP_VERSION_T2;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 15,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_HTTP_VERSION_T2:
-            // HTTP-VERSION next
-            if (*ptr == 'P') {
-                pos = REQUEST_HTTP_VERSION_P;
-            } 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) : Invalid HTTP-Version");
+                break;
+    
+            case REQUEST_HTTP_VERSION_T2:
+                // HTTP-VERSION next
+                if (*ptr == 'P') {
+                    pos = REQUEST_HTTP_VERSION_P;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 16,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_HTTP_VERSION_P:
-            // HTTP-VERSION next
-            if (*ptr == '/') {
-                pos = REQUEST_HTTP_VERSION_SLASH;
-            } 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) : Invalid HTTP-Version");
+                break;
+    
+            case REQUEST_HTTP_VERSION_P:
+                // HTTP-VERSION next
+                if (*ptr == '/') {
+                    pos = REQUEST_HTTP_VERSION_SLASH;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 17,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_HTTP_VERSION_SLASH:
-            // HTTP-VERSION Mejor number
-            if (isdigit(*ptr)) {
-                pos = REQUEST_HTTP_VERSION_MAJOR;
-            } 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) : Invalid HTTP-Version");
+                break;
+    
+            case REQUEST_HTTP_VERSION_SLASH:
+                // HTTP-VERSION Mejor number
+                if (isdigit(*ptr)) {
+                    pos = REQUEST_HTTP_VERSION_MAJOR;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 18,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_HTTP_VERSION_MAJOR:
-            // HTTP-VERSION next dot
-            if (*ptr == '.') {
-                pos = REQUEST_HTTP_VERSION_DOT;
-            } else if (!isdigit(*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_request::parse(std::string request) : Invalid HTTP-Version");
+                break;
+    
+            case REQUEST_HTTP_VERSION_MAJOR:
+                // HTTP-VERSION next dot
+                if (*ptr == '.') {
+                    pos = REQUEST_HTTP_VERSION_DOT;
+                } else if (!isdigit(*ptr)) {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 19,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_HTTP_VERSION_DOT:
-            // HTTP-VERSION Minor number
-            if (isdigit(*ptr)) {
-                pos = REQUEST_HTTP_VERSION_MINOR;
-            } 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) : Invalid HTTP-Version");
+                break;
+    
+            case REQUEST_HTTP_VERSION_DOT:
+                // HTTP-VERSION Minor number
+                if (isdigit(*ptr)) {
+                    pos = REQUEST_HTTP_VERSION_MINOR;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 20,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_HTTP_VERSION_MINOR:
-            // HTTP-VERSION end with CR
-            if (*ptr == '\r') {
-                pos = REQUEST_CR;
-                this->_http_version.assign(start, ptr);
-            } else if (!isdigit(*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_request::parse(std::string request) : Invalid HTTP-Version");
+                break;
+    
+            case REQUEST_HTTP_VERSION_MINOR:
+                // HTTP-VERSION end with CR
+                if (*ptr == '\r') {
+                    pos = REQUEST_CR;
+                    this->_http_version.assign(start, ptr);
+                } else if (!isdigit(*ptr)) {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 21,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_CR:
-            // LF only
-            if (*ptr == '\n') {
-                pos = REQUEST_LF;
-                http_message::parse(std::string(ptr + 1, end));
-            } 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");
+                break;
+    
+            case REQUEST_CR:
+                // LF only
+                if (*ptr == '\n') {
+                    pos = REQUEST_LF;
+                    http_message::parse(std::string(ptr + 1, end));
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 22,
+                    "Parse error: No LF.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
+                break;
             }
-            break;
+            if (pos == REQUEST_LF)
+                break;
+            ptr++;
         }
-        if (pos == REQUEST_LF)
-            break;
-        ptr++;
+    }
+    catch (...) {
+        LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 23,
+        "Exception occured by parsing HTTP request.");
     }
 
     /*-------- 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, 40,
         "out_function : void http_request::parse(std::string request)");
     }
     /*------ DEBUG LOG END ------*/
@@ -604,7 +558,7 @@ void http_request::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, 41,
         "in_function : void http_request::rebuild()");
     }
     /*------ DEBUG LOG END ------*/
@@ -614,7 +568,7 @@ void http_request::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, 42,
         "out_function : void http_request::rebuild()");
     }
     /*------ DEBUG LOG END ------*/
index 97bf859..17b7fe5 100644 (file)
@@ -31,7 +31,7 @@ http_response::http_response()
 {
     /*-------- 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, 43,
         "in/out_function : Constructor http_response::http_response(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -47,7 +47,7 @@ http_response::http_response(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, 44,
         "in/out_function : Constructor http_response::http_response(std::string header) : "
         "header(%s)", header.c_str());
     }
@@ -62,7 +62,7 @@ http_response::~http_response()
 {
     /*-------- 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, 45,
         "in/out_function : Destructor http_response::~http_response(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -77,9 +77,9 @@ std::string http_response::http_version() 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, 46,
         "in_function : std::string http_response::http_version(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 47,
         "out_function : std::string http_response::http_version(void) : "
         "return(%s)", this->_http_version.c_str());
     }
@@ -99,7 +99,7 @@ std::string http_response::http_version(std::string _http_version)
 {
     /*-------- 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, 48,
         "in_function : std::string http_response::http_version(std::string _http_version) : "
         "_http_version(%s)", _http_version.c_str());
     }
@@ -111,7 +111,7 @@ std::string http_response::http_version(std::string _http_version)
 
     /*-------- 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, 49,
         "out_function : std::string http_response::http_version(std::string _http_version) : "
         "return(%s)", ret.c_str());
     }
@@ -129,9 +129,9 @@ std::string http_response::status_code() 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, 50,
         "in_function : std::string http_response::status_code(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 51,
         "out_function : std::string http_response::status_code(void) : "
         "return(%s)", this->_status_code.c_str());
     }
@@ -151,7 +151,7 @@ std::string http_response::status_code(std::string _status_code)
 {
     /*-------- 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, 52,
         "in_function : std::string http_response::status_code(std::string _status_code) : "
         "_status_code(%s)", _status_code.c_str());
     }
@@ -163,7 +163,7 @@ std::string http_response::status_code(std::string _status_code)
 
     /*-------- 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, 53,
         "out_function : std::string http_response::status_code(std::string _status_code) : "
         "return(%s)", ret.c_str());
     }
@@ -181,9 +181,9 @@ std::string http_response::reason_phrase() 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, 54,
         "in_function : std::string http_response::reason_phrase(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 55,
         "out_function : std::string http_response::reason_phrase(void) : "
         "return(%s)", this->_reason_phrase.c_str());
     }
@@ -203,7 +203,7 @@ std::string http_response::reason_phrase(std::string _reason_phrase)
 {
     /*-------- 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, 56,
         "in_function : std::string http_response::reason_phrase(std::string _reason_phrase) : "
         "_reason_phrase(%s)", _reason_phrase.c_str());
     }
@@ -215,7 +215,7 @@ std::string http_response::reason_phrase(std::string _reason_phrase)
 
     /*-------- 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, 57,
         "out_function : std::string http_response::reason_phrase(std::string _reason_phrase) : "
         "return(%s)", ret.c_str());
     }
@@ -233,7 +233,7 @@ std::string http_response::status_line() 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, 58,
         "in_function : std::string http_response::status_line(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -242,7 +242,7 @@ std::string http_response::status_line() 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, 59,
         "out_function : std::string http_response::status_line(void) : "
         "return(%s)", ret.c_str());
     }
@@ -260,7 +260,7 @@ std::string http_response::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, 60,
         "in_function : std::string http_response::as_string(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -270,7 +270,7 @@ std::string http_response::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, 61,
         "out_function : std::string http_response::as_string(void) : "
         "return(%s)", this->raw_message.c_str());
     }
@@ -288,7 +288,7 @@ void http_response::parse(std::string response)
 {
     /*-------- 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, 62,
         "in_function : void http_response::parse(std::string response) : "
         "response(%s)", response.c_str());
     }
@@ -322,279 +322,221 @@ void http_response::parse(std::string response)
     std::string::iterator end = response.end();
     std::string::iterator start = ptr;
     std::pair<std::string, std::string> field_pair;
-    while (ptr != end) {
-        switch(pos) {
-        /*
-         * STATUS-LINE :
-         *      HTTP-VERSION SP STATUS-CODE SP REASON-PHRASE CRLF
-         */
-        /*
-         * HTTP-VERSION     : "HTTP" "/" 1*DIGIT "." 1*DIGIT
-         */
-        case RESPONSE_TOP:
-            // HTTP-VERSION start
-            if (*ptr == 'H') {
-                pos = RESPONSE_HTTP_VERSION_H;
-                start = ptr;
-            } 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_response::parse(std::string response) : Invalid HTTP-Version");
+    try {
+        while (ptr != end) {
+            switch(pos) {
+            /*
+             * STATUS-LINE :
+             *      HTTP-VERSION SP STATUS-CODE SP REASON-PHRASE CRLF
+             */
+            /*
+             * HTTP-VERSION     : "HTTP" "/" 1*DIGIT "." 1*DIGIT
+             */
+            case RESPONSE_TOP:
+                // HTTP-VERSION start
+                if (*ptr == 'H') {
+                    pos = RESPONSE_HTTP_VERSION_H;
+                    start = ptr;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 24,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_HTTP_VERSION_H:
-            // HTTP-VERSION next
-            if (*ptr == 'T') {
-                pos = RESPONSE_HTTP_VERSION_T1;
-            } 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_response::parse(std::string response) : Invalid HTTP-Version");
+                break;
+    
+            case RESPONSE_HTTP_VERSION_H:
+                // HTTP-VERSION next
+                if (*ptr == 'T') {
+                    pos = RESPONSE_HTTP_VERSION_T1;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 25,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_HTTP_VERSION_T1:
-            // HTTP-VERSION next
-            if (*ptr == 'T') {
-                pos = RESPONSE_HTTP_VERSION_T2;
-            } 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_response::parse(std::string response) : Invalid HTTP-Version");
+                break;
+    
+            case RESPONSE_HTTP_VERSION_T1:
+                // HTTP-VERSION next
+                if (*ptr == 'T') {
+                    pos = RESPONSE_HTTP_VERSION_T2;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 26,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_HTTP_VERSION_T2:
-            // HTTP-VERSION next
-            if (*ptr == 'P') {
-                pos = RESPONSE_HTTP_VERSION_P;
-            } 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_response::parse(std::string response) : Invalid HTTP-Version");
+                break;
+    
+            case RESPONSE_HTTP_VERSION_T2:
+                // HTTP-VERSION next
+                if (*ptr == 'P') {
+                    pos = RESPONSE_HTTP_VERSION_P;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 27,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_HTTP_VERSION_P:
-            // HTTP-VERSION next
-            if (*ptr == '/') {
-                pos = RESPONSE_HTTP_VERSION_SLASH;
-            } 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_response::parse(std::string response) : Invalid HTTP-Version");
+                break;
+    
+            case RESPONSE_HTTP_VERSION_P:
+                // HTTP-VERSION next
+                if (*ptr == '/') {
+                    pos = RESPONSE_HTTP_VERSION_SLASH;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 28,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_HTTP_VERSION_SLASH:
-            // HTTP-VERSION Mejor number
-            if (isdigit(*ptr)) {
-                pos = RESPONSE_HTTP_VERSION_MAJOR;
-            } 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_response::parse(std::string response) : Invalid HTTP-Version");
+                break;
+    
+            case RESPONSE_HTTP_VERSION_SLASH:
+                // HTTP-VERSION Mejor number
+                if (isdigit(*ptr)) {
+                    pos = RESPONSE_HTTP_VERSION_MAJOR;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 29,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_HTTP_VERSION_MAJOR:
-            // HTTP-VERSION next dot
-            if (*ptr == '.') {
-                pos = RESPONSE_HTTP_VERSION_DOT;
-            } else if (!isdigit(*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_response::parse(std::string response) : Invalid HTTP-Version");
+                break;
+    
+            case RESPONSE_HTTP_VERSION_MAJOR:
+                // HTTP-VERSION next dot
+                if (*ptr == '.') {
+                    pos = RESPONSE_HTTP_VERSION_DOT;
+                } else if (!isdigit(*ptr)) {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 30,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_HTTP_VERSION_DOT:
-            // HTTP-VERSION Minor number
-            if (isdigit(*ptr)) {
-                pos = RESPONSE_HTTP_VERSION_MINOR;
-            } 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_response::parse(std::string response) : Invalid HTTP-Version");
+                break;
+    
+            case RESPONSE_HTTP_VERSION_DOT:
+                // HTTP-VERSION Minor number
+                if (isdigit(*ptr)) {
+                    pos = RESPONSE_HTTP_VERSION_MINOR;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 31,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_HTTP_VERSION_MINOR:
-            // HTTP-VERSION end with SP
-            if (*ptr == ' ') {
-                pos = RESPONSE_HTTP_VERSION_SP;
-                this->_http_version.assign(start, ptr);
-            } else if (!isdigit(*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_response::parse(std::string response) : Invalid HTTP-Version");
+                break;
+    
+            case RESPONSE_HTTP_VERSION_MINOR:
+                // HTTP-VERSION end with SP
+                if (*ptr == ' ') {
+                    pos = RESPONSE_HTTP_VERSION_SP;
+                    this->_http_version.assign(start, ptr);
+                } else if (!isdigit(*ptr)) {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 32,
+                    "Parse error: Invalid http-version.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        /*
-         * Status-Code  : 3DIGIT
-         */
-        case RESPONSE_HTTP_VERSION_SP:
-            // STATUS-CODE start
-            if (isdigit(*ptr)) {
-                pos = RESPONSE_STATUS_CODE1;
-                start = ptr;
-            } 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_response::parse(std::string response) : Invalid Status-Code");
+                break;
+    
+            /*
+             * Status-Code  : 3DIGIT
+             */
+            case RESPONSE_HTTP_VERSION_SP:
+                // STATUS-CODE start
+                if (isdigit(*ptr)) {
+                    pos = RESPONSE_STATUS_CODE1;
+                    start = ptr;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 33,
+                    "Parse error: Invalid status-code.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_STATUS_CODE1:
-            // STATUS-CODE next
-            if (isdigit(*ptr)) {
-                pos = RESPONSE_STATUS_CODE2;
-            } 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_response::parse(std::string response) : Invalid Status-Code");
+                break;
+    
+            case RESPONSE_STATUS_CODE1:
+                // STATUS-CODE next
+                if (isdigit(*ptr)) {
+                    pos = RESPONSE_STATUS_CODE2;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 34,
+                    "Parse error: Invalid status-code.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_STATUS_CODE2:
-            // STATUS-CODE next
-            if (isdigit(*ptr)) {
-                pos = RESPONSE_STATUS_CODE3;
-            } 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_response::parse(std::string response) : Invalid Status-Code");
+                break;
+    
+            case RESPONSE_STATUS_CODE2:
+                // STATUS-CODE next
+                if (isdigit(*ptr)) {
+                    pos = RESPONSE_STATUS_CODE3;
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 35,
+                    "Parse error: Invalid status-code.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_STATUS_CODE3:
-            // Status-Code end with SP
-            if (*ptr == ' ') {
-                pos = RESPONSE_STATUS_CODE_SP;
-                this->_status_code.assign(start, ptr);
-            } 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_response::parse(std::string response) : Invalid Status-Code");
+                break;
+    
+            case RESPONSE_STATUS_CODE3:
+                // Status-Code end with SP
+                if (*ptr == ' ') {
+                    pos = RESPONSE_STATUS_CODE_SP;
+                    this->_status_code.assign(start, ptr);
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 36,
+                    "Parse error: Invalid status-code.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        /*
-         * Reason-Phrase    : *<TEXT, excluding CR, LF>
-         */
-        case RESPONSE_STATUS_CODE_SP:
-            // Reason-Phrase is OCTET
-            if (*ptr == '\r') { // omit reason-phrase
-                pos = RESPONSE_CR;
-                this->_reason_phrase.clear();
-            } else if (*ptr != '\n') {
-                pos = RESPONSE_REASON_PHRASE;
-                start = ptr;
-            } 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_response::parse(std::string response) : Invalid Reason-Phrase");
+                break;
+    
+            /*
+             * Reason-Phrase    : *<TEXT, excluding CR, LF>
+             */
+            case RESPONSE_STATUS_CODE_SP:
+                // Reason-Phrase is OCTET
+                if (*ptr == '\r') { // omit reason-phrase
+                    pos = RESPONSE_CR;
+                    this->_reason_phrase.clear();
+                } else if (*ptr != '\n') {
+                    pos = RESPONSE_REASON_PHRASE;
+                    start = ptr;
+                } else  {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 37,
+                    "Parse error: Invalid reason-phrase.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_REASON_PHRASE:
-            // Reason-Phrase end with CR
-            if (*ptr == '\r') {
-                pos = RESPONSE_CR;
-                this->_reason_phrase.assign(start, ptr);
-            } else if (*ptr == '\n') {
-                /*-------- 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_response::parse(std::string response) : Invalid Reason-Phrase");
+                break;
+    
+            case RESPONSE_REASON_PHRASE:
+                // Reason-Phrase end with CR
+                if (*ptr == '\r') {
+                    pos = RESPONSE_CR;
+                    this->_reason_phrase.assign(start, ptr);
+                } else if (*ptr == '\n') {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 38,
+                    "Parse error: Invalid reason-phrase.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case RESPONSE_CR:
-            // LF only
-            if (*ptr == '\n') {
-                pos = RESPONSE_LF;
-                http_message::parse(std::string(ptr + 1, end));
-            } 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_response::parse(std::string response) : not CRLF");
+                break;
+    
+            case RESPONSE_CR:
+                // LF only
+                if (*ptr == '\n') {
+                    pos = RESPONSE_LF;
+                    http_message::parse(std::string(ptr + 1, end));
+                } else {
+                    LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 39,
+                    "Parse error: No LF.(%c)", *ptr);
+                    throw -1;
                 }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
+                break;
             }
-            break;
+            if (pos == RESPONSE_LF)
+                break;
+            ptr++;
         }
-        if (pos == RESPONSE_LF)
-            break;
-        ptr++;
+    }
+    catch (...) {
+        LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 40,
+        "Exception occured by parsing HTTP response.");
     }
 
     /*-------- 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, 63,
         "out_function : void http_response::parse(std::string response)");
     }
     /*------ DEBUG LOG END ------*/
@@ -607,7 +549,7 @@ void http_response::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, 64,
         "in_function : void http_response::rebuild()");
     }
     /*------ DEBUG LOG END ------*/
@@ -617,7 +559,7 @@ void http_response::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, 65,
         "out_function : void http_response::rebuild()");
     }
     /*------ DEBUG LOG END ------*/
index c015fd9..c233d4f 100644 (file)
@@ -34,7 +34,7 @@ packet_editor::packet_editor(const sslproxy_session* session)
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 1, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 1,
         "in_function : Constructor packet_editor::packet_editor(const sslproxysession* session)");
     }
     /*------ DEBUG LOG END ------*/
@@ -43,7 +43,7 @@ packet_editor::packet_editor(const sslproxy_session* session)
 
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 1, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 2,
         "out_function : Constructor packet_editor::packet_editor(const sslproxysession* session)");
     }
     /*------ DEBUG LOG END ------*/
@@ -56,7 +56,7 @@ packet_editor::~packet_editor()
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 2, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 3,
         "in/out_function : Destructor packet_editor::~packet_editor(void)");
     }
     /*------ DEBUG LOG END ------*/
@@ -69,43 +69,53 @@ void packet_editor::edit_client(char* client_msg, size_t& client_length)
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 4,
         "in_function : void packet_editor::edit_client(char* client_msg, size_t& client_length) : "
         "client_msg(%s), client_length(%d)", client_msg, client_length);
-        
     }
     /*------ DEBUG LOG END ------*/
 
+    // Edit HTTP (request header)
     std::list<std::pair<std::string, std::string > >::iterator it, end;
     it  = ::http_request_header.begin();
     end = ::http_request_header.end();
     http_request request(std::string(client_msg, client_length));
     for (;it != end; ++it) {
-        LOGGER_PUT_LOG_FATAL(LOG_CAT_PACKET_EDIT, 3, "mode: %s, header: %s", it->first.c_str(), it->second.c_str());
+        // Set request header field
         if (it->first == "set") {
+            // "Header-Field-Name":"Set-Value"
             std::vector<std::string> set_vector = split(it->second, ":", 2);
             if (set_vector.size() == 2)
                 expand_macro(set_vector.at(1));
+                // Overwrite or insert.
                 request.header(set_vector.at(0), set_vector.at(1));
         }
+        // Remove request header field
         else if (it->first == "unset") {
+            // "Header-Field-Name"
             request.header(it->second, "");
         }
+        // Add request header field
         else if (it->first == "add") {
+            // "Header-Field-Name":"Set-Value"
             std::vector<std::string> add_vector = split(it->second, ":", 2);
             if (add_vector.size() == 2) {
                 field_range current_range = request.header(add_vector.at(0));
                 expand_macro(add_vector.at(1));
+                // If header field already exists, concatinate values.
                 if (current_range.first != current_range.second) {
                     std::string new_value = current_range.first->second;
                     new_value += "," + add_vector.at(1);
                     request.header(add_vector.at(0), new_value);
+                // otherwise insert new header field.
                 } else {
                     request.header(add_vector.at(0), add_vector.at(1));
                 }
             }
         }
+        // Replace request header field using regular expression
         else if (it->first == "replace") {
+            // "Header-Field-Name":"From-Value(regex)":"To-Value"
             std::vector<std::string> replace_vector = split(it->second, ":", 3);
             if (replace_vector.size() == 3) {
                 field_range current_range = request.header(replace_vector.at(0));
@@ -114,6 +124,7 @@ void packet_editor::edit_client(char* client_msg, size_t& client_length)
                 boost::regex exp(replace_vector.at(1));
                 for (;current_range.first != current_range.second; current_range.first++) {
                     std::string new_value = current_range.first->second;
+                    // Replace only if exist
                     if (boost::regex_search(new_value, exp)) {
                         new_value = boost::regex_replace(new_value, exp, replace_vector.at(2));
                         request.header(replace_vector.at(0), new_value);
@@ -122,19 +133,27 @@ void packet_editor::edit_client(char* client_msg, size_t& client_length)
             }
         }
     }
+
+    /*
+     * Insert other protocol editor.
+     */
+
     std::string edited = request.as_string();
+    // New client message is too long (over buffer size)
     if (edited.size() > MAX_BUFFER_SIZE) {
-        // XXX log
-        return;
+        LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT, 1, "Edited message is too long. Drop message.");
+    }
+    else {
+        // Set new client message size.
+        client_length = edited.size();
+        // Set new client message.
+        memcpy(client_msg, edited.c_str(), client_length);
     }
-    client_length = edited.size();
-    memcpy(client_msg, edited.c_str(), client_length);
 
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 3, // XXX log
-        "out_function : void packet_editor::edit_client(char* client_msg, size_t& client_length) : "
-        "client_msg(%s), client_length(%d)", client_msg, client_length);
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 5,
+        "out_function : void packet_editor::edit_client(char* client_msg, size_t& client_length)");
     }
     /*------ DEBUG LOG END ------*/
 }
@@ -146,43 +165,53 @@ void packet_editor::edit_server(char* server_msg, size_t& server_length)
 {
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 3, // XXX log
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 6,
         "in_function : void packet_editor::edit_server(char* server_msg, size_t& server_length) : "
         "server_msg(%s), server_length(%d)", server_msg, server_length);
-        
     }
     /*------ DEBUG LOG END ------*/
 
+    // Edit HTTP (response header)
     std::list<std::pair<std::string, std::string > >::iterator it, end;
     it  = ::http_response_header.begin();
     end = ::http_response_header.end();
     http_response response(std::string(server_msg, server_length));
     for (;it != end; ++it) {
-        LOGGER_PUT_LOG_FATAL(LOG_CAT_PACKET_EDIT, 3, "mode: %s, header: %s", it->first.c_str(), it->second.c_str());
+        // Set request header field
         if (it->first == "set") {
+            // "Header-Field-Name":"Set-Value"
             std::vector<std::string> set_vector = split(it->second, ":", 2);
             if (set_vector.size() == 2)
                 expand_macro(set_vector.at(1));
+                // Overwrite or insert.
                 response.header(set_vector.at(0), set_vector.at(1));
         }
+        // Remove request header field
         else if (it->first == "unset") {
+            // "Header-Field-Name"
             response.header(it->second, "");
         }
+        // Add request header field
         else if (it->first == "add") {
+            // "Header-Field-Name":"Set-Value"
             std::vector<std::string> add_vector = split(it->second, ":", 2);
             if (add_vector.size() == 2) {
                 field_range current_range = response.header(add_vector.at(0));
                 expand_macro(add_vector.at(1));
+                // If header field already exists, concatinate values.
                 if (current_range.first != current_range.second) {
                     std::string new_value = current_range.first->second;
                     new_value += "," + add_vector.at(1);
                     response.header(add_vector.at(0), new_value);
+                // otherwise insert new header field.
                 } else {
                     response.header(add_vector.at(0), add_vector.at(1));
                 }
             }
         }
+        // Replace request header field using regular expression
         else if (it->first == "replace") {
+            // "Header-Field-Name":"From-Value(regex)":"To-Value"
             std::vector<std::string> replace_vector = split(it->second, ":", 3);
             if (replace_vector.size() == 3) {
                 field_range current_range = response.header(replace_vector.at(0));
@@ -191,6 +220,7 @@ void packet_editor::edit_server(char* server_msg, size_t& server_length)
                 boost::regex exp(replace_vector.at(1));
                 for (;current_range.first != current_range.second; current_range.first++) {
                     std::string new_value = current_range.first->second;
+                    // Replace only if exist
                     if (boost::regex_search(new_value, exp)) {
                         new_value = boost::regex_replace(new_value, exp, replace_vector.at(2));
                         response.header(replace_vector.at(0), new_value);
@@ -199,19 +229,27 @@ void packet_editor::edit_server(char* server_msg, size_t& server_length)
             }
         }
     }
+
+    /*
+     * Insert other protocol editor.
+     */
+
     std::string edited = response.as_string();
+    // New server message is too long (over buffer size)
     if (edited.size() > MAX_BUFFER_SIZE) {
-        // XXX log
-        return;
+        LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT, 2, "Edited message is too long. Drop message.");
+    }
+    else {
+        // Set new server message size.
+        server_length = edited.size();
+        // Set new server message.
+        memcpy(server_msg, edited.c_str(), server_length);
     }
-    server_length = edited.size();
-    memcpy(server_msg, edited.c_str(), server_length);
 
     /*-------- DEBUG LOG --------*/
     if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 3, // XXX log
-        "out_function : void packet_editor::edit_server(char* server_msg, size_t& server_length) : "
-        "server_msg(%s), server_length(%d)", server_msg, server_length);
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 7,
+        "out_function : void packet_editor::edit_server(char* server_msg, size_t& server_length)");
     }
     /*------ DEBUG LOG END ------*/
 }
@@ -222,6 +260,13 @@ void packet_editor::edit_server(char* server_msg, size_t& server_length)
  * @param[in/out]   source  string
  */
 void packet_editor::expand_macro(std::string& source) {
+    /*-------- DEBUG LOG --------*/
+    if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 8,
+        "in_function : void packet_editor::expand_macro(std::string& source) : "
+        "source(%s)", source.c_str());
+    }
+    /*------ DEBUG LOG END ------*/
     int pos;
 
     pos = source.find("%{CLIENT_ADDR}");
@@ -265,6 +310,13 @@ void packet_editor::expand_macro(std::string& source) {
         int port_begin = ::recv_endpoint.find(':') + 1;
         source.replace(pos, 12, ::recv_endpoint.substr(port_begin, ::recv_endpoint.length() - port_begin));
     }
+
+    /*-------- DEBUG LOG --------*/
+    if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 9,
+        "out_function : void packet_editor::expand_macro(std::string& source)");
+    }
+    /*------ DEBUG LOG END ------*/
 }
 
 /*!
@@ -278,6 +330,14 @@ void packet_editor::expand_macro(std::string& source) {
  * @param[in]   limit   max token
  */
 std::vector<std::string> packet_editor::split(const std::string& source, const std::string& delimiter, int limit = 0) {
+    /*-------- DEBUG LOG --------*/
+    if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 10,
+        "in_function : std::vector<std::string> packet_editor::split"
+        "(const std::string& source, const std::string& delimiter, int limit) : "
+        "source(%s), delimiter(%s), limit(%d)", source.c_str(), delimiter.c_str(), limit);
+    }
+    /*------ DEBUG LOG END ------*/
     std::vector<std::string> words;
     int begin = 0;
     int end   = source.size();
@@ -293,5 +353,12 @@ std::vector<std::string> packet_editor::split(const std::string& source, const s
         limit--;
     }
     words.push_back(source.substr(begin, end - begin));
+    /*-------- DEBUG LOG --------*/
+    if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
+        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 11,
+        "out_function : std::vector<std::string> packet_editor::split"
+        "(const std::string& source, const std::string& delimiter, int limit)");
+    }
+    /*------ DEBUG LOG END ------*/
     return words;
 }
index 05255ed..71ce5d1 100644 (file)
@@ -1202,7 +1202,7 @@ static int getParameters(std::string config_filename)
                            "http_request_header", request_map);
                        /*-------- DEBUG LOG --------*/
                        if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_SSLPROXY_COMMON)) {
-                               LOGGER_PUT_LOG_DEBUG(LOG_CAT_SSLPROXY_COMMON, 61, // XXX fix log
+                               LOGGER_PUT_LOG_DEBUG(LOG_CAT_SSLPROXY_COMMON, 101,
                                    "function : static int getParameters("
                                    "std::string config_filename) : "
                                    "get http_request_header OK.");
@@ -1213,8 +1213,8 @@ static int getParameters(std::string config_filename)
                        while (it != end) {
                                int delimiter_pos = it->second.find(':');
                                if (delimiter_pos == std::string::npos) {
-                                       LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, // XXX fix log
-                                           "Invalid http_request_header parameter value.");
+                                       LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 50,
+                                           "Invalid http_request_header parameter value.(no delimiter)");
                                        throw -1;
                                }
                                std::pair<std::string, std::string> header_pair(
@@ -1224,11 +1224,10 @@ static int getParameters(std::string config_filename)
                                  && header_pair.first != "unset"
                                  && header_pair.first != "add"
                                  && header_pair.first != "replace" ) {
-                                       LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, // XXX fix log
-                                           "Invalid http_request_header parameter value.");
+                                       LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 51,
+                                           "Invalid http_request_header parameter value.(invalid type)");
                                        throw -1;
                                }
-LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, "read: mode(%s) value(%s)", header_pair.first.c_str(), header_pair.second.c_str());
                                ::http_request_header.push_back(header_pair);
                                ::client_packet_edit = true;
                                it++;
@@ -1242,7 +1241,7 @@ LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, "read: mode(%s) value(%s)", he
                            "http_response_header", response_map);
                        /*-------- DEBUG LOG --------*/
                        if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_SSLPROXY_COMMON)) {
-                               LOGGER_PUT_LOG_DEBUG(LOG_CAT_SSLPROXY_COMMON, 61, // XXX fix log
+                               LOGGER_PUT_LOG_DEBUG(LOG_CAT_SSLPROXY_COMMON, 102,
                                    "function : static int getParameters("
                                    "std::string config_filename) : "
                                    "get http_response_header OK.");
@@ -1253,8 +1252,8 @@ LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, "read: mode(%s) value(%s)", he
                        while (it != end) {
                                int delimiter_pos = it->second.find(':');
                                if (delimiter_pos == std::string::npos) {
-                                       LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, // XXX fix log
-                                           "Invalid http_response_header parameter value.");
+                                       LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 52,
+                                           "Invalid http_response_header parameter value.(no delimiter)");
                                        throw -1;
                                }
                                std::pair<std::string, std::string> header_pair(
@@ -1264,11 +1263,10 @@ LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, "read: mode(%s) value(%s)", he
                                  && header_pair.first != "unset"
                                  && header_pair.first != "add"
                                  && header_pair.first != "replace" ) {
-                                       LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, // XXX fix log
-                                           "Invalid http_response_header parameter value.");
+                                       LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 53,
+                                           "Invalid http_response_header parameter value.(invalid type)");
                                        throw -1;
                                }
-LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, "read: mode(%s) value(%s)", header_pair.first.c_str(), header_pair.second.c_str());
                                ::http_response_header.push_back(header_pair);
                                ::server_packet_edit = true;
                                it++;