OSDN Git Service

#336
authortakamaru <takamaru@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Tue, 24 Mar 2009 11:00:34 +0000 (11:00 +0000)
committertakamaru <takamaru@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Tue, 24 Mar 2009 11:00:34 +0000 (11:00 +0000)
git-svn-id: http://10.144.169.20/repos/um/branches/l7vsd-3.x-shamshel-PT@7732 1ed66053-1c2d-0410-8867-f7571e6e31d3

module/protocol/http_protocol_module_base.cpp
module/protocol/http_protocol_module_base.h
module/protocol/protocol_module_cinsert.cpp
src/tcp_session.cpp

index ebec6e4..5b286f5 100644 (file)
 
 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 {
@@ -35,15 +84,6 @@ l7vs::http_protocol_module_base::check_http_method(  const char* buffer,
        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++ ){
@@ -136,16 +176,6 @@ l7vs::http_protocol_module_base::check_http_version(       const char* buffer,
        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++ ){
@@ -242,11 +272,6 @@ l7vs::http_protocol_module_base::check_status_code(        const char* buffer,
        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++ ){
@@ -269,7 +294,7 @@ l7vs::http_protocol_module_base::check_status_code( const char* buffer,
        
                                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;
        
@@ -345,11 +370,6 @@ bool       l7vs::http_protocol_module_base::find_uri(      const char* buffer,
 
        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++ ){
@@ -454,11 +474,6 @@ bool       l7vs::http_protocol_module_base::find_status_code(      const char* buffer,
 
        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++ ){
@@ -481,7 +496,7 @@ bool        l7vs::http_protocol_module_base::find_status_code(      const char* buffer,
        
                                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 ){
        
@@ -558,6 +573,8 @@ bool        l7vs::http_protocol_module_base::find_http_header(      const char* buffer,
        }
        //---------- DEBUG LOG END ------------------------------
 
+       cregex  http_header_regex;
+
        bool    find_result                     = true;
 
        char*   find_string                     = NULL;
@@ -571,8 +588,6 @@ bool        l7vs::http_protocol_module_base::find_http_header(      const char* buffer,
 
        match_results< const char* >    result;
 
-       cregex  http_header_regex;
-
        if( buffer != NULL ){
 
                for( count = 0; count < buffer_len; count++ ){
@@ -623,11 +638,11 @@ bool      l7vs::http_protocol_module_base::find_http_header(      const char* buffer,
                                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 ){
@@ -640,9 +655,9 @@ bool        l7vs::http_protocol_module_base::find_http_header(      const char* buffer,
                                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;
@@ -652,9 +667,9 @@ bool        l7vs::http_protocol_module_base::find_http_header(      const char* buffer,
                                        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;
@@ -706,3 +721,562 @@ bool      l7vs::http_protocol_module_base::find_http_header(      const char* buffer,
        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;
+
+}
index 1ab4e02..b9a634b 100644 (file)
@@ -60,7 +60,34 @@ protected:
        //! @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 ){};
index ffe1a0b..fab781a 100644 (file)
@@ -7,6 +7,28 @@
 #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
@@ -207,8 +229,6 @@ protocol_module_cinsert::check_parameter( const std::vector< std::string >& args
        }
        //---------- DEBUG LOG END ------------------------------
 
-       using namespace boost::xpressive;
-
        check_message_result check_result;
 
        bool cookie_name_set_flag       = false;
@@ -222,17 +242,6 @@ protocol_module_cinsert::check_parameter( const std::vector< std::string >& args
 
        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
@@ -572,8 +581,6 @@ protocol_module_cinsert::set_parameter( const std::vector< std::string >& args )
        }
        //---------- DEBUG LOG END ------------------------------
 
-       using namespace boost::xpressive;
-
        check_message_result check_result;
 
        bool cookie_name_set_flag       = false;
@@ -587,17 +594,6 @@ protocol_module_cinsert::set_parameter( const std::vector< std::string >& args )
 
        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
        {
 
@@ -895,6 +891,14 @@ protocol_module_cinsert::set_parameter( const std::vector< std::string >& args )
                                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; 
@@ -1376,8 +1380,6 @@ protocol_module_cinsert::handle_client_recv(
        }
        //---------- DEBUG LOG END ------------------------------
 
-       using namespace boost::xpressive;
-
        t_session_thread_data_cinsert   thread_data;
 
        char*   buffer_1                        = NULL;
@@ -1398,7 +1400,6 @@ protocol_module_cinsert::handle_client_recv(
        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;
@@ -1625,11 +1626,18 @@ protocol_module_cinsert::handle_client_recv(
                                                        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 );
 
@@ -1647,11 +1655,18 @@ protocol_module_cinsert::handle_client_recv(
                                                                                                                = 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 );
 
@@ -1795,11 +1810,18 @@ protocol_module_cinsert::handle_client_recv(
                                                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 );
 
@@ -1817,11 +1839,18 @@ protocol_module_cinsert::handle_client_recv(
                                                                                                        = 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 );
 
@@ -2022,7 +2051,7 @@ protocol_module_cinsert::handle_realserver_select(
        }
        //---------- DEBUG LOG END ------------------------------
 
-       using namespace boost::xpressive;
+//     cregex  cookie_regex;
 
        t_session_thread_data_cinsert   thread_data;
 
@@ -2032,16 +2061,11 @@ protocol_module_cinsert::handle_realserver_select(
        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;
@@ -2109,14 +2133,21 @@ protocol_module_cinsert::handle_realserver_select(
                                                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 )
                                                        {
        
@@ -2124,7 +2155,13 @@ protocol_module_cinsert::handle_realserver_select(
                                                                                                        + 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 );
@@ -2365,15 +2402,21 @@ protocol_module_cinsert::handle_realserver_connect(
                                                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 )
                                                        {
 
@@ -2395,14 +2438,21 @@ protocol_module_cinsert::handle_realserver_connect(
                                                        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 )
                                                                {
 
@@ -3162,15 +3212,21 @@ protocol_module_cinsert::handle_sorryserver_connect(
 
                                                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 )
                                                        {
        
@@ -3192,14 +3248,21 @@ protocol_module_cinsert::handle_sorryserver_connect(
                                                        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 )
                                                                {
                
@@ -3737,8 +3800,6 @@ protocol_module_cinsert::handle_realserver_recv(
        }
        //---------- DEBUG LOG END ------------------------------
 
-       using namespace boost::xpressive;
-
        t_session_thread_data_cinsert   thread_data;
 
        char*   buffer                          = NULL;
@@ -3762,7 +3823,6 @@ protocol_module_cinsert::handle_realserver_recv(
        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;
@@ -4003,11 +4063,18 @@ protocol_module_cinsert::handle_realserver_recv(
                                                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 );
 
@@ -4025,11 +4092,18 @@ protocol_module_cinsert::handle_realserver_recv(
                                                                                                        = 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 );
 
@@ -4175,11 +4249,18 @@ protocol_module_cinsert::handle_realserver_recv(
                                        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 );
 
@@ -4197,11 +4278,18 @@ protocol_module_cinsert::handle_realserver_recv(
                                                                                                = 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 );
 
@@ -4406,8 +4494,6 @@ protocol_module_cinsert::handle_sorryserver_recv(
        }
        //---------- DEBUG LOG END ------------------------------
 
-       using namespace boost::xpressive;
-
        t_session_thread_data_cinsert   thread_data;
 
        recive_data             sorryserver_recv_data;
@@ -4431,7 +4517,6 @@ protocol_module_cinsert::handle_sorryserver_recv(
        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;
@@ -4666,11 +4751,18 @@ protocol_module_cinsert::handle_sorryserver_recv(
                                                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 );
 
@@ -4688,11 +4780,18 @@ protocol_module_cinsert::handle_sorryserver_recv(
                                                                                                                = 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 );
 
@@ -4835,11 +4934,18 @@ protocol_module_cinsert::handle_sorryserver_recv(
                                        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 );
 
@@ -4857,11 +4963,18 @@ protocol_module_cinsert::handle_sorryserver_recv(
                                                                                                = 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 );
 
@@ -5162,15 +5275,21 @@ protocol_module_cinsert::handle_client_connection_check(
                                        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 )
                                                {
 
index f5d2445..4b80cbe 100644 (file)
@@ -643,6 +643,7 @@ namespace l7vs{
                        }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)){
@@ -833,6 +834,7 @@ namespace l7vs{
                        }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)){
@@ -943,6 +945,7 @@ namespace l7vs{
        //! 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;
@@ -953,6 +956,7 @@ namespace l7vs{
                        up_thread_exit(process_type);
                        return;
                }
+               */
                
                if(0 < parent_service.get_wait_upstream()){
                        //----Debug log----------------------------------------------------------------------
@@ -1012,21 +1016,8 @@ namespace l7vs{
                        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];
@@ -1259,19 +1250,8 @@ namespace l7vs{
                }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];
@@ -1726,19 +1706,8 @@ namespace l7vs{
                }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];
@@ -2198,6 +2167,7 @@ namespace l7vs{
        //! 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;
@@ -2208,6 +2178,7 @@ namespace l7vs{
                        down_thread_exit(process_type);
                        return;
                }
+               */
                bool is_emp = down_thread_receive_realserver_socket_list.empty();
                if(is_emp){
                        boost::this_thread::yield();
@@ -2273,21 +2244,8 @@ namespace l7vs{
                        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];
@@ -2638,19 +2596,8 @@ namespace l7vs{
                }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];
@@ -2807,21 +2754,8 @@ namespace l7vs{
                        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];