OSDN Git Service

Add log messages and comments.
[ultramonkey-l7/sslproxy.git] / src / http_request.cpp
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 ------*/