using namespace boost::xpressive;
+cregex method_regex
+ = ( as_xpr("GET") | as_xpr("HEAD") | as_xpr("POST") |
+ as_xpr("PUT") | as_xpr("PROPFIND") | as_xpr("PROPPATCH") |
+ as_xpr("OPTIONS") | as_xpr("CONNECT") | as_xpr("COPY") |
+ as_xpr("TRACE") | as_xpr("DELETE") | as_xpr("LOCK") |
+ as_xpr("UNLOCK") | as_xpr("MOVE") | as_xpr("MKCOL")) >> _s >>
+ +~_s >> _s >>
+ "HTTP/" >> _d >> "." >> _d;
+
+cregex version_regex_request
+ = +alpha >> _s >>
+ +~_s >> _s >>
+ "HTTP/" >> (as_xpr("1.0")|as_xpr("1.1"));
+
+cregex version_regex_response
+ = "HTTP/" >> (as_xpr("1.0")|as_xpr("1.1")) >> _s >>
+ repeat<3>(_d) >> _s >>
+ *_;
+
+cregex status_code_regex_check
+ = "HTTP/" >> _d >> "." >> _d >> _s >>
+ range('1', '3') >> repeat<2>(_d) >> _s >>
+ *_;
+
+cregex uri_regex
+ = +alpha >> _s >>
+ (s1 = *~_s) >> _s >>
+ "HTTP/" >> _d >> "." >> _d;
+
+cregex status_code_regex_find
+ = "HTTP/" >> _d >> "." >> _d >> _s >>
+ (s1 = repeat<3>(_d)) >> _s >>
+ *_;
+
+cregex http_header_regex_cookie
+ = _ln >> (s1 = icase("cookie") >> ":" >> *~_ln);
+
+cregex http_header_regex_content_length
+ = _ln >> (s1 = icase("content-length") >> ":" >> *~_ln);
+
+cregex http_header_regex_x_forwarded_for
+ = _ln >> (s1 = icase("x-forwarded-for") >> ":" >> *~_ln);
+
+cregex http_header_regex_all
+ = _ln >> (s1 = *_ >> ~_ln) >> repeat<2>(_ln);
+
+cregex http_header_regex_none
+ = _ln >> (s1 = _ln);
+
l7vs::http_protocol_module_base::CHECK_RESULT_TAG
l7vs::http_protocol_module_base::check_http_method( const char* buffer,
const size_t buffer_len ) const {
char* check_string = NULL;
size_t line_length = 0;
- cregex method_regex
- = ( as_xpr("GET") | as_xpr("HEAD") | as_xpr("POST") |
- as_xpr("PUT") | as_xpr("PROPFIND") | as_xpr("PROPPATCH") |
- as_xpr("OPTIONS") | as_xpr("CONNECT") | as_xpr("COPY") |
- as_xpr("TRACE") | as_xpr("DELETE") | as_xpr("LOCK") |
- as_xpr("UNLOCK") | as_xpr("MOVE") | as_xpr("MKCOL")) >> _s >>
- +~_s >> _s >>
- "HTTP/" >> _d >> "." >> _d;
-
if( buffer != NULL ){
for( line_length = 0; line_length < buffer_len; line_length++ ){
char* check_string = NULL;
size_t line_length = 0;
- cregex version_regex_request
- = +alpha >> _s >>
- +~_s >> _s >>
- "HTTP/" >> (as_xpr("1.0")|as_xpr("1.1"));
-
- cregex version_regex_response
- = "HTTP/" >> (as_xpr("1.0")|as_xpr("1.1")) >> _s >>
- repeat<3>(_d) >> _s >>
- *_;
-
if( buffer != NULL ){
for( line_length = 0; line_length < buffer_len; line_length++ ){
char* check_string = NULL;
size_t line_length = 0;
- cregex status_code_regex
- = "HTTP/" >> _d >> "." >> _d >> _s >>
- range('1', '3') >> repeat<2>(_d) >> _s >>
- *_;
-
if( buffer != NULL ){
for( line_length = 0; line_length < buffer_len; line_length++ ){
check_string[line_length] = '\0';
- if( !regex_match( check_string, status_code_regex )){
+ if( !regex_match( check_string, status_code_regex_check )){
check_result = CHECK_NG;
match_results< const char* > result;
- cregex uri_regex
- = +alpha >> _s >>
- (s1 = *~_s) >> _s >>
- "HTTP/" >> _d >> "." >> _d;
-
if( buffer != NULL ){
for( line_length = 0; line_length < buffer_len; line_length++ ){
match_results< const char* > result;
- cregex status_code_regex
- = "HTTP/" >> _d >> "." >> _d >> _s >>
- (s1 = repeat<3>(_d)) >> _s >>
- *_;
-
if( buffer != NULL ){
for( line_length = 0; line_length < buffer_len; line_length++ ){
find_string[line_length] = '\0';
- find_result = regex_search( find_string, result, status_code_regex );
+ find_result = regex_search( find_string, result, status_code_regex_find );
if( find_result == true ){
}
//---------- DEBUG LOG END ------------------------------
+ cregex http_header_regex;
+
bool find_result = true;
char* find_string = NULL;
match_results< const char* > result;
- cregex http_header_regex;
-
if( buffer != NULL ){
for( count = 0; count < buffer_len; count++ ){
memcpy( find_string, buffer + header_begin, header_length );
find_string[header_length] = '\0';
-
+
if( http_header_name.length() > 0 ){
-
+
http_header_regex = _ln >> (s1 = icase(http_header_name) >> ":" >> *~_ln);
-
+
find_result = regex_search( find_string, result, http_header_regex );
if( find_result == true ){
else{
http_header_regex = _ln >> (s1 = *_ >> ~_ln) >> repeat<2>(_ln);
-
+
find_result = regex_search( find_string, result, http_header_regex );
-
+
if( find_result == true ){
http_header_offset = result.position(1) + header_begin;
else{
http_header_regex = _ln >> (s1 = _ln);
-
+
find_result = regex_search( find_string, result, http_header_regex );
-
+
if( find_result == true ){
http_header_offset = result.position(1) + header_begin;
return find_result;
}
+
+bool l7vs::http_protocol_module_base::find_http_header_cookie(
+ const char* buffer,
+ const size_t buffer_len,
+ size_t& http_header_offset,
+ size_t& http_header_len ){
+
+ //---------- DEBUG LOG START ------------------------------
+ if( LOG_LV_DEBUG == getloglevel())
+ {
+ boost::format outform( "function in : [find_http_header_cookie] : "
+ "buffer_len = [%d]" );
+
+ outform % buffer_len;
+
+ putLogDebug( 0,
+ outform.str(),
+ __FILE__,
+ __LINE__ );
+ }
+ //---------- DEBUG LOG END ------------------------------
+
+ bool find_result = true;
+
+ char* find_string = NULL;
+ size_t count = 0;
+ size_t header_begin = 0;
+ size_t header_end = 0;
+ size_t header_length = 0;
+
+ int header_begin_flag = 0;
+ int header_end_flag = 0;
+
+ match_results< const char* > result;
+
+ if( buffer != NULL ){
+
+ for( count = 0; count < buffer_len; count++ ){
+
+ if( buffer[count] == '\r' || buffer[count] == '\n' ){
+
+ if( header_begin_flag == 0 ){
+
+ header_begin = count;
+ header_begin_flag = 1;
+
+ }
+
+ if( count > 0 ){
+
+ if( ( buffer[count-1] == '\r' && buffer[count] == '\r' ) ||
+ ( buffer[count-1] == '\n' && buffer[count] == '\n' ) ){
+
+ header_end = count;
+ header_end_flag = 1;
+ break;
+
+ }
+ }
+
+ if( count > 2 ){
+
+ if( buffer[count-3] == '\r' && buffer[count-2] == '\n' &&
+ buffer[count-1] == '\r' && buffer[count] == '\n' ){
+
+ header_end = count;
+ header_end_flag = 1;
+ break;
+
+ }
+ }
+ }
+ }
+
+ if( header_begin_flag == 1 && header_end_flag == 1 ){
+
+ header_length = header_end - header_begin + 1;
+
+ find_string = (char*)malloc( header_length + 1 );
+
+ if( find_string != NULL ){
+
+ memcpy( find_string, buffer + header_begin, header_length );
+
+ find_string[header_length] = '\0';
+
+ find_result = regex_search( find_string, result, http_header_regex_cookie );
+
+ if( find_result == true ){
+
+ http_header_offset = result.position(1) + header_begin;
+ http_header_len = result.length(1);
+
+ }
+
+ free( find_string );
+
+ }
+ else{
+
+ find_result = false;
+
+ }
+
+ }
+ else{
+
+ find_result = false;
+
+ }
+ }
+ else{
+
+ find_result = false;
+
+ }
+
+ //---------- DEBUG LOG START ------------------------------
+ if( LOG_LV_DEBUG == getloglevel())
+ {
+ boost::format outform( "function out : [find_http_header_cookie] : "
+ "find_result = [%d], "
+ "http_header_offset = [%d], "
+ "http_header_len = [%d]" );
+
+ outform % find_result % http_header_offset % http_header_len;
+
+ putLogDebug( 0,
+ outform.str(),
+ __FILE__,
+ __LINE__ );
+ }
+ //---------- DEBUG LOG END ------------------------------
+
+ return find_result;
+
+}
+
+bool l7vs::http_protocol_module_base::find_http_header_content_length(
+ const char* buffer,
+ const size_t buffer_len,
+ size_t& http_header_offset,
+ size_t& http_header_len ){
+
+ //---------- DEBUG LOG START ------------------------------
+ if( LOG_LV_DEBUG == getloglevel())
+ {
+ boost::format outform( "function in : [find_http_header_content_length] : "
+ "buffer_len = [%d]" );
+
+ outform % buffer_len;
+
+ putLogDebug( 0,
+ outform.str(),
+ __FILE__,
+ __LINE__ );
+ }
+ //---------- DEBUG LOG END ------------------------------
+
+ bool find_result = true;
+
+ char* find_string = NULL;
+ size_t count = 0;
+ size_t header_begin = 0;
+ size_t header_end = 0;
+ size_t header_length = 0;
+
+ int header_begin_flag = 0;
+ int header_end_flag = 0;
+
+ match_results< const char* > result;
+
+ if( buffer != NULL ){
+
+ for( count = 0; count < buffer_len; count++ ){
+
+ if( buffer[count] == '\r' || buffer[count] == '\n' ){
+
+ if( header_begin_flag == 0 ){
+
+ header_begin = count;
+ header_begin_flag = 1;
+
+ }
+
+ if( count > 0 ){
+
+ if( ( buffer[count-1] == '\r' && buffer[count] == '\r' ) ||
+ ( buffer[count-1] == '\n' && buffer[count] == '\n' ) ){
+
+ header_end = count;
+ header_end_flag = 1;
+ break;
+
+ }
+ }
+
+ if( count > 2 ){
+
+ if( buffer[count-3] == '\r' && buffer[count-2] == '\n' &&
+ buffer[count-1] == '\r' && buffer[count] == '\n' ){
+
+ header_end = count;
+ header_end_flag = 1;
+ break;
+
+ }
+ }
+ }
+ }
+
+ if( header_begin_flag == 1 && header_end_flag == 1 ){
+
+ header_length = header_end - header_begin + 1;
+
+ find_string = (char*)malloc( header_length + 1 );
+
+ if( find_string != NULL ){
+
+ memcpy( find_string, buffer + header_begin, header_length );
+
+ find_string[header_length] = '\0';
+
+ find_result = regex_search( find_string, result, http_header_regex_content_length );
+
+ if( find_result == true ){
+
+ http_header_offset = result.position(1) + header_begin;
+ http_header_len = result.length(1);
+
+ }
+
+ free( find_string );
+
+ }
+ else{
+
+ find_result = false;
+
+ }
+
+ }
+ else{
+
+ find_result = false;
+
+ }
+ }
+ else{
+
+ find_result = false;
+
+ }
+
+ //---------- DEBUG LOG START ------------------------------
+ if( LOG_LV_DEBUG == getloglevel())
+ {
+ boost::format outform( "function out : [find_http_header_content_length] : "
+ "find_result = [%d], "
+ "http_header_offset = [%d], "
+ "http_header_len = [%d]" );
+
+ outform % find_result % http_header_offset % http_header_len;
+
+ putLogDebug( 0,
+ outform.str(),
+ __FILE__,
+ __LINE__ );
+ }
+ //---------- DEBUG LOG END ------------------------------
+
+ return find_result;
+
+}
+
+bool l7vs::http_protocol_module_base::find_http_header_x_forwarded_for(
+ const char* buffer,
+ const size_t buffer_len,
+ size_t& http_header_offset,
+ size_t& http_header_len ){
+
+ //---------- DEBUG LOG START ------------------------------
+ if( LOG_LV_DEBUG == getloglevel())
+ {
+ boost::format outform( "function in : [find_http_header_x_forwarded_for] : "
+ "buffer_len = [%d]" );
+
+ outform % buffer_len;
+
+ putLogDebug( 0,
+ outform.str(),
+ __FILE__,
+ __LINE__ );
+ }
+ //---------- DEBUG LOG END ------------------------------
+
+ bool find_result = true;
+
+ char* find_string = NULL;
+ size_t count = 0;
+ size_t header_begin = 0;
+ size_t header_end = 0;
+ size_t header_length = 0;
+
+ int header_begin_flag = 0;
+ int header_end_flag = 0;
+
+ match_results< const char* > result;
+
+ if( buffer != NULL ){
+
+ for( count = 0; count < buffer_len; count++ ){
+
+ if( buffer[count] == '\r' || buffer[count] == '\n' ){
+
+ if( header_begin_flag == 0 ){
+
+ header_begin = count;
+ header_begin_flag = 1;
+
+ }
+
+ if( count > 0 ){
+
+ if( ( buffer[count-1] == '\r' && buffer[count] == '\r' ) ||
+ ( buffer[count-1] == '\n' && buffer[count] == '\n' ) ){
+
+ header_end = count;
+ header_end_flag = 1;
+ break;
+
+ }
+ }
+
+ if( count > 2 ){
+
+ if( buffer[count-3] == '\r' && buffer[count-2] == '\n' &&
+ buffer[count-1] == '\r' && buffer[count] == '\n' ){
+
+ header_end = count;
+ header_end_flag = 1;
+ break;
+
+ }
+ }
+ }
+ }
+
+ if( header_begin_flag == 1 && header_end_flag == 1 ){
+
+ header_length = header_end - header_begin + 1;
+
+ find_string = (char*)malloc( header_length + 1 );
+
+ if( find_string != NULL ){
+
+ memcpy( find_string, buffer + header_begin, header_length );
+
+ find_string[header_length] = '\0';
+
+ find_result = regex_search( find_string, result, http_header_regex_x_forwarded_for );
+
+ if( find_result == true ){
+
+ http_header_offset = result.position(1) + header_begin;
+ http_header_len = result.length(1);
+
+ }
+
+ free( find_string );
+
+ }
+ else{
+
+ find_result = false;
+
+ }
+
+ }
+ else{
+
+ find_result = false;
+
+ }
+ }
+ else{
+
+ find_result = false;
+
+ }
+
+ //---------- DEBUG LOG START ------------------------------
+ if( LOG_LV_DEBUG == getloglevel())
+ {
+ boost::format outform( "function out : [find_http_header_x_forwarded_for] : "
+ "find_result = [%d], "
+ "http_header_offset = [%d], "
+ "http_header_len = [%d]" );
+
+ outform % find_result % http_header_offset % http_header_len;
+
+ putLogDebug( 0,
+ outform.str(),
+ __FILE__,
+ __LINE__ );
+ }
+ //---------- DEBUG LOG END ------------------------------
+
+ return find_result;
+
+}
+
+bool l7vs::http_protocol_module_base::find_http_header_all(
+ const char* buffer,
+ const size_t buffer_len,
+ size_t& http_header_offset,
+ size_t& http_header_len ){
+
+ //---------- DEBUG LOG START ------------------------------
+ if( LOG_LV_DEBUG == getloglevel())
+ {
+ boost::format outform( "function in : [find_http_header_all] : "
+ "buffer_len = [%d]" );
+
+ outform % buffer_len;
+
+ putLogDebug( 0,
+ outform.str(),
+ __FILE__,
+ __LINE__ );
+ }
+ //---------- DEBUG LOG END ------------------------------
+
+ bool find_result = true;
+
+ char* find_string = NULL;
+ size_t count = 0;
+ size_t header_begin = 0;
+ size_t header_end = 0;
+ size_t header_length = 0;
+
+ int header_begin_flag = 0;
+ int header_end_flag = 0;
+
+ match_results< const char* > result;
+
+ if( buffer != NULL ){
+
+ for( count = 0; count < buffer_len; count++ ){
+
+ if( buffer[count] == '\r' || buffer[count] == '\n' ){
+
+ if( header_begin_flag == 0 ){
+
+ header_begin = count;
+ header_begin_flag = 1;
+
+ }
+
+ if( count > 0 ){
+
+ if( ( buffer[count-1] == '\r' && buffer[count] == '\r' ) ||
+ ( buffer[count-1] == '\n' && buffer[count] == '\n' ) ){
+
+ header_end = count;
+ header_end_flag = 1;
+ break;
+
+ }
+ }
+
+ if( count > 2 ){
+
+ if( buffer[count-3] == '\r' && buffer[count-2] == '\n' &&
+ buffer[count-1] == '\r' && buffer[count] == '\n' ){
+
+ header_end = count;
+ header_end_flag = 1;
+ break;
+
+ }
+ }
+ }
+ }
+
+ if( header_begin_flag == 1 && header_end_flag == 1 ){
+
+ header_length = header_end - header_begin + 1;
+
+ find_string = (char*)malloc( header_length + 1 );
+
+ if( find_string != NULL ){
+
+ memcpy( find_string, buffer + header_begin, header_length );
+
+ find_string[header_length] = '\0';
+
+ find_result = regex_search( find_string, result, http_header_regex_all );
+
+ if( find_result == true ){
+
+ http_header_offset = result.position(1) + header_begin;
+ http_header_len = result.length(1);
+
+ }
+ else{
+
+ find_result = regex_search( find_string, result, http_header_regex_none );
+
+ if( find_result == true ){
+
+ http_header_offset = result.position(1) + header_begin;
+ http_header_len = 0;
+
+ }
+ }
+
+ free( find_string );
+
+ }
+ else{
+
+ find_result = false;
+
+ }
+
+ }
+ else{
+
+ find_result = false;
+
+ }
+ }
+ else{
+
+ find_result = false;
+
+ }
+
+ //---------- DEBUG LOG START ------------------------------
+ if( LOG_LV_DEBUG == getloglevel())
+ {
+ boost::format outform( "function out : [find_http_header_all] : "
+ "find_result = [%d], "
+ "http_header_offset = [%d], "
+ "http_header_len = [%d]" );
+
+ outform % find_result % http_header_offset % http_header_len;
+
+ putLogDebug( 0,
+ outform.str(),
+ __FILE__,
+ __LINE__ );
+ }
+ //---------- DEBUG LOG END ------------------------------
+
+ return find_result;
+
+}
//! @param size_t& header length
//! @return bool find is true. not find is false
bool find_http_header( const char*, const size_t, const std::string&, size_t&, size_t& );
-
+ //! serch http header Cookie
+ //! @param const char* buffer
+ //! @param const size_t buffer_len
+ //! @param size_t& header offset
+ //! @param size_t& header length
+ //! @return bool find is true. not find is false
+ bool find_http_header_cookie( const char*, const size_t, size_t&, size_t& );
+ //! serch http header Content_Length
+ //! @param const char* buffer
+ //! @param const size_t buffer_len
+ //! @param size_t& header offset
+ //! @param size_t& header length
+ //! @return bool find is true. not find is false
+ bool find_http_header_content_length( const char*, const size_t, size_t&, size_t& );
+ //! serch http header X_Forwarded_For
+ //! @param const char* buffer
+ //! @param const size_t buffer_len
+ //! @param size_t& header offset
+ //! @param size_t& header length
+ //! @return bool find is true. not find is false
+ bool find_http_header_x_forwarded_for( const char*, const size_t, size_t&, size_t& );
+ //! serch http header all
+ //! @param const char* buffer
+ //! @param const size_t buffer_len
+ //! @param size_t& header offset
+ //! @param size_t& header length
+ //! @return bool find is true. not find is false
+ bool find_http_header_all( const char*, const size_t, size_t&, size_t& );
public:
//! constractor
http_protocol_module_base( std::string in_modulename ) : protocol_module_base( in_modulename ){};
#include <boost/format.hpp>
#include "protocol_module_cinsert.h"
+using namespace boost::xpressive;
+
+sregex cookie_name_regex
+ = +( alpha | digit );
+
+sregex cookie_expire_regex
+ = +digit;
+
+sregex sorry_uri_regex
+ = +( '/' >>
+ *( alpha |
+ digit |
+ ( set = ';', ':', '@', '&', '=' ) |
+ ( set = '$', '-', '_', '.', '+' ) |
+ ( set = '!', '*', '\'', '\(', ')', ',' ) |
+ '%' >> repeat<2>(xdigit)));
+
+cregex content_length_regex
+ = icase("Content-Length") >> ":" >> *~_d >> (s1 = +_d) >> *~_d;
+
+cregex cookie_regex;
+
namespace l7vs
{
//! constractor
}
//---------- DEBUG LOG END ------------------------------
- using namespace boost::xpressive;
-
check_message_result check_result;
bool cookie_name_set_flag = false;
bool match_result;
- sregex cookie_name_regex = +( alpha | digit );
- sregex cookie_expire_regex = +digit;
- sregex sorry_uri_regex
- = +( '/' >>
- *( alpha |
- digit |
- ( set = ';', ':', '@', '&', '=' ) |
- ( set = '$', '-', '_', '.', '+' ) |
- ( set = '!', '*', '\'', '\(', ')', ',' ) |
- '%' >> repeat<2>(xdigit)));
-
int cookie_expire_tmp;
try
}
//---------- DEBUG LOG END ------------------------------
- using namespace boost::xpressive;
-
check_message_result check_result;
bool cookie_name_set_flag = false;
bool match_result;
- sregex cookie_name_regex = +( alpha | digit );
- sregex cookie_expire_regex = +digit;
- sregex sorry_uri_regex
- = +( '/' >>
- *( alpha |
- digit |
- ( set = ';', ':', '@', '&', '=' ) |
- ( set = '$', '-', '_', '.', '+' ) |
- ( set = '!', '*', '\'', '\(', ')', ',' ) |
- '%' >> repeat<2>(xdigit)));
-
try
{
memcpy( cookie_name.data(), "CookieName\0", 12);
}
+ std::string cookie_name_str = cookie_name.data();
+
+ cookie_regex
+ = icase("Cookie") >> ":" >> *_ >>
+ cookie_name_str >> "=" >>
+ ( s1 = +_d >> "." >> +_d >> "." >> +_d >> "." >> +_d ) >>
+ ":" >> ( s2 = +_d );
+
if( cookie_expire_set_flag == false )
{
cookie_expire = 86400;
}
//---------- DEBUG LOG END ------------------------------
- using namespace boost::xpressive;
-
t_session_thread_data_cinsert thread_data;
char* buffer_1 = NULL;
std::string http_header_name_content_length = "Content-Length";
std::string content_length;
match_results< const char* > regex_result;
- cregex content_length_regex = icase("Content-Length") >> ":" >> *~_d >> (s1 = +_d) >> *~_d;
t_session_thread_data_map_itr thread_data_itr;
t_recive_data_map_itr recive_data_itr;
if( check_result == CHECK_OK )
{
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// unsend_data_size,
+// http_header_name_blank,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_all(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_itr->send_offset,
unsend_data_size,
- http_header_name_blank,
http_header_offset,
http_header_len );
= http_header_offset + http_header_len + 4;
}
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// send_status_itr->send_rest_size,
+// http_header_name_content_length,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_content_length(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_itr->send_offset,
send_status_itr->send_rest_size,
- http_header_name_content_length,
http_header_offset,
http_header_len );
if( check_result == CHECK_OK )
{
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_add.send_offset,
+// rest_request_data_size,
+// http_header_name_blank,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_all(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_add.send_offset,
rest_request_data_size,
- http_header_name_blank,
http_header_offset,
http_header_len );
= http_header_offset + http_header_len + 4;
}
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_add.send_offset,
+// send_status_add.send_rest_size,
+// http_header_name_content_length,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_content_length(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_add.send_offset,
send_status_add.send_rest_size,
- http_header_name_content_length,
http_header_offset,
http_header_len );
}
//---------- DEBUG LOG END ------------------------------
- using namespace boost::xpressive;
+// cregex cookie_regex;
t_session_thread_data_cinsert thread_data;
size_t http_header_offset = 0;
size_t http_header_len = 0;
std::string http_header_name_cookie = "Cookie";
- std::string cookie_name_str = cookie_name.data();
+// std::string cookie_name_str = cookie_name.data();
std::string cookie;
std::string cookie_address;
std::string cookie_port;
match_results< const char* > regex_result;
- cregex cookie_regex
- = icase("Cookie") >> ":" >> *_ >>
- cookie_name_str >> "=" >>
- ( s1 = +_d >> "." >> +_d >> "." >> +_d >> "." >> +_d ) >>
- ":" >> ( s2 = +_d );
realserverlist_type::iterator rs_list_itr;
t_session_thread_data_map_itr thread_data_itr;
else
{
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// send_status_itr->send_possible_size,
+// http_header_name_cookie,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_cookie(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_itr->send_offset,
send_status_itr->send_possible_size,
- http_header_name_cookie,
http_header_offset,
http_header_len );
-
+
if( find_result == true )
{
+ send_status_itr->send_offset
+ http_header_offset,
http_header_len );
-
+
+// cookie_regex
+// = icase("Cookie") >> ":" >> *_ >>
+// cookie_name_str >> "=" >>
+// ( s1 = +_d >> "." >> +_d >> "." >> +_d >> "." >> +_d ) >>
+// ":" >> ( s2 = +_d );
+
find_result = regex_search( cookie.c_str(),
regex_result,
cookie_regex );
if( forwarded_for == 1 )
{
- find_result
- = find_http_header( (const char*)recive_data_itr->second.recive_buffer
+// find_result
+// = find_http_header( (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// send_status_itr->send_possible_size,
+// http_header_name_x_forwarded_for,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_x_forwarded_for(
+ (const char*)recive_data_itr->second.recive_buffer
+ send_status_itr->send_offset,
send_status_itr->send_possible_size,
- http_header_name_x_forwarded_for,
http_header_offset,
http_header_len );
-
-
+
if( find_result == true )
{
else
{
- find_result
- = find_http_header( (const char*)recive_data_itr->second.recive_buffer
- + send_status_itr->send_offset,
- send_status_itr->send_possible_size,
- http_header_name_blank,
- http_header_offset,
- http_header_len );
-
+// find_result
+// = find_http_header( (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// send_status_itr->send_possible_size,
+// http_header_name_blank,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_all(
+ (const char*)recive_data_itr->second.recive_buffer
+ + send_status_itr->send_offset,
+ send_status_itr->send_possible_size,
+ http_header_offset,
+ http_header_len );
+
if( find_result == true )
{
if( forwarded_for == 1 )
{
- find_result
- = find_http_header( (const char*)recive_data_itr->second.recive_buffer
+// find_result
+// = find_http_header( (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// send_status_itr->send_possible_size,
+// http_header_name_x_forwarded_for,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_x_forwarded_for(
+ (const char*)recive_data_itr->second.recive_buffer
+ send_status_itr->send_offset,
send_status_itr->send_possible_size,
- http_header_name_x_forwarded_for,
http_header_offset,
http_header_len );
-
-
+
if( find_result == true )
{
else
{
- find_result
- = find_http_header( (const char*)recive_data_itr->second.recive_buffer
- + send_status_itr->send_offset,
- send_status_itr->send_possible_size,
- http_header_name_blank,
- http_header_offset,
- http_header_len );
-
+// find_result
+// = find_http_header( (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// send_status_itr->send_possible_size,
+// http_header_name_blank,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_all(
+ (const char*)recive_data_itr->second.recive_buffer
+ + send_status_itr->send_offset,
+ send_status_itr->send_possible_size,
+ http_header_offset,
+ http_header_len );
+
if( find_result == true )
{
}
//---------- DEBUG LOG END ------------------------------
- using namespace boost::xpressive;
-
t_session_thread_data_cinsert thread_data;
char* buffer = NULL;
std::string http_header_name_content_length = "Content-Length";
std::string content_length;
match_results< const char* > regex_result;
- cregex content_length_regex = icase("Content-Length") >> ":" >> *~_d >> (s1 = +_d) >> *~_d;
t_session_thread_data_map_itr thread_data_itr;
t_recive_data_map_itr recive_data_itr;
if( check_result == CHECK_OK )
{
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// unsend_data_size,
+// http_header_name_blank,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_all(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_itr->send_offset,
unsend_data_size,
- http_header_name_blank,
http_header_offset,
http_header_len );
= http_header_offset + http_header_len + 4;
}
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// send_status_itr->send_rest_size,
+// http_header_name_content_length,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_content_length(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_itr->send_offset,
send_status_itr->send_rest_size,
- http_header_name_content_length,
http_header_offset,
http_header_len );
if( check_result == CHECK_OK )
{
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_add.send_offset,
+// rest_response_data_size,
+// http_header_name_blank,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_all(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_add.send_offset,
rest_response_data_size,
- http_header_name_blank,
http_header_offset,
http_header_len );
= http_header_offset + http_header_len + 4;
}
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_add.send_offset,
+// send_status_add.send_rest_size,
+// http_header_name_content_length,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_content_length(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_add.send_offset,
send_status_add.send_rest_size,
- http_header_name_content_length,
http_header_offset,
http_header_len );
}
//---------- DEBUG LOG END ------------------------------
- using namespace boost::xpressive;
-
t_session_thread_data_cinsert thread_data;
recive_data sorryserver_recv_data;
std::string http_header_name_content_length = "Content-Length";
std::string content_length;
match_results< const char* > regex_result;
- cregex content_length_regex = icase("Content-Length") >> ":" >> *~_d >> (s1 = +_d) >> *~_d;
t_session_thread_data_map_itr thread_data_itr;
t_recive_data_map_itr recive_data_itr;
if( check_result == CHECK_OK )
{
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// unsend_data_size,
+// http_header_name_blank,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_all(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_itr->send_offset,
unsend_data_size,
- http_header_name_blank,
http_header_offset,
http_header_len );
= http_header_offset + http_header_len + 4;
}
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// send_status_itr->send_rest_size,
+// http_header_name_content_length,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_content_length(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_itr->send_offset,
send_status_itr->send_rest_size,
- http_header_name_content_length,
http_header_offset,
http_header_len );
if( check_result == CHECK_OK )
{
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_add.send_offset,
+// rest_response_data_size,
+// http_header_name_blank,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_all(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_add.send_offset,
rest_response_data_size,
- http_header_name_blank,
http_header_offset,
http_header_len );
= http_header_offset + http_header_len + 4;
}
- find_result = find_http_header(
+// find_result = find_http_header(
+// (const char*)recive_data_itr->second.recive_buffer
+// + send_status_add.send_offset,
+// send_status_add.send_rest_size,
+// http_header_name_content_length,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_content_length(
(const char*)recive_data_itr->second.recive_buffer
+ send_status_add.send_offset,
send_status_add.send_rest_size,
- http_header_name_content_length,
http_header_offset,
http_header_len );
if( send_status_itr->edit_data_list.empty() == true )
{
- find_result
- = find_http_header( (const char*)recive_data_itr->second.recive_buffer
+// find_result
+// = find_http_header( (const char*)recive_data_itr->second.recive_buffer
+// + send_status_itr->send_offset,
+// send_status_itr->send_possible_size,
+// http_header_name_blank,
+// http_header_offset,
+// http_header_len );
+
+ find_result = find_http_header_all(
+ (const char*)recive_data_itr->second.recive_buffer
+ send_status_itr->send_offset,
send_status_itr->send_possible_size,
- http_header_name_blank,
http_header_offset,
http_header_len );
-
if( find_result == true )
{
}else{
up_thread_next_call_function.second(LOCAL_PROC);
}
+ boost::this_thread::yield();
}
//----Debug log----------------------------------------------------------------------
if (LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION)){
}else{
down_thread_next_call_function.second(LOCAL_PROC);
}
+ boost::this_thread::yield();
}
//----Debug log----------------------------------------------------------------------
if (LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION)){
//! up thread receive client side and raise module event of handle_client_recv
//! @param[in] process_type is prosecess type
void tcp_session::up_thread_client_receive(const TCP_PROCESS_TYPE_TAG process_type){
+ /*
if(protocol_module == NULL){
//Error protocol_module NULL
std::stringstream buf;
up_thread_exit(process_type);
return;
}
+ */
if(0 < parent_service.get_wait_upstream()){
//----Debug log----------------------------------------------------------------------
if(ec == boost::asio::error::try_again){
func_tag = UP_FUNC_CLIENT_RECEIVE;
boost::this_thread::yield();
- }else if(ec == boost::asio::error::eof){
- func_tag = UP_FUNC_CLIENT_DISCONNECT;
- }else if(ec == boost::asio::error::connection_reset){
- func_tag = UP_FUNC_CLIENT_DISCONNECT;
}else{
func_tag = UP_FUNC_CLIENT_DISCONNECT;
- if(client_socket.is_open()){
- //receive socket error
- std::stringstream buf;
- buf << "Thread ID[";
- buf << boost::this_thread::get_id();
- buf << "] receive socket error :";
- buf << ec.message();
- Logger::putLogError( LOG_CAT_L7VSD_SESSION, 9999, buf.str(), __FILE__, __LINE__ );
- }
}
}
up_thread_function_pair func = up_thread_function_array[func_tag];
}else{
if(ec == boost::asio::error::try_again){
func_tag = UP_FUNC_REALSERVER_SEND;
- }else if(ec == boost::asio::error::eof){
- func_tag = UP_FUNC_REALSERVER_DISCONNECT;
- }else if(ec == boost::asio::error::connection_reset){
- func_tag = UP_FUNC_REALSERVER_DISCONNECT;
}else{
func_tag = UP_FUNC_REALSERVER_DISCONNECT;
- //send socket error
- std::stringstream buf;
- buf << "Thread ID[";
- buf << boost::this_thread::get_id();
- buf << "] send socket error :";
- buf << ec.message();
- Logger::putLogError( LOG_CAT_L7VSD_SESSION, 9999, buf.str(), __FILE__, __LINE__ );
}
}
up_thread_function_pair func = up_thread_function_array[func_tag];
}else{
if(ec == boost::asio::error::try_again){
func_tag = UP_FUNC_SORRYSERVER_SEND;
- }else if(ec == boost::asio::error::eof){
- func_tag = UP_FUNC_SORRYSERVER_DISCONNECT;
- }else if(ec == boost::asio::error::connection_reset){
- func_tag = UP_FUNC_SORRYSERVER_DISCONNECT;
}else{
func_tag = UP_FUNC_SORRYSERVER_DISCONNECT;
- //send socket error
- std::stringstream buf;
- buf << "Thread ID[";
- buf << boost::this_thread::get_id();
- buf << "] send socket error :";
- buf << ec.message();
- Logger::putLogError( LOG_CAT_L7VSD_SESSION, 9999, buf.str(), __FILE__, __LINE__ );
}
}
up_thread_function_pair func = up_thread_function_array[func_tag];
//! down thread receive from realserver and raise module event of handle_realserver_recv
//! @param[in] process_type is prosecess type
void tcp_session::down_thread_realserver_receive(const TCP_PROCESS_TYPE_TAG process_type){
+ /*
if(protocol_module == NULL){
//Error protocol_module NULL
std::stringstream buf;
down_thread_exit(process_type);
return;
}
+ */
bool is_emp = down_thread_receive_realserver_socket_list.empty();
if(is_emp){
boost::this_thread::yield();
if(ec == boost::asio::error::try_again){
func_tag = DOWN_FUNC_REALSERVER_RECEIVE;
boost::this_thread::yield();
- }else if(ec == boost::asio::error::eof){
- func_tag = DOWN_FUNC_REALSERVER_DISCONNECT;
- }else if(ec == boost::asio::error::connection_reset){
- func_tag = DOWN_FUNC_REALSERVER_DISCONNECT;
}else{
func_tag = DOWN_FUNC_REALSERVER_DISCONNECT;
- if(down_thread_current_receive_realserver_socket->second->is_open()){
- //receive socket error
- std::stringstream buf;
- buf << "Thread ID[";
- buf << boost::this_thread::get_id();
- buf << "] receive socket error :";
- buf << ec.message();
- Logger::putLogError( LOG_CAT_L7VSD_SESSION, 9999, buf.str(), __FILE__, __LINE__ );
- }
}
}
down_thread_function_pair func = down_thread_function_array[func_tag];
}else{
if(ec == boost::asio::error::try_again){
func_tag = DOWN_FUNC_CLIENT_SEND;
- }else if(ec == boost::asio::error::eof){
- func_tag = DOWN_FUNC_CLIENT_DISCONNECT;
- }else if(ec == boost::asio::error::connection_reset){
- func_tag = DOWN_FUNC_CLIENT_DISCONNECT;
}else{
func_tag = DOWN_FUNC_CLIENT_DISCONNECT;
- //send socket error
- std::stringstream buf;
- buf << "Thread ID[";
- buf << boost::this_thread::get_id();
- buf << "] send socket error :";
- buf << ec.message();
- Logger::putLogError( LOG_CAT_L7VSD_SESSION, 9999, buf.str(), __FILE__, __LINE__ );
}
}
down_thread_function_pair func = down_thread_function_array[func_tag];
if(ec == boost::asio::error::try_again){
func_tag = DOWN_FUNC_SORRYSERVER_RECEIVE;
boost::this_thread::yield();
- }else if(ec == boost::asio::error::eof){
- func_tag = DOWN_FUNC_SORRYSERVER_DISCONNECT;
- }else if(ec == boost::asio::error::connection_reset){
- func_tag = DOWN_FUNC_SORRYSERVER_DISCONNECT;
}else{
func_tag = DOWN_FUNC_SORRYSERVER_DISCONNECT;
- if(sorryserver_socket.second->is_open()){
- //receive socket error
- std::stringstream buf;
- buf << "Thread ID[";
- buf << boost::this_thread::get_id();
- buf << "] receive socket error :";
- buf << ec.message();
- Logger::putLogError( LOG_CAT_L7VSD_SESSION, 9999, buf.str(), __FILE__, __LINE__ );
- }
}
}
down_thread_function_pair func = down_thread_function_array[func_tag];