OSDN Git Service

Delete test files.
authorKohei TANUMA <tanuma@users.sourceforge.jp>
Mon, 10 Aug 2009 15:30:48 +0000 (00:30 +0900)
committerKohei TANUMA <tanuma@users.sourceforge.jp>
Mon, 10 Aug 2009 15:30:48 +0000 (00:30 +0900)
conf/Makefile.in
include/http_message.cpp [deleted file]
include/http_request.cpp [deleted file]

index f884a0e..4286f0d 100644 (file)
@@ -278,7 +278,7 @@ uninstall-am: uninstall-info-am
 
 install:
        $(INSTALL) -b -m 644 -D ./sslproxy.logger_init.cf /etc/l7vs/sslproxy/sslproxy.logger_init.cf
-       $(INSTALL) -b -m 644 -D ./sslproxy.target_1.cf /etc/l7vs/sslproxy/sslproxy.target.cf
+       $(INSTALL) -b -m 644 -D ./sslproxy.target.cf /etc/l7vs/sslproxy/sslproxy.target.cf
        $(INSTALL) -b -m 644 -D ./sslproxyadm.cf /etc/l7vs/sslproxy/sslproxyadm.cf
        $(INSTALL) -b -m 644 -D ./sslproxyadm.logrotate /etc/logrotate.d/sslproxyadm
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/include/http_message.cpp b/include/http_message.cpp
deleted file mode 100644 (file)
index 2d6b39d..0000000
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- * @file  http_message.cpp
- * @brief module of HTTP Message
- * @brief HTTP Message parser
- *
- * Copyright (C) 2009  NTT COMWARE Corporation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- **********************************************************************/
-
-#include "http_message.h"
-
-/*!
- * HTTP Message constructor.
- */
-http_message::http_message()
-    :
-    modified(false)
-{
-    /*-------- 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
-        "in/out_function : Constructor http_message::http_message(void)");
-    }
-    /*------ DEBUG LOG END ------*/
-}
-
-/*!
- * HTTP Message constructor.
- * Parse HTTP message header.
- *
- * @param[in]   header  full http message header string
- */
-http_message::http_message(std::string header)
-    :
-    modified(false)
-{
-    /*-------- 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
-        "in/out_function : Constructor http_message::http_message(std::string header) : "
-        "header(%s)", header.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-    this->parse(header);
-}
-
-/*!
- * HTTP Message destructor.
- */
-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
-        "in/out_function : Destructor http_message::~http_message(void)");
-    }
-    /*------ DEBUG LOG END ------*/
-}
-
-/*!
- * Get HTTP header field function.
- *
- * @param[in]   field_name  lookup field name
- * @return      header field value
- */
-field_range http_message::header(std::string field_name)
-{
-    /*-------- 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
-        "in_function : field_range http_message::header(std::string field_name) : "
-        "field_name(%s)", field_name.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    field_range ret = this->_header.get<field_map>().equal_range(field_name);
-
-    /*-------- 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 : field_range http_message::header(std::string field_name)");
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return ret;
-}
-
-/*!
- * Set HTTP header field function.
- * Set new HTTP header field and return old HTTP header field.
- *
- * @param[in]   field_name  lookup field name
- * @param[in]   field_value field value
- */
-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
-        "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());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    bool replaced = false;
-    field_range ret = this->_header.get<field_map>().equal_range(field_name);
-    field_map_iterator it = ret.first;
-    field_map_iterator it_end = ret.second;
-    for (;it != it_end; ++it) {
-        if ( _header.get<field_map>().replace(it, field(field_name, field_value)) ) {
-            replaced = true;
-            this->modified = true;
-        }
-    }
-    if (!replaced) {
-        _header.get<field_map>().insert( field(field_name, field_value) );
-        this->modified = true;
-    }
-
-    /*-------- 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 : field_range http_message::header(std::string field_name, std::string field_value)");
-    }
-    /*------ DEBUG LOG END ------*/
-}
-
-/*!
- * Get message body function.
- *
- * @return    message body
- */
-std::string http_message::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
-        "in_function : std::string http_message::body(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-        "out_function : std::string http_message::body(void) : "
-        "return(%s)", this->_body.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return this->_body;
-}
-
-/*!
- * Set message body function.
- * Set new message body and return old message body.
- *
- * @param[in]   _body   new message body
- * @return  old message body
- */
-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
-        "in_function : std::string http_message::http_version(std::string _message) : "
-        "_body(%s)", _body.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    std::string ret = this->_body;
-    this->_body = _body;
-    this->modified = true;
-
-    /*-------- 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 : std::string http_message::body(std::string _body) : "
-        "return(%s)", ret.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return ret;
-}
-
-/*!
- * Get full HTTP message function.
- *
- * @return    HTTP message
- */
-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
-        "in_function : std::string http_message::as_string(void)");
-    }
-    /*------ DEBUG LOG END ------*/
-
-    if (this->modified)
-        this->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
-        "out_function : std::string http_message::as_string(void) : "
-        "return(%s)", this->raw_message.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return this->raw_message;
-}
-
-/*!
- * Parse HTTP header function.
- *
- * @param[in]   message     full HTTP message header
- */
-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
-        "in_function : void http_message::parse(std::string message) : "
-        "message(%s)", message.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    // save raw message
-    this->raw_message = message;
-
-    // parse message
-    HTTP_MESSAGE_POSITION pos = MESSAGE_TOP;
-
-    /*
-     * RFC2616
-     *  OCTET       : 8bit data
-     *  CHAR        : US-ASCII(0-127)
-     *  UPALPHA     : A-Z
-     *  LOALPHA     : a-z
-     *  ALPHA       : UPALPHA | LOALPHA
-     *  DIGIT       : 0-9
-     *  HEXDIG      : A-F | a-f | DIGIT
-     *  SP          : SPace(32)
-     *  HT          : Horizontal Tab(9)
-     *  CR          : Carriage Return(13)
-     *  LF          : Line Feed(10)
-     *  CTL         : ConTLol char(0-31,127)
-     *  LWS         : [CRLF] 1*(SP|HT)
-     *  separators  : ()<>@,;:\"/[]?={} and SP, HT
-     *  token       : 1*(CHAR not CTL, separators)
-     */
-    std::string::iterator ptr = message.begin();
-    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()) {
-                    _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()) {
-                    _header.get<field_map>().insert(field_pair);
-                    field_pair.first.clear();
-                }
-                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_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.");
-                }
-                /*------ 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);
-                }
-                /*------ 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);
-                }
-                /*------ 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");
-                }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        /*
-         * MESSAGE-BODY     : *OCTET
-         */
-        case MESSAGE_LAST_LF:
-            pos = MESSAGE_BODY;
-            start = ptr;
-            break;
-
-        case MESSAGE_BODY:
-            break;
-        }
-        ptr++;
-    }
-
-    switch (pos) {
-    case MESSAGE_BODY:
-        this->_body.assign(start, 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)");
-    }
-    /*------ DEBUG LOG END ------*/
-}
-
-/*!
- * Rebuild HTTP header function.
- */
-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
-        "in_function : void http_message::rebuild()");
-    }
-    /*------ DEBUG LOG END ------*/
-
-    // insertion order
-    header_container::iterator it = this->_header.begin();
-    header_container::iterator it_end = this->_header.end();
-
-    while (it != it_end) {
-        this->raw_message += it->first + ": " + it->second + "\r\n";
-        it++;
-    }
-
-    this->raw_message += "\r\n" + this->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
-        "out_function : void http_message::rebuild()");
-    }
-    /*------ DEBUG LOG END ------*/
-}
-
-
-
-//============================
-
-void printheader(http_message& message, std::string name) {
-        field_range r;
-        r = message.header(name);
-        while (r.first != r.second) {
-            std::cout << "=======> HEADER(" << r.first->first << "): " << r.first->second<< std::endl;
-            r.first++;
-        }
-}
-
-void changeheader(http_message& message, std::string name, std::string value) {
-        message.header(name, value);
-        printheader(message, name);
-}
-
-int main() {
-
-    try {
-        http_message message("POST /index HTTP/1.1\r\nHost: localhost\r\nX-Forwarded-For: localhost\r\n  foobar\r\nAccept: */*\r\n\r\nMessageBODY");
-        std::cout << message.as_string() << std::endl;
-        printheader(message, "Host");
-        printheader(message, "X-Forwarded-For");
-        printheader(message, "Accept");
-        printheader(message, "Test");
-        changeheader(message, "Test", "new test");
-        changeheader(message, "Host", "new host");
-        std::cout << message.as_string() << std::endl;
-        std::cout << message.body("type=project&id=303") << std::endl;
-        std::cout << message.body() << std::endl;
-        std::cout << message.as_string() << std::endl;
-    }
-    catch(...) {}
-
-    try {
-        http_message r;
-        r.header("Host", "img.unitcom.co.jp");
-        r.header("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)");
-        r.header("Accept", "image/png,image/*;q=0.8,*/*;q=0.5");
-        r.header("Accept-Language", "ja,en-us;q=0.7,en;q=0.3");
-        r.header("Accept-Encoding", "gzip,deflate");
-        r.header("Accept-Charset", "Shift_JIS,utf-8;q=0.7,*;q=0.7");
-        r.header("Keep-Alive", "300");
-        r.header("Connection", "keep-alive");
-        r.header("Referer", "http://www.faith-go.co.jp/special/");
-        r.header("Cookie", "ASPSESSIONIDQCCQBQBR=HHKHICIACCKKHPIIECCOBOJG");
-        r.body("TEST__TEST");
-        std::cout << r.as_string() << std::endl;
-    }
-    catch(...) {}
-
-    try {
-std::string text = 
-"Host: 192.168.0.4:7780\r\n"
-"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)\r\n"
-"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
-"Accept-Language: ja,en-us;q=0.7,en;q=0.3\r\n"
-"Accept-Encoding: gzip,deflate\r\n"
-"Accept-Charset: Shift_JIS,utf-8;q=0.7,*;q=0.7\r\n"
-"Keep-Alive: 300\r\n"
-"Connection: keep-alive\r\n"
-"Cookie: rh_omni_tc=70160000000H4AoAAK; __utma=225840474.262789985507525570.1236909895.1236909895.1236909895.1; __utmz=225840474.1236909895.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); sch_target=mygroup; sch_d=3; sch_m=5; sch_y=2009; sch_move=weekly; PHPSESSID=pfn9gu39gkfq3cn16cr70q12b5; circular_kwd=; room_target=all; room_move=weekly; room_y=2009; room_m=4; room_d=27\r\n"
-"Cache-Control: max-age=0\r\n"
-"\r\n";
-        http_message re(text);
-        std::cout << re.as_string() << std::endl;
-    }
-    catch(...){}
-    return 0;
-}
diff --git a/include/http_request.cpp b/include/http_request.cpp
deleted file mode 100644 (file)
index ddf97dc..0000000
+++ /dev/null
@@ -1,979 +0,0 @@
-/*
- * @file  http_request.cpp
- * @brief module of HTTP Request
- * @brief HTTP Request parser
- *
- * Copyright (C) 2009  NTT COMWARE Corporation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- **********************************************************************/
-
-//#define DEBUG
-#include "http_request.h"
-
-/*!
- * HTTP Request constructor.
- */
-http_request::http_request()
-    :
-    modified(false)
-{
-    /*-------- 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
-        "in/out_function : Constructor http_request::http_request(void)");
-    }
-    /*------ DEBUG LOG END ------*/
-}
-
-/*!
- * HTTP Request constructor.
- * Parse HTTP request header.
- *
- * @param[in]   header  full http request header string
- */
-http_request::http_request(std::string header)
-    :
-    modified(false)
-{
-    /*-------- 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
-        "in/out_function : Constructor http_request::http_request(std::string header) : "
-        "header(%s)", header.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-    this->parse(header);
-}
-
-/*!
- * HTTP Request destructor.
- */
-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
-        "in/out_function : Destructor http_request::~http_request(void)");
-    }
-    /*------ DEBUG LOG END ------*/
-}
-
-/*!
- * Get method function.
- *
- * @return    method
- */
-std::string http_request::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
-        "in_function : std::string http_request::method(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-        "out_function : std::string http_request::method(void) : "
-        "return(%s)", this->_method.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return this->_method;
-}
-
-/*!
- * Set method function.
- * Set new method and return old method.
- *
- * @param[in]   method  new method
- * @return  old method
- */
-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
-        "in_function : std::string http_request::method(std::string _method) : "
-        "_method(%s)", _method.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    std::string ret = this->_method;
-    this->_method = _method;
-    this->modified = true;
-
-    /*-------- 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 : std::string http_request::method(std::string _method) : "
-        "return(%s)", ret.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return ret;
-}
-
-/*!
- * Get request URI function.
- *
- * @return    request URI
- */
-std::string http_request::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
-        "in_function : std::string http_request::request_uri(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-        "out_function : std::string http_request::request_uri(void) : "
-        "return(%s)", this->_request_uri.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return this->_request_uri;
-}
-
-/*!
- * Set request URI function.
- * Set new request URI and return old request URI.
- *
- * @param[in]   _request_uri    new request URI
- * @return  old request URI
- */
-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
-        "in_function : std::string http_request::request_uri(std::string _request_uri) : "
-        "_request_uri(%s)", _request_uri.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    std::string ret = this->_request_uri;
-    this->_request_uri = _request_uri;
-    this->modified = true;
-
-    /*-------- 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 : std::string http_request::_request_uri(std::string _request_uri) : "
-        "return(%s)", ret.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return ret;
-}
-
-/*!
- * Get HTTP version function.
- *
- * @return    HTTP version
- */
-std::string http_request::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
-        "in_function : std::string http_request::http_version(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-        "out_function : std::string http_request::http_version(void) : "
-        "return(%s)", this->_http_version.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return this->_http_version;
-}
-
-/*!
- * Set HTTP version function.
- * Set new HTTP version and return old HTTP version.
- *
- * @param[in]   _http_version   new HTTP version
- * @return  old HTTP version
- */
-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
-        "in_function : std::string http_request::http_version(std::string _http_version) : "
-        "_http_version(%s)", _http_version.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    std::string ret = this->_http_version;
-    this->_http_version = _http_version;
-    this->modified = true;
-
-    /*-------- 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 : std::string http_request::http_version(std::string _http_version) : "
-        "return(%s)", ret.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return ret;
-}
-
-/*!
- * Get HTTP header field function.
- *
- * @param[in]   field_name  lookup field name
- * @return      header field value
- */
-field_range http_request::header(std::string field_name)
-{
-    /*-------- 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
-        "in_function : field_range http_request::header(std::string field_name) : "
-        "field_name(%s)", field_name.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    field_range ret = this->_header.get<field_map>().equal_range(field_name);
-
-    /*-------- 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 : field_range http_request::header(std::string field_name)");
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return ret;
-}
-
-/*!
- * Set HTTP header field function.
- * Set new HTTP header field and return old HTTP header field.
- *
- * @param[in]   field_name  lookup field name
- * @param[in]   field_value field value
- */
-void http_request::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
-        "in_function : field_range http_request::header(std::string field_name, std::string field_value) : "
-        "field_name(%s), field_value(%s)", field_name.c_str(), field_value.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    bool replaced = false;
-    field_range ret = this->_header.get<field_map>().equal_range(field_name);
-    field_map_iterator it = ret.first;
-    field_map_iterator it_end = ret.second;
-    for (;it != it_end; ++it) {
-        if ( _header.get<field_map>().replace(it, field(field_name, field_value)) ) {
-            replaced = true;
-            this->modified = true;
-        }
-    }
-    if (!replaced) {
-        _header.get<field_map>().insert( field(field_name, field_value) );
-        this->modified = true;
-    }
-
-    /*-------- 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 : field_range http_request::header(std::string field_name, std::string field_value)");
-    }
-    /*------ DEBUG LOG END ------*/
-}
-
-/*!
- * Get message body function.
- *
- * @return    message body
- */
-std::string http_request::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
-        "in_function : std::string http_request::message(void)");
-        LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
-        "out_function : std::string http_request::message(void) : "
-        "return(%s)", this->_message.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return this->_message;
-}
-
-/*!
- * Set message body function.
- * Set new message body and return old message body.
- *
- * @param[in]   _message    new message body
- * @return  old message body
- */
-std::string http_request::message(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
-        "in_function : std::string http_request::http_version(std::string _message) : "
-        "_message(%s)", _message.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    std::string ret = this->_message;
-    this->_message = _message;
-    this->modified = true;
-
-    /*-------- 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 : std::string http_request::message(std::string _message) : "
-        "return(%s)", ret.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return ret;
-}
-
-/*!
- * Get request line function.
- *
- * @return    request line
- */
-std::string http_request::request_line()
-{
-    /*-------- 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
-        "in_function : std::string http_request::request_line(void)");
-    }
-    /*------ DEBUG LOG END ------*/
-
-    std::string ret = this->method() + " " + this->request_uri() + " " + this->http_version() + "\r\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 : std::string http_request::request_line(void) : "
-        "return(%s)", ret.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return ret;
-}
-
-/*!
- * Get full HTTP request function.
- *
- * @return    HTTP request
- */
-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
-        "in_function : std::string http_request::as_string(void)");
-    }
-    /*------ DEBUG LOG END ------*/
-
-    if (this->modified)
-        this->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
-        "out_function : std::string http_request::as_string(void) : "
-        "return(%s)", this->raw_request.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    return this->raw_request;
-}
-
-/*!
- * Parse HTTP header function.
- *
- * @param[in]   request     full HTTP request header
- */
-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
-        "in_function : void http_request::parse(std::string request) : "
-        "request(%s)", request.c_str());
-    }
-    /*------ DEBUG LOG END ------*/
-
-    // save raw request
-    this->raw_request = request;
-
-    // parse request
-    HTTP_REQUEST_POSITION pos = REQUEST_METHOD;
-
-    /*
-     * RFC2616
-     *  OCTET       : 8bit data
-     *  CHAR        : US-ASCII(0-127)
-     *  UPALPHA     : A-Z
-     *  LOALPHA     : a-z
-     *  ALPHA       : UPALPHA | LOALPHA
-     *  DIGIT       : 0-9
-     *  HEXDIG      : A-F | a-f | DIGIT
-     *  SP          : SPace(32)
-     *  HT          : Horizontal Tab(9)
-     *  CR          : Carriage Return(13)
-     *  LF          : Line Feed(10)
-     *  CTL         : ConTLol char(0-31,127)
-     *  LWS         : [CRLF] 1*(SP|HT)
-     *  separators  : ()<>@,;:\"/[]?={} and SP, HT
-     *  token       : 1*(CHAR not CTL, separators)
-     */
-    std::string::iterator ptr = request.begin();
-    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");
-                }
-                /*------ 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");
-                }
-                /*------ 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");
-                }
-                /*------ 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");
-                }
-                /*------ 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");
-                }
-                /*------ 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");
-                }
-                /*------ 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");
-                }
-                /*------ 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");
-                }
-                /*------ 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");
-                }
-                /*------ 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");
-                }
-                /*------ 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");
-                }
-                /*------ 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");
-                }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_CR:
-            // LF only
-            if (*ptr == '\n') {
-                pos = REQUEST_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;
-
-        /*
-         * 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 REQUEST_LF:
-            if (isalpha(*ptr) || *ptr == '-' || isdigit(*ptr) || 
-                *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == '!' ||
-                *ptr == '$' || *ptr == '&' || *ptr == '*' || *ptr == '+' ||
-                *ptr == '%') {
-                if (field_pair.first.length()) {
-                    _header.get<field_map>().insert(field_pair);
-                    field_pair.first.clear();
-                }
-                start = ptr;
-                pos = REQUEST_FIELD_NAME;
-            } else if (*ptr == ' ' || *ptr == '\t') {
-                pos = REQUEST_FIELD_VALUE;
-            } else if (*ptr == '\r') { // CRLF + CRLF
-                if (field_pair.first.length()) {
-                    _header.get<field_map>().insert(field_pair);
-                    field_pair.first.clear();
-                }
-                pos = REQUEST_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_request::parse(std::string request) : not CRLF");
-                }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_FIELD_NAME:
-            // field-name end with ':'
-            if (*ptr == ':') {
-                pos = REQUEST_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_request::parse(std::string request) : Invalid header field name.");
-                }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_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 = REQUEST_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_request::parse(std::string request) : Invalid header field value.('%c')", *ptr);
-                }
-                /*------ DEBUG LOG END ------*/
-            }
-            break;
-
-        case REQUEST_FIELD_VALUE:
-            // field-value end with CR
-            if (*ptr == '\r') {
-                pos = REQUEST_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_request::parse(std::string request) : Invalid header field value.('%c')", *ptr);
-                }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        case REQUEST_LAST_CR:
-            // LF only
-            if (*ptr == '\n') {
-                pos = REQUEST_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_request::parse(std::string request) : not CRLF");
-                }
-                /*------ DEBUG LOG END ------*/
-                throw -1;
-            }
-            break;
-
-        /*
-         * MESSAGE-BODY     : *OCTET
-         */
-        case REQUEST_LAST_LF:
-            pos = REQUEST_MESSAGE;
-            start = ptr;
-            break;
-
-        case REQUEST_MESSAGE:
-            break;
-        }
-        ptr++;
-    }
-
-    switch (pos) {
-    case REQUEST_MESSAGE:
-        this->_message.assign(start, 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)");
-    }
-    /*------ DEBUG LOG END ------*/
-}
-
-/*!
- * Rebuild HTTP header function.
- */
-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
-        "in_function : void http_request::rebuild()");
-    }
-    /*------ DEBUG LOG END ------*/
-
-    this->raw_request = this->request_line();
-    // insertion order
-    header_container::iterator it = this->_header.begin();
-    header_container::iterator it_end = this->_header.end();
-
-    while (it != it_end) {
-        this->raw_request += it->first + ": " + it->second + "\r\n";
-        it++;
-    }
-
-    this->raw_request += "\r\n" + this->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
-        "out_function : void http_request::rebuild()");
-    }
-    /*------ DEBUG LOG END ------*/
-}
-
-void printheader(http_request& request, std::string name) {
-        field_range r;
-        r = request.header(name);
-        while (r.first != r.second) {
-            std::cout << "=======> HEADER(" << r.first->first << "): " << r.first->second<< std::endl;
-            r.first++;
-        }
-}
-
-void changeheader(http_request& request, std::string name, std::string value) {
-        request.header(name, value);
-        printheader(request, name);
-}
-
-int main() {
-/*
-    try {
-        http_request req;
-        req.parse("GET / HTTP/1.0\n");
-        std::cout << "=======> METHOD: " << req.method() << std::endl;
-    }
-    catch(...) {}
-*/
-
-    try {
-        http_request request("POST /index HTTP/1.1\r\nHost: localhost\r\nX-Forwarded-For: localhost\r\n  foobar\r\nAccept: */*\r\n\r\nMessageBODY");
-        std::cout << request.as_string() << std::endl;
-        std::cout << "=======> METHOD: " << request.method() << std::endl;
-        std::cout << "=======> URI: " << request.request_uri() << std::endl;
-        std::cout << "=======> VERSION: " << request.http_version() << std::endl;
-        printheader(request, "Host");
-        printheader(request, "X-Forwarded-For");
-        printheader(request, "Accept");
-        printheader(request, "Test");
-        changeheader(request, "Test", "new test");
-        changeheader(request, "Host", "new host");
-        std::cout << request.as_string() << std::endl;
-        std::cout << request.request_line() << std::endl;
-//        std::cout << request.method("TRACE") << std::endl;
-//        std::cout << request.request_uri("/?type=project&id=393") << std::endl;
-//        std::cout << request.http_version("HTTP/1.0") << std::endl;
-        std::cout << request.request_line() << std::endl;
-        std::cout << request.message("type=project&id=303") << std::endl;
-        std::cout << request.message() << std::endl;
-        std::cout << request.as_string() << std::endl;
-    }
-    catch(...) {}
-
-    try {
-        http_request r;
-        r.method("GET");
-        r.request_uri("/index.html");
-        r.http_version("HTTP/1.1");
-        r.header("Host", "img.unitcom.co.jp");
-        r.header("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)");
-        r.header("Accept", "image/png,image/*;q=0.8,*/*;q=0.5");
-        r.header("Accept-Language", "ja,en-us;q=0.7,en;q=0.3");
-        r.header("Accept-Encoding", "gzip,deflate");
-        r.header("Accept-Charset", "Shift_JIS,utf-8;q=0.7,*;q=0.7");
-        r.header("Keep-Alive", "300");
-        r.header("Connection", "keep-alive");
-        r.header("Referer", "http://www.faith-go.co.jp/special/");
-        r.header("Cookie", "ASPSESSIONIDQCCQBQBR=HHKHICIACCKKHPIIECCOBOJG");
-        r.message("TEST__TEST");
-        std::cout << r.as_string() << std::endl;
-    }
-    catch(...) {}
-
-    try {
-std::string text = 
-"GET /cgi-bin/env.cgi HTTP/1.1\r\n"
-"Host: 192.168.0.4:7780\r\n"
-"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)\r\n"
-"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
-"Accept-Language: ja,en-us;q=0.7,en;q=0.3\r\n"
-"Accept-Encoding: gzip,deflate\r\n"
-"Accept-Charset: Shift_JIS,utf-8;q=0.7,*;q=0.7\r\n"
-"Keep-Alive: 300\r\n"
-"Connection: keep-alive\r\n"
-"Cookie: rh_omni_tc=70160000000H4AoAAK; __utma=225840474.262789985507525570.1236909895.1236909895.1236909895.1; __utmz=225840474.1236909895.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); sch_target=mygroup; sch_d=3; sch_m=5; sch_y=2009; sch_move=weekly; PHPSESSID=pfn9gu39gkfq3cn16cr70q12b5; circular_kwd=; room_target=all; room_move=weekly; room_y=2009; room_m=4; room_d=27\r\n"
-"Cache-Control: max-age=0\r\n"
-"\r\n";
-        http_request re(text);
-        std::cout << re.as_string() << std::endl;
-    }
-    catch(...){}
-    return 0;
-}