⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_gzip.c

📁 look at this software its cool really cool
💻 C
📖 第 1 页 / 共 5 页
字号:
                  checktarget = r__content_type;                 }               else if ( ( this_type == MOD_GZIP_IMAP_ISFILE ) &&                         ( flen > 0 ) )                 {                  type_is_included = 1;                  checktarget = r__filename;                 }               else if ( ( this_type == MOD_GZIP_IMAP_ISURI ) &&                         ( ulen > 0 ) )                 {                  type_is_included = 1;                  checktarget = r__uri;                 }               else if ( ( this_type == MOD_GZIP_IMAP_ISHANDLER ) &&                         ( hlen > 0 ) )                 {                  type_is_included = 1;                  checktarget = r__handler;                 }              }            if ( type_is_included )              {               #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1               #ifdef MOD_GZIP_DEBUG1               mod_gzip_printf( "%s: type_is_included = %d = YES",cn,type_is_included);               #endif               #endif               this_name   = mgc->imap[x].name;               this_len1   = mgc->imap[x].len1;               this_pregex = mgc->imap[x].pregex;               ok_to_check_it = 1;               if ( http_field_check )                 {                  #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1                  #ifdef MOD_GZIP_DEBUG1                  mod_gzip_printf( "%s: fieldkey  = [%s]",cn,mod_gzip_npp(fieldkey));                  mod_gzip_printf( "%s: this_name = [%s]",cn,mod_gzip_npp(this_name));                  mod_gzip_printf( "%s: this_len1 = %d",  cn,this_len1);                  mod_gzip_printf( "%s: Call mod_gzip_strnicmp(fieldkey,this_name,this_len1)...",cn);                  #endif                  #endif                  if ( mod_gzip_strnicmp( fieldkey, this_name, this_len1 )==0)                    {                     #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1                     #ifdef MOD_GZIP_DEBUG1                     mod_gzip_printf( "%s: .... mod_gzip_strnicmp() = TRUE",cn);                     mod_gzip_printf( "%s: .... Field key name MATCHES",cn);                     #endif                     #endif                    }                  else                    {                     #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1                     #ifdef MOD_GZIP_DEBUG1                     mod_gzip_printf( "%s: .... mod_gzip_strnicmp() = FALSE",cn);                     mod_gzip_printf( "%s: .... Field key name does NOT MATCH",cn);                     #endif                     #endif                     ok_to_check_it = 0;                    }                 }               if ( ok_to_check_it )                 {                  #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1                  #ifdef MOD_GZIP_DEBUG1                  mod_gzip_printf( "%s: ok_to_check_it = %d = YES",cn,ok_to_check_it);                  #endif                  #endif                  if ( ( this_pregex ) && ( checktarget ) )                    {                     #ifdef MOD_GZIP_DEBUG1                     mod_gzip_printf( "%s: 'this_pregex' is NON-NULL",cn);                     mod_gzip_printf( "%s: Performing regular expression check...",cn);                     mod_gzip_printf( "%s: Call ap_regexec( this_name=[%s], checktarget=[%s] )",                                       cn, mod_gzip_npp(this_name), mod_gzip_npp(checktarget) );                     #endif                     regex_error =                     ap_regexec(                     this_pregex, checktarget, 0, (regmatch_t *) NULL, 0 );                     if ( regex_error == 0 )                       {                        #ifdef MOD_GZIP_DEBUG1                        mod_gzip_printf( "%s: YYYY regex_error = %d = MATCH!",cn,regex_error);                        #endif                        pass_result  = 1;                        action_value = this_action;                        break;                       }                     else                       {                        #ifdef MOD_GZIP_DEBUG1                        mod_gzip_printf( "%s: NNNN regex_error = %d = NO MATCH!",cn,regex_error);                        #endif                       }                    }                  else                    {                     #ifdef MOD_GZIP_DEBUG1                     if ( !this_pregex )                       {                        mod_gzip_printf( "%s: 'this_pregex' is NULL",cn);                       }                     if ( !checktarget )                       {                        mod_gzip_printf( "%s: 'checktarget' is NULL",cn);                       }                     mod_gzip_printf( "%s: No regular expression check performed",cn);                     #endif                    }                 }               else                 {                  #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1                  #ifdef MOD_GZIP_DEBUG1                  mod_gzip_printf( "%s: ok_to_check_it = %d = NO",cn,ok_to_check_it);                  mod_gzip_printf( "%s: The record has been SKIPPED...",cn);                  #endif                  #endif                 }              }            else              {               #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1               #ifdef MOD_GZIP_DEBUG1               mod_gzip_printf( "%s: type_is_included = %d = NO",cn,type_is_included);               mod_gzip_printf( "%s: The record has been SKIPPED...",cn);               #endif               #endif              }           }         else           {            #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1            #ifdef MOD_GZIP_DEBUG1            mod_gzip_printf( "%s: This record does NOT match filter_value %d",                              cn, filter_value );            mod_gzip_printf( "%s: The record has been SKIPPED...",cn);            #endif            #endif           }        }     #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1     #ifdef MOD_GZIP_DEBUG1     mod_gzip_printf( "%s: --------------------------------------------",cn);     mod_gzip_printf( "%s: pass_result = %d",cn,pass_result);     #endif     #endif     if ( pass_result )       {        if ( pass == 0 ) item_is_excluded = 1;        else             item_is_included = 1;        break;       }    }/* End 'for ( pass=0; pass<passes; pass++ )' */        #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: item_is_excluded = %d",cn,item_is_excluded); mod_gzip_printf( "%s: item_is_included = %d",cn,item_is_included); #endif if ( item_is_excluded )   {    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: The item is EXCLUDED...",cn);    mod_gzip_printf( "%s: Exit > return( MOD_GZIP_IMAP_DECLINED1 ) >",cn);    #endif    return( MOD_GZIP_IMAP_DECLINED1 );   } else if ( item_is_included )   {    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: The item is INCLUDED...",cn);    mod_gzip_printf( "%s: Exit > return( 1 ) >",cn);    #endif    return action_value;   } if ( http_field_check )   {    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: ?? Status unknown ?? Default is to 'accept'...",cn);    mod_gzip_printf( "%s: Exit > return( MOD_GZIP_IMAP_STATIC1 ) >",cn);    #endif    return MOD_GZIP_IMAP_STATIC1;   } #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: Exit > return( MOD_GZIP_IMAP_DECLINED1 ) >",cn); #endif return( MOD_GZIP_IMAP_DECLINED1 );}/* ELIGIBILITY CHECKS... */int mod_gzip_echeck1( request_rec *r, mod_gzip_conf *dconf ){ /* Primary eligibility checks... */ int         i           = 0; int         field_ok    = 0; int         action_flag = 0; const char *tablekey    = 0; const char *tablestring = 0; int accept_encoding_gzip_seen = 0; #ifdef MOD_GZIP_DEBUG1 char cn[]="mod_gzip_echeck1()"; mod_gzip_conf *sconf = 0; #endif /* Start... */ #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( " " ); mod_gzip_printf( "%s: #### Entry...",cn); mod_gzip_printf( "%s: r                = %ld", cn,(long)r); mod_gzip_printf( "%s: r->main          = %ld", cn,(long)r->main); mod_gzip_printf( "%s: r->next          = %ld", cn,(long)r->next); mod_gzip_printf( "%s: r->prev          = %ld", cn,(long)r->prev); mod_gzip_printf( "%s: r->header_only   = %ld", cn,(long)r->header_only ); mod_gzip_printf( "%s: r->method_number = %ld", cn,(long)r->method_number ); mod_gzip_printf( "%s: r->method        = [%s]",cn,mod_gzip_npp(r->method)); mod_gzip_printf( "%s: r->unparsed_uri  = [%s]",cn,mod_gzip_npp(r->unparsed_uri)); mod_gzip_printf( "%s: r->uri           = [%s]",cn,mod_gzip_npp(r->uri)); mod_gzip_printf( "%s: r->filename      = [%s]",cn,mod_gzip_npp(r->filename)); mod_gzip_printf( "%s: r->handler       = [%s]",cn,mod_gzip_npp(r->handler)); mod_gzip_printf( "%s: r->content_type  = [%s]",cn,mod_gzip_npp(r->content_type)); sconf = ( mod_gzip_conf * ) ap_get_module_config( r->server->module_config, &gzip_module ); mod_gzip_printf( "%s: r->server->server_hostname = [%s]", cn,mod_gzip_npp(r->server->server_hostname)); if ( sconf )   {    mod_gzip_printf( "%s: sconf        = %ld", cn,(long)sconf);    mod_gzip_printf( "%s: sconf->loc   = [%s]",cn,mod_gzip_npp(sconf->loc));    mod_gzip_printf( "%s: sconf->is_on = %ld", cn,(long)sconf->is_on);   } if ( dconf)   {    mod_gzip_printf( "%s: dconf        = %ld", cn,(long)dconf);    mod_gzip_printf( "%s: dconf->loc   = [%s]",cn,mod_gzip_npp(dconf->loc));    mod_gzip_printf( "%s: dconf->is_on = %ld", cn,(long)dconf->is_on);   } /* Show the request headers at this point in time... */ mod_gzip_printf( "%s: REQUEST HEADERS",cn); mod_gzip_dump_a_table( (request_rec *) r, (apr_table_t *) r->headers_in ); /* Show the response headers at this point in time... */ mod_gzip_printf( "%s: RESPONSE HEADERS",cn); mod_gzip_dump_a_table( (request_rec *) r, (apr_table_t *) r->headers_out ); #endif /* MOD_GZIP_DEBUG1 */ /* Begin checks... */ /* Do the quickest checks first... */ if ( !dconf )   {    #ifdef MOD_GZIP_USES_APACHE_LOGS    apr_table_setn( r->notes,"mod_gzip_result",                    apr_pstrdup(r->pool,"DECLINED:NO_DCONF"));    #endif    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: 'dconf' is NULL. Unable to continue.",cn);    mod_gzip_printf( "%s: Exit > return( DECLINED ) >", cn);    #endif    return DECLINED;   } if ( !dconf->is_on )   {    #ifdef MOD_GZIP_USES_APACHE_LOGS    apr_table_setn( r->notes,"mod_gzip_result",                    apr_pstrdup(r->pool,"DECLINED:OFF"));    #endif    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: 'dconf->is_on' is FALSE",cn);    mod_gzip_printf( "%s: mod_gzip is not turned ON for this location...",cn);    mod_gzip_printf( "%s: This transaction will be ignored...",cn);    mod_gzip_printf( "%s: Exit > return( DECLINED ) >",cn);    #endif    return DECLINED;   } /* Only accept HTTP 'GET' or 'POST' requests for now... */ if ( ( r->method_number != M_GET  ) &&      ( r->method_number != M_POST ) )   {    #ifdef MOD_GZIP_USES_APACHE_LOGS    apr_table_setn( r->notes,"mod_gzip_result",                    apr_pstrdup(r->pool,"DECLINED:NOT_GET_OR_POST"));    #endif    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: r->method_number is NOT M_GET or M_POST",cn);    mod_gzip_printf( "%s: Ignoring this request...",cn);    mod_gzip_printf( "%s: Exit > return( DECLINED ) >",cn);    #endif    return DECLINED;   } /* Always include a specific check of the 'r->header_only' flag... */ /* NOTE: Sometimes 'r->header_only' is used by certain modules */ /* as an internal flag regardless of the value of 'r->method_number'. */ if ( r->header_only  )   {    #ifdef MOD_GZIP_USES_APACHE_LOGS    apr_table_setn( r->notes,"mod_gzip_result",                    apr_pstrdup(r->pool,"DECLINED:HEAD_REQUEST"));    #endif    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: r->header_only is TRUE...",cn);    mod_gzip_printf( "%s: Ignoring this HEAD request...",cn);    mod_gzip_printf( "%s: Exit > return( DECLINED ) >",cn);    #endif    return DECLINED;   } /* Verify the HTTP protocol version setting(s)... */ #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: dconf->min_http = %ld", cn, (long) dconf->min_http ); mod_gzip_printf( "%s: r->proto_num    = %ld", cn, (long) r->proto_num ); #endif if ( ( dconf->min_http > 0 ) && ( r->proto_num > 0 ) )   {    if ( r->proto_num < dconf->min_http )      {       #ifdef MOD_GZIP_USES_APACHE_LOGS       apr_table_setn( r->notes,"mod_gzip_result",                       apr_pstrdup(r->pool,"DECLINED:HTTP_LEVEL_TOO_LOW"));       #endif       #ifdef MOD_GZIP_DEBUG1       mod_gzip_printf( "%s: HTTP protocol version level is TOO LOW", cn);       mod_gzip_printf( "%s: Exit > return( DECLINED ) >", cn);       #endif       return DECLINED;      }    else      {       #ifdef MOD_GZIP_DEBUG1       mod_gzip_printf( "%s: HTTP protocol version level is OK", cn);       #endif      }   } /* Check for pre-compressed static file requests... */ if ( r->filename )   {    if ( mod_gzip_strendswith( r->filename, ".gz", 1 ) )      {       apr_table_setn( r->notes,"mod_gzip_result",                      apr_pstrdup(r->pool,"DECLINED:FEXT_GZ"));       #ifdef MOD_GZIP_DEBUG1       mod_gzip_printf( "%s: r->filename ends with '.gz'...",cn);       mod_gzip_printf( "%s: Exit > return( DECLINED ) >",cn);       #endif       return DECLINED;      }    #ifdef MOD_GZIP_DEBUG1    else      {       #ifdef MOD_GZIP_DEBUG1       mod_gzip_printf( "%s: r->filename does NOT end with '.gz'...",cn);       mod_gzip_printf( "%s: OK to continue...",cn);       #endif      }    #endif   } /* Check for 'Accept-Encoding: gzip, deflate'... */ #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: Checking for [Accept-Encoding: gzip]", cn ); #endif tablestring = apr_table_get( r->headers_in, "Accept-Encoding" ); #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: r->headers_in->Accept-Encoding = [%s]",                   cn,mod_gzip_npp(tablestring)); #endif if ( tablestring )   {    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: 'Accept-Encoding' field seen...", cn);    mod_gzip_printf( "%s: Checking for 'gzip' value...", cn);    #endif    if ( mod_gzip_stringcontains( (char *)tablestring, "gzip" ) )      {       #ifdef MOD_GZIP_DEBUG1       mod_gzip_printf( "%s: 'gzip' value seen...", cn);       #endif       accept_encoding_gzip_seen = 1;      }    else      {       #ifdef MOD_GZIP_USES_APACHE_LOGS       apr_table_setn( r->notes,"mod_gzip_result",                       apr_pstrdup(r->pool,"DECLINED:NO_GZIP"));       #endif       #ifdef MOD_GZIP_DEBUG1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -