{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 1, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 1,
"in/out_function : Constructor http_message::http_message(void)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 1, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 2,
"in/out_function : Constructor http_message::http_message(std::string header) : "
"header(%s)", header.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 2, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3,
"in/out_function : Destructor http_message::~http_message(void)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 4,
"in_function : field_range http_message::header(std::string field_name) : "
"field_name(%s)", field_name.c_str());
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 5,
"out_function : field_range http_message::header(std::string field_name)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 6,
"in_function : field_range http_message::header(std::string field_name, std::string field_value) : "
"field_name(%s), field_value(%s)", field_name.c_str(), field_value.c_str());
}
}
}
catch (...) {
- // XXX log: insert, replace (no throw by erase)
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 1,
+ "Exception occured by inserting or replacing boost::multi_index.");
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 7,
"out_function : field_range http_message::header(std::string field_name, std::string field_value)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 8,
"in_function : std::string http_message::body(void)");
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 9,
"out_function : std::string http_message::body(void) : "
"return(%s)", this->_body.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 10,
"in_function : std::string http_message::http_version(std::string _message) : "
"_body(%s)", _body.c_str());
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 11,
"out_function : std::string http_message::body(std::string _body) : "
"return(%s)", ret.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 12,
"in_function : std::string http_message::as_string(void)");
}
/*------ DEBUG LOG END ------*/
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 13,
"out_function : std::string http_message::as_string(void) : "
"return(%s)", this->raw_message.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 14,
"in_function : void http_message::parse(std::string message) : "
"message(%s)", message.c_str());
}
std::string::iterator end = message.end();
std::string::iterator start = ptr;
std::pair<std::string, std::string> field_pair;
- while (ptr != end) {
- switch(pos) {
- /*
- * MESSAGE-HEADER : field-name ":" [ field-value ]
- * field-name : token
- * field-value : *( field-content | LWS )
- * field-content : <the OCTETs making up the field-value and
- * consisting of either *TEXT or combinations
- * of token, separators, and quoted-string>
- * TEXT : <any OCTET except CTLs, but including LWS>
- * quoted-string : ( <"> *(qdtext | quoted-pair ) <"> )
- * qdtext : <any TEXT except <">>
- * quoted-pair : "\" CHAR
- */
- case MESSAGE_TOP:
- if (isalpha(*ptr) || *ptr == '-' || isdigit(*ptr) ||
- *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == '!' ||
- *ptr == '$' || *ptr == '&' || *ptr == '*' || *ptr == '+' ||
- *ptr == '%') {
- start = ptr;
- pos = MESSAGE_FIELD_NAME;
- } else if (*ptr == '\r') { // CRLF + CRLF
- pos = MESSAGE_LAST_CR;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_message::parse(std::string message) : not CRLF");
- }
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case MESSAGE_CR:
- // LF only
- if (*ptr == '\n') {
- pos = MESSAGE_LF;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_request::parse(std::string request) : not CRLF");
- }
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case MESSAGE_LF:
- if (isalpha(*ptr) || *ptr == '-' || isdigit(*ptr) ||
- *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == '!' ||
- *ptr == '$' || *ptr == '&' || *ptr == '*' || *ptr == '+' ||
- *ptr == '%') {
- if (field_pair.first.length()) {
- field_pair.first = convert_upper_camel_case(field_pair.first);
- boost::trim(field_pair.second);
- _header.get<field_map>().insert(field_pair);
- field_pair.first.clear();
+ try {
+ while (ptr != end) {
+ switch(pos) {
+ /*
+ * MESSAGE-HEADER : field-name ":" [ field-value ]
+ * field-name : token
+ * field-value : *( field-content | LWS )
+ * field-content : <the OCTETs making up the field-value and
+ * consisting of either *TEXT or combinations
+ * of token, separators, and quoted-string>
+ * TEXT : <any OCTET except CTLs, but including LWS>
+ * quoted-string : ( <"> *(qdtext | quoted-pair ) <"> )
+ * qdtext : <any TEXT except <">>
+ * quoted-pair : "\" CHAR
+ */
+ case MESSAGE_TOP:
+ if (isalpha(*ptr) || *ptr == '-' || isdigit(*ptr) ||
+ *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == '!' ||
+ *ptr == '$' || *ptr == '&' || *ptr == '*' || *ptr == '+' ||
+ *ptr == '%') {
+ start = ptr;
+ pos = MESSAGE_FIELD_NAME;
+ } else if (*ptr == '\r') { // CRLF + CRLF
+ pos = MESSAGE_LAST_CR;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 2,
+ "Parse error: Invalid header field name.(%c)", *ptr);
+ throw -1;
}
- start = ptr;
- pos = MESSAGE_FIELD_NAME;
- } else if (*ptr == ' ' || *ptr == '\t') {
- pos = MESSAGE_FIELD_VALUE;
- } else if (*ptr == '\r') { // CRLF + CRLF
- if (field_pair.first.length()) {
- field_pair.first = convert_upper_camel_case(field_pair.first);
- boost::trim(field_pair.second);
- _header.get<field_map>().insert(field_pair);
- field_pair.first.clear();
+ break;
+
+ case MESSAGE_CR:
+ // LF only
+ if (*ptr == '\n') {
+ pos = MESSAGE_LF;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 3,
+ "Parse error: No LF.(%c)", *ptr);
+ throw -1;
}
- pos = MESSAGE_LAST_CR;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_message::parse(std::string message) : not CRLF");
+ break;
+
+ case MESSAGE_LF:
+ if (isalpha(*ptr) || *ptr == '-' || isdigit(*ptr) ||
+ *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == '!' ||
+ *ptr == '$' || *ptr == '&' || *ptr == '*' || *ptr == '+' ||
+ *ptr == '%') {
+ if (field_pair.first.length()) {
+ field_pair.first = convert_upper_camel_case(field_pair.first);
+ boost::trim(field_pair.second);
+ _header.get<field_map>().insert(field_pair);
+ field_pair.first.clear();
+ }
+ start = ptr;
+ pos = MESSAGE_FIELD_NAME;
+ } else if (*ptr == ' ' || *ptr == '\t') {
+ pos = MESSAGE_FIELD_VALUE;
+ } else if (*ptr == '\r') { // CRLF + CRLF
+ if (field_pair.first.length()) {
+ field_pair.first = convert_upper_camel_case(field_pair.first);
+ boost::trim(field_pair.second);
+ _header.get<field_map>().insert(field_pair);
+ field_pair.first.clear();
+ }
+ pos = MESSAGE_LAST_CR;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 4,
+ "Parse error: Invalid header field name.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case MESSAGE_FIELD_NAME:
- // field-name end with ':'
- if (*ptr == ':') {
- pos = MESSAGE_FIELD_NAME_COLON;
- field_pair.first.assign(start, ptr);
- } else if (!isalpha(*ptr) && *ptr != '-' && !isdigit(*ptr) &&
- *ptr != '.' && *ptr != '_' && *ptr != '~' && *ptr != '!' &&
- *ptr != '$' && *ptr != '&' && *ptr != '*' && *ptr != '+' &&
- *ptr != '%') {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_message::parse(std::string message) : Invalid header field name.");
+ break;
+
+ case MESSAGE_FIELD_NAME:
+ // field-name end with ':'
+ if (*ptr == ':') {
+ pos = MESSAGE_FIELD_NAME_COLON;
+ field_pair.first.assign(start, ptr);
+ } else if (!isalpha(*ptr) && *ptr != '-' && !isdigit(*ptr) &&
+ *ptr != '.' && *ptr != '_' && *ptr != '~' && *ptr != '!' &&
+ *ptr != '$' && *ptr != '&' && *ptr != '*' && *ptr != '+' &&
+ *ptr != '%') {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 5,
+ "Parse error: Invalid header field name.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case MESSAGE_FIELD_NAME_COLON:
- if (*ptr == ' ' || isalpha(*ptr) || isdigit(*ptr) || *ptr == '-' ||
- *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == ':' ||
- *ptr == '@' || *ptr == '!' || *ptr == '$' || *ptr == '&' ||
- *ptr == '(' || *ptr == ')' || *ptr == '*' || *ptr == '+' ||
- *ptr == ',' || *ptr == ';' || *ptr == '=' || *ptr == '%' ||
- *ptr == '<' || *ptr == '>' || *ptr == '[' || *ptr == ']' ||
- *ptr == '{' || *ptr == '}' || *ptr == '?' || *ptr == '"' ||
- *ptr == '|' || *ptr == '/' || *ptr == '\\' || *ptr == '\t') {
- start = ptr;
- pos = MESSAGE_FIELD_VALUE;
- } else if (*ptr == '\r') { // omit field value
- field_pair.second.clear();
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_message::parse(std::string message) : Invalid header field value.('%c')", *ptr);
+ break;
+
+ case MESSAGE_FIELD_NAME_COLON:
+ if (*ptr == ' ' || isalpha(*ptr) || isdigit(*ptr) || *ptr == '-' ||
+ *ptr == '.' || *ptr == '_' || *ptr == '~' || *ptr == ':' ||
+ *ptr == '@' || *ptr == '!' || *ptr == '$' || *ptr == '&' ||
+ *ptr == '(' || *ptr == ')' || *ptr == '*' || *ptr == '+' ||
+ *ptr == ',' || *ptr == ';' || *ptr == '=' || *ptr == '%' ||
+ *ptr == '<' || *ptr == '>' || *ptr == '[' || *ptr == ']' ||
+ *ptr == '{' || *ptr == '}' || *ptr == '?' || *ptr == '"' ||
+ *ptr == '|' || *ptr == '/' || *ptr == '\\' || *ptr == '\t') {
+ start = ptr;
+ pos = MESSAGE_FIELD_VALUE;
+ } else if (*ptr == '\r') { // omit field value
+ field_pair.second.clear();
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 6,
+ "Parse error: Invalid header field value.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- }
- break;
-
- case MESSAGE_FIELD_VALUE:
- // field-value end with CR
- if (*ptr == '\r') {
- pos = MESSAGE_CR;
- field_pair.second.assign(start, ptr);
- } else if (*ptr != ' ' && !isalpha(*ptr) && !isdigit(*ptr) && *ptr != '-' &&
- *ptr != '.' && *ptr != '_' && *ptr != '~' && *ptr != ':' &&
- *ptr != '@' && *ptr != '!' && *ptr != '$' && *ptr != '&' &&
- *ptr != '(' && *ptr != ')' && *ptr != '*' && *ptr != '+' &&
- *ptr != ',' && *ptr != ';' && *ptr != '=' && *ptr != '%' &&
- *ptr != '<' && *ptr != '>' && *ptr != '[' && *ptr != ']' &&
- *ptr != '{' && *ptr != '}' && *ptr != '?' && *ptr != '"' &&
- *ptr != '|' && *ptr != '/' && *ptr != '\\'&& *ptr != '\t' ) {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_message::parse(std::string message) : Invalid header field value.('%c')", *ptr);
+ break;
+
+ case MESSAGE_FIELD_VALUE:
+ // field-value end with CR
+ if (*ptr == '\r') {
+ pos = MESSAGE_CR;
+ field_pair.second.assign(start, ptr);
+ } else if (*ptr != ' ' && !isalpha(*ptr) && !isdigit(*ptr) && *ptr != '-' &&
+ *ptr != '.' && *ptr != '_' && *ptr != '~' && *ptr != ':' &&
+ *ptr != '@' && *ptr != '!' && *ptr != '$' && *ptr != '&' &&
+ *ptr != '(' && *ptr != ')' && *ptr != '*' && *ptr != '+' &&
+ *ptr != ',' && *ptr != ';' && *ptr != '=' && *ptr != '%' &&
+ *ptr != '<' && *ptr != '>' && *ptr != '[' && *ptr != ']' &&
+ *ptr != '{' && *ptr != '}' && *ptr != '?' && *ptr != '"' &&
+ *ptr != '|' && *ptr != '/' && *ptr != '\\'&& *ptr != '\t' ) {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 7,
+ "Parse error: Invalid header field value.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case MESSAGE_LAST_CR:
- // LF only
- if (*ptr == '\n') {
- pos = MESSAGE_LAST_LF;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_message::parse(std::string message) : not CRLF");
+ break;
+
+ case MESSAGE_LAST_CR:
+ // LF only
+ if (*ptr == '\n') {
+ pos = MESSAGE_LAST_LF;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 8,
+ "Parse error: No LF.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
+ break;
+
+ /*
+ * MESSAGE-BODY : *OCTET
+ */
+ case MESSAGE_LAST_LF:
+ pos = MESSAGE_BODY;
+ start = ptr;
+ break;
+
+ case MESSAGE_BODY:
+ break;
}
- break;
-
- /*
- * MESSAGE-BODY : *OCTET
- */
- case MESSAGE_LAST_LF:
- pos = MESSAGE_BODY;
- start = ptr;
- break;
-
+ ptr++;
+ }
+
+ switch (pos) {
case MESSAGE_BODY:
- break;
+ this->_body.assign(start, ptr);
}
- ptr++;
}
-
- switch (pos) {
- case MESSAGE_BODY:
- this->_body.assign(start, ptr);
+ catch (...) {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 9,
+ "Exception occured by parsing HTTP message.");
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 15,
"out_function : void http_message::parse(std::string message)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 16,
"in_function : void http_message::rebuild()");
}
/*------ DEBUG LOG END ------*/
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 17,
"out_function : void http_message::rebuild()");
}
/*------ DEBUG LOG END ------*/
/*!
* Field name convert function.
+ * Convert upper camelcase
+ * ex. connecTION => Connection
+ * usEr-aGeNT => User-Agent
+ * p3p => P3P
*
* @param[in] field_name field name
* @return converted to camel case
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 18,
"in_function : std::string http_message::upper_camel_case(std::string field_name) : "
"field_name(%s)", field_name.c_str());
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 19,
"out_function : std::string http_message::upper_camel_case(std::string field_name) : "
"return(%s)", ret.c_str());
}
{
/*-------- 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 ------*/
{
/*-------- 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());
}
{
/*-------- 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 ------*/
{
/*-------- 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());
}
{
/*-------- 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());
}
/*-------- 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());
}
{
/*-------- 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());
}
{
/*-------- 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());
}
/*-------- 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());
}
{
/*-------- 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());
}
{
/*-------- 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());
}
/*-------- 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());
}
{
/*-------- 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 ------*/
/*-------- 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());
}
{
/*-------- 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 ------*/
/*-------- 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());
}
{
/*-------- 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());
}
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 ------*/
{
/*-------- 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 ------*/
/*-------- 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 ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 1, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 43,
"in/out_function : Constructor http_response::http_response(void)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 1, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 44,
"in/out_function : Constructor http_response::http_response(std::string header) : "
"header(%s)", header.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 2, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 45,
"in/out_function : Destructor http_response::~http_response(void)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 46,
"in_function : std::string http_response::http_version(void)");
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 47,
"out_function : std::string http_response::http_version(void) : "
"return(%s)", this->_http_version.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 48,
"in_function : std::string http_response::http_version(std::string _http_version) : "
"_http_version(%s)", _http_version.c_str());
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 49,
"out_function : std::string http_response::http_version(std::string _http_version) : "
"return(%s)", ret.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 50,
"in_function : std::string http_response::status_code(void)");
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 51,
"out_function : std::string http_response::status_code(void) : "
"return(%s)", this->_status_code.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 52,
"in_function : std::string http_response::status_code(std::string _status_code) : "
"_status_code(%s)", _status_code.c_str());
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 53,
"out_function : std::string http_response::status_code(std::string _status_code) : "
"return(%s)", ret.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 54,
"in_function : std::string http_response::reason_phrase(void)");
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 55,
"out_function : std::string http_response::reason_phrase(void) : "
"return(%s)", this->_reason_phrase.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 56,
"in_function : std::string http_response::reason_phrase(std::string _reason_phrase) : "
"_reason_phrase(%s)", _reason_phrase.c_str());
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 57,
"out_function : std::string http_response::reason_phrase(std::string _reason_phrase) : "
"return(%s)", ret.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 58,
"in_function : std::string http_response::status_line(void)");
}
/*------ DEBUG LOG END ------*/
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 59,
"out_function : std::string http_response::status_line(void) : "
"return(%s)", ret.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 60,
"in_function : std::string http_response::as_string(void)");
}
/*------ DEBUG LOG END ------*/
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 61,
"out_function : std::string http_response::as_string(void) : "
"return(%s)", this->raw_message.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 62,
"in_function : void http_response::parse(std::string response) : "
"response(%s)", response.c_str());
}
std::string::iterator end = response.end();
std::string::iterator start = ptr;
std::pair<std::string, std::string> field_pair;
- while (ptr != end) {
- switch(pos) {
- /*
- * STATUS-LINE :
- * HTTP-VERSION SP STATUS-CODE SP REASON-PHRASE CRLF
- */
- /*
- * HTTP-VERSION : "HTTP" "/" 1*DIGIT "." 1*DIGIT
- */
- case RESPONSE_TOP:
- // HTTP-VERSION start
- if (*ptr == 'H') {
- pos = RESPONSE_HTTP_VERSION_H;
- start = ptr;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ try {
+ while (ptr != end) {
+ switch(pos) {
+ /*
+ * STATUS-LINE :
+ * HTTP-VERSION SP STATUS-CODE SP REASON-PHRASE CRLF
+ */
+ /*
+ * HTTP-VERSION : "HTTP" "/" 1*DIGIT "." 1*DIGIT
+ */
+ case RESPONSE_TOP:
+ // HTTP-VERSION start
+ if (*ptr == 'H') {
+ pos = RESPONSE_HTTP_VERSION_H;
+ start = ptr;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 24,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_H:
- // HTTP-VERSION next
- if (*ptr == 'T') {
- pos = RESPONSE_HTTP_VERSION_T1;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_H:
+ // HTTP-VERSION next
+ if (*ptr == 'T') {
+ pos = RESPONSE_HTTP_VERSION_T1;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 25,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_T1:
- // HTTP-VERSION next
- if (*ptr == 'T') {
- pos = RESPONSE_HTTP_VERSION_T2;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_T1:
+ // HTTP-VERSION next
+ if (*ptr == 'T') {
+ pos = RESPONSE_HTTP_VERSION_T2;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 26,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_T2:
- // HTTP-VERSION next
- if (*ptr == 'P') {
- pos = RESPONSE_HTTP_VERSION_P;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_T2:
+ // HTTP-VERSION next
+ if (*ptr == 'P') {
+ pos = RESPONSE_HTTP_VERSION_P;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 27,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_P:
- // HTTP-VERSION next
- if (*ptr == '/') {
- pos = RESPONSE_HTTP_VERSION_SLASH;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_P:
+ // HTTP-VERSION next
+ if (*ptr == '/') {
+ pos = RESPONSE_HTTP_VERSION_SLASH;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 28,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_SLASH:
- // HTTP-VERSION Mejor number
- if (isdigit(*ptr)) {
- pos = RESPONSE_HTTP_VERSION_MAJOR;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_SLASH:
+ // HTTP-VERSION Mejor number
+ if (isdigit(*ptr)) {
+ pos = RESPONSE_HTTP_VERSION_MAJOR;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 29,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_MAJOR:
- // HTTP-VERSION next dot
- if (*ptr == '.') {
- pos = RESPONSE_HTTP_VERSION_DOT;
- } else if (!isdigit(*ptr)) {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_MAJOR:
+ // HTTP-VERSION next dot
+ if (*ptr == '.') {
+ pos = RESPONSE_HTTP_VERSION_DOT;
+ } else if (!isdigit(*ptr)) {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 30,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_DOT:
- // HTTP-VERSION Minor number
- if (isdigit(*ptr)) {
- pos = RESPONSE_HTTP_VERSION_MINOR;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_DOT:
+ // HTTP-VERSION Minor number
+ if (isdigit(*ptr)) {
+ pos = RESPONSE_HTTP_VERSION_MINOR;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 31,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_MINOR:
- // HTTP-VERSION end with SP
- if (*ptr == ' ') {
- pos = RESPONSE_HTTP_VERSION_SP;
- this->_http_version.assign(start, ptr);
- } else if (!isdigit(*ptr)) {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_MINOR:
+ // HTTP-VERSION end with SP
+ if (*ptr == ' ') {
+ pos = RESPONSE_HTTP_VERSION_SP;
+ this->_http_version.assign(start, ptr);
+ } else if (!isdigit(*ptr)) {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 32,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- /*
- * Status-Code : 3DIGIT
- */
- case RESPONSE_HTTP_VERSION_SP:
- // STATUS-CODE start
- if (isdigit(*ptr)) {
- pos = RESPONSE_STATUS_CODE1;
- start = ptr;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Status-Code");
+ break;
+
+ /*
+ * Status-Code : 3DIGIT
+ */
+ case RESPONSE_HTTP_VERSION_SP:
+ // STATUS-CODE start
+ if (isdigit(*ptr)) {
+ pos = RESPONSE_STATUS_CODE1;
+ start = ptr;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 33,
+ "Parse error: Invalid status-code.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_STATUS_CODE1:
- // STATUS-CODE next
- if (isdigit(*ptr)) {
- pos = RESPONSE_STATUS_CODE2;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Status-Code");
+ break;
+
+ case RESPONSE_STATUS_CODE1:
+ // STATUS-CODE next
+ if (isdigit(*ptr)) {
+ pos = RESPONSE_STATUS_CODE2;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 34,
+ "Parse error: Invalid status-code.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_STATUS_CODE2:
- // STATUS-CODE next
- if (isdigit(*ptr)) {
- pos = RESPONSE_STATUS_CODE3;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Status-Code");
+ break;
+
+ case RESPONSE_STATUS_CODE2:
+ // STATUS-CODE next
+ if (isdigit(*ptr)) {
+ pos = RESPONSE_STATUS_CODE3;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 35,
+ "Parse error: Invalid status-code.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_STATUS_CODE3:
- // Status-Code end with SP
- if (*ptr == ' ') {
- pos = RESPONSE_STATUS_CODE_SP;
- this->_status_code.assign(start, ptr);
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Status-Code");
+ break;
+
+ case RESPONSE_STATUS_CODE3:
+ // Status-Code end with SP
+ if (*ptr == ' ') {
+ pos = RESPONSE_STATUS_CODE_SP;
+ this->_status_code.assign(start, ptr);
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 36,
+ "Parse error: Invalid status-code.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- /*
- * Reason-Phrase : *<TEXT, excluding CR, LF>
- */
- case RESPONSE_STATUS_CODE_SP:
- // Reason-Phrase is OCTET
- if (*ptr == '\r') { // omit reason-phrase
- pos = RESPONSE_CR;
- this->_reason_phrase.clear();
- } else if (*ptr != '\n') {
- pos = RESPONSE_REASON_PHRASE;
- start = ptr;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Reason-Phrase");
+ break;
+
+ /*
+ * Reason-Phrase : *<TEXT, excluding CR, LF>
+ */
+ case RESPONSE_STATUS_CODE_SP:
+ // Reason-Phrase is OCTET
+ if (*ptr == '\r') { // omit reason-phrase
+ pos = RESPONSE_CR;
+ this->_reason_phrase.clear();
+ } else if (*ptr != '\n') {
+ pos = RESPONSE_REASON_PHRASE;
+ start = ptr;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 37,
+ "Parse error: Invalid reason-phrase.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_REASON_PHRASE:
- // Reason-Phrase end with CR
- if (*ptr == '\r') {
- pos = RESPONSE_CR;
- this->_reason_phrase.assign(start, ptr);
- } else if (*ptr == '\n') {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Reason-Phrase");
+ break;
+
+ case RESPONSE_REASON_PHRASE:
+ // Reason-Phrase end with CR
+ if (*ptr == '\r') {
+ pos = RESPONSE_CR;
+ this->_reason_phrase.assign(start, ptr);
+ } else if (*ptr == '\n') {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 38,
+ "Parse error: Invalid reason-phrase.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_CR:
- // LF only
- if (*ptr == '\n') {
- pos = RESPONSE_LF;
- http_message::parse(std::string(ptr + 1, end));
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : not CRLF");
+ break;
+
+ case RESPONSE_CR:
+ // LF only
+ if (*ptr == '\n') {
+ pos = RESPONSE_LF;
+ http_message::parse(std::string(ptr + 1, end));
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 39,
+ "Parse error: No LF.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
+ break;
}
- break;
+ if (pos == RESPONSE_LF)
+ break;
+ ptr++;
}
- if (pos == RESPONSE_LF)
- break;
- ptr++;
+ }
+ catch (...) {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 40,
+ "Exception occured by parsing HTTP response.");
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 63,
"out_function : void http_response::parse(std::string response)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 64,
"in_function : void http_response::rebuild()");
}
/*------ DEBUG LOG END ------*/
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 65,
"out_function : void http_response::rebuild()");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 1, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 1,
"in_function : Constructor packet_editor::packet_editor(const sslproxysession* session)");
}
/*------ DEBUG LOG END ------*/
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 1, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 2,
"out_function : Constructor packet_editor::packet_editor(const sslproxysession* session)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 2, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 3,
"in/out_function : Destructor packet_editor::~packet_editor(void)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 4,
"in_function : void packet_editor::edit_client(char* client_msg, size_t& client_length) : "
"client_msg(%s), client_length(%d)", client_msg, client_length);
-
}
/*------ DEBUG LOG END ------*/
+ // Edit HTTP (request header)
std::list<std::pair<std::string, std::string > >::iterator it, end;
it = ::http_request_header.begin();
end = ::http_request_header.end();
http_request request(std::string(client_msg, client_length));
for (;it != end; ++it) {
- LOGGER_PUT_LOG_FATAL(LOG_CAT_PACKET_EDIT, 3, "mode: %s, header: %s", it->first.c_str(), it->second.c_str());
+ // Set request header field
if (it->first == "set") {
+ // "Header-Field-Name":"Set-Value"
std::vector<std::string> set_vector = split(it->second, ":", 2);
if (set_vector.size() == 2)
expand_macro(set_vector.at(1));
+ // Overwrite or insert.
request.header(set_vector.at(0), set_vector.at(1));
}
+ // Remove request header field
else if (it->first == "unset") {
+ // "Header-Field-Name"
request.header(it->second, "");
}
+ // Add request header field
else if (it->first == "add") {
+ // "Header-Field-Name":"Set-Value"
std::vector<std::string> add_vector = split(it->second, ":", 2);
if (add_vector.size() == 2) {
field_range current_range = request.header(add_vector.at(0));
expand_macro(add_vector.at(1));
+ // If header field already exists, concatinate values.
if (current_range.first != current_range.second) {
std::string new_value = current_range.first->second;
new_value += "," + add_vector.at(1);
request.header(add_vector.at(0), new_value);
+ // otherwise insert new header field.
} else {
request.header(add_vector.at(0), add_vector.at(1));
}
}
}
+ // Replace request header field using regular expression
else if (it->first == "replace") {
+ // "Header-Field-Name":"From-Value(regex)":"To-Value"
std::vector<std::string> replace_vector = split(it->second, ":", 3);
if (replace_vector.size() == 3) {
field_range current_range = request.header(replace_vector.at(0));
boost::regex exp(replace_vector.at(1));
for (;current_range.first != current_range.second; current_range.first++) {
std::string new_value = current_range.first->second;
+ // Replace only if exist
if (boost::regex_search(new_value, exp)) {
new_value = boost::regex_replace(new_value, exp, replace_vector.at(2));
request.header(replace_vector.at(0), new_value);
}
}
}
+
+ /*
+ * Insert other protocol editor.
+ */
+
std::string edited = request.as_string();
+ // New client message is too long (over buffer size)
if (edited.size() > MAX_BUFFER_SIZE) {
- // XXX log
- return;
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT, 1, "Edited message is too long. Drop message.");
+ }
+ else {
+ // Set new client message size.
+ client_length = edited.size();
+ // Set new client message.
+ memcpy(client_msg, edited.c_str(), client_length);
}
- client_length = edited.size();
- memcpy(client_msg, edited.c_str(), client_length);
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 3, // XXX log
- "out_function : void packet_editor::edit_client(char* client_msg, size_t& client_length) : "
- "client_msg(%s), client_length(%d)", client_msg, client_length);
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 5,
+ "out_function : void packet_editor::edit_client(char* client_msg, size_t& client_length)");
}
/*------ DEBUG LOG END ------*/
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 6,
"in_function : void packet_editor::edit_server(char* server_msg, size_t& server_length) : "
"server_msg(%s), server_length(%d)", server_msg, server_length);
-
}
/*------ DEBUG LOG END ------*/
+ // Edit HTTP (response header)
std::list<std::pair<std::string, std::string > >::iterator it, end;
it = ::http_response_header.begin();
end = ::http_response_header.end();
http_response response(std::string(server_msg, server_length));
for (;it != end; ++it) {
- LOGGER_PUT_LOG_FATAL(LOG_CAT_PACKET_EDIT, 3, "mode: %s, header: %s", it->first.c_str(), it->second.c_str());
+ // Set request header field
if (it->first == "set") {
+ // "Header-Field-Name":"Set-Value"
std::vector<std::string> set_vector = split(it->second, ":", 2);
if (set_vector.size() == 2)
expand_macro(set_vector.at(1));
+ // Overwrite or insert.
response.header(set_vector.at(0), set_vector.at(1));
}
+ // Remove request header field
else if (it->first == "unset") {
+ // "Header-Field-Name"
response.header(it->second, "");
}
+ // Add request header field
else if (it->first == "add") {
+ // "Header-Field-Name":"Set-Value"
std::vector<std::string> add_vector = split(it->second, ":", 2);
if (add_vector.size() == 2) {
field_range current_range = response.header(add_vector.at(0));
expand_macro(add_vector.at(1));
+ // If header field already exists, concatinate values.
if (current_range.first != current_range.second) {
std::string new_value = current_range.first->second;
new_value += "," + add_vector.at(1);
response.header(add_vector.at(0), new_value);
+ // otherwise insert new header field.
} else {
response.header(add_vector.at(0), add_vector.at(1));
}
}
}
+ // Replace request header field using regular expression
else if (it->first == "replace") {
+ // "Header-Field-Name":"From-Value(regex)":"To-Value"
std::vector<std::string> replace_vector = split(it->second, ":", 3);
if (replace_vector.size() == 3) {
field_range current_range = response.header(replace_vector.at(0));
boost::regex exp(replace_vector.at(1));
for (;current_range.first != current_range.second; current_range.first++) {
std::string new_value = current_range.first->second;
+ // Replace only if exist
if (boost::regex_search(new_value, exp)) {
new_value = boost::regex_replace(new_value, exp, replace_vector.at(2));
response.header(replace_vector.at(0), new_value);
}
}
}
+
+ /*
+ * Insert other protocol editor.
+ */
+
std::string edited = response.as_string();
+ // New server message is too long (over buffer size)
if (edited.size() > MAX_BUFFER_SIZE) {
- // XXX log
- return;
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT, 2, "Edited message is too long. Drop message.");
+ }
+ else {
+ // Set new server message size.
+ server_length = edited.size();
+ // Set new server message.
+ memcpy(server_msg, edited.c_str(), server_length);
}
- server_length = edited.size();
- memcpy(server_msg, edited.c_str(), server_length);
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 3, // XXX log
- "out_function : void packet_editor::edit_server(char* server_msg, size_t& server_length) : "
- "server_msg(%s), server_length(%d)", server_msg, server_length);
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 7,
+ "out_function : void packet_editor::edit_server(char* server_msg, size_t& server_length)");
}
/*------ DEBUG LOG END ------*/
}
* @param[in/out] source string
*/
void packet_editor::expand_macro(std::string& source) {
+ /*-------- DEBUG LOG --------*/
+ if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 8,
+ "in_function : void packet_editor::expand_macro(std::string& source) : "
+ "source(%s)", source.c_str());
+ }
+ /*------ DEBUG LOG END ------*/
int pos;
pos = source.find("%{CLIENT_ADDR}");
int port_begin = ::recv_endpoint.find(':') + 1;
source.replace(pos, 12, ::recv_endpoint.substr(port_begin, ::recv_endpoint.length() - port_begin));
}
+
+ /*-------- DEBUG LOG --------*/
+ if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 9,
+ "out_function : void packet_editor::expand_macro(std::string& source)");
+ }
+ /*------ DEBUG LOG END ------*/
}
/*!
* @param[in] limit max token
*/
std::vector<std::string> packet_editor::split(const std::string& source, const std::string& delimiter, int limit = 0) {
+ /*-------- DEBUG LOG --------*/
+ if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 10,
+ "in_function : std::vector<std::string> packet_editor::split"
+ "(const std::string& source, const std::string& delimiter, int limit) : "
+ "source(%s), delimiter(%s), limit(%d)", source.c_str(), delimiter.c_str(), limit);
+ }
+ /*------ DEBUG LOG END ------*/
std::vector<std::string> words;
int begin = 0;
int end = source.size();
limit--;
}
words.push_back(source.substr(begin, end - begin));
+ /*-------- DEBUG LOG --------*/
+ if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT)) {
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT, 11,
+ "out_function : std::vector<std::string> packet_editor::split"
+ "(const std::string& source, const std::string& delimiter, int limit)");
+ }
+ /*------ DEBUG LOG END ------*/
return words;
}
"http_request_header", request_map);
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_SSLPROXY_COMMON)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_SSLPROXY_COMMON, 61, // XXX fix log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_SSLPROXY_COMMON, 101,
"function : static int getParameters("
"std::string config_filename) : "
"get http_request_header OK.");
while (it != end) {
int delimiter_pos = it->second.find(':');
if (delimiter_pos == std::string::npos) {
- LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, // XXX fix log
- "Invalid http_request_header parameter value.");
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 50,
+ "Invalid http_request_header parameter value.(no delimiter)");
throw -1;
}
std::pair<std::string, std::string> header_pair(
&& header_pair.first != "unset"
&& header_pair.first != "add"
&& header_pair.first != "replace" ) {
- LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, // XXX fix log
- "Invalid http_request_header parameter value.");
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 51,
+ "Invalid http_request_header parameter value.(invalid type)");
throw -1;
}
-LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, "read: mode(%s) value(%s)", header_pair.first.c_str(), header_pair.second.c_str());
::http_request_header.push_back(header_pair);
::client_packet_edit = true;
it++;
"http_response_header", response_map);
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_SSLPROXY_COMMON)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_SSLPROXY_COMMON, 61, // XXX fix log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_SSLPROXY_COMMON, 102,
"function : static int getParameters("
"std::string config_filename) : "
"get http_response_header OK.");
while (it != end) {
int delimiter_pos = it->second.find(':');
if (delimiter_pos == std::string::npos) {
- LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, // XXX fix log
- "Invalid http_response_header parameter value.");
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 52,
+ "Invalid http_response_header parameter value.(no delimiter)");
throw -1;
}
std::pair<std::string, std::string> header_pair(
&& header_pair.first != "unset"
&& header_pair.first != "add"
&& header_pair.first != "replace" ) {
- LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, // XXX fix log
- "Invalid http_response_header parameter value.");
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 53,
+ "Invalid http_response_header parameter value.(invalid type)");
throw -1;
}
-LOGGER_PUT_LOG_ERROR(LOG_CAT_SSLPROXY_COMMON, 20, "read: mode(%s) value(%s)", header_pair.first.c_str(), header_pair.second.c_str());
::http_response_header.push_back(header_pair);
::server_packet_edit = true;
it++;