Config-ApacheFormat
view release on metacpan or search on metacpan
ApacheFormat.pm view on Meta::CPAN
Since only scalars are supported, if you use a multi-value, you will
only get back the first one:
Options Plus Minus "About the Same"
Values $Options
In this examples, "Values" will become "Plus". This is seldom a limitation
since in most cases, variable subsitution is used like the first example
shows. This option defaults to 0.
=item setenv_vars
If this is set to 1, then the special C<SetEnv> directive will be set
values in the environment via C<%ENV>. Also, the special C<UnSetEnv>
directive will delete environment variables.
For example:
# $ENV{PATH} = "/usr/sbin:/usr/bin"
SetEnv PATH "/usr/sbin:/usr/bin"
ApacheFormat.pm view on Meta::CPAN
# declare generated methods
use Class::MethodMaker
new_with_init => "new",
new_hash_init => "hash_init",
get_set => [ -noclear => qw/
inheritance_support
include_support
autoload_support
case_sensitive
expand_vars
setenv_vars
valid_directives
valid_blocks
duplicate_directives
hash_directives
fix_booleans
root_directive
include_directives
_parent
_data
_block_vals
ApacheFormat.pm view on Meta::CPAN
# setup defaults
sub init {
my $self = shift;
my %args = (
inheritance_support => 1,
include_support => 1,
autoload_support => 0,
case_sensitive => 0,
expand_vars => 0,
setenv_vars => 0,
valid_directives => undef,
valid_blocks => undef,
duplicate_directives=> 'last',
include_directives => ['Include'],
hash_directives => undef,
fix_booleans => 0,
root_directive => undef,
_data => {},
@_);
ApacheFormat.pm view on Meta::CPAN
# weaken() to avoid creating a circular reference that
# would leak memory)
my $parent = $self;
weaken($parent);
my $block = ref($self)->new(
inheritance_support => $self->{inheritance_support},
include_support => $self->{include_support},
autoload_support => $self->{autoload_support},
case_sensitive => $case_sensitive,
expand_vars => $self->{expand_vars},
setenv_vars => $self->{setenv_vars},
valid_directives => $self->{valid_directives},
valid_blocks => $self->{valid_blocks},
duplicate_directives=> $self->{duplicate_directives},
hash_directives => $self->{hash_directives},
fix_booleans => $self->{fix_booleans},
root_directive => $self->{root_directive},
include_directives => $self->{include_directives},
_parent => $parent,
_block_vals => ref $val ? $val : [ $val ],
);
ApacheFormat.pm view on Meta::CPAN
croak("Error in config file $filename, line $$line_num: $@")
if $@;
# expand_vars if set
eval {
@val = $self->_expand_vars(@val) if $self->{expand_vars};
};
croak("Error in config file $filename, line $$line_num: $@")
if $@;
# and then setenv too (allowing PATH "$BASEDIR/bin")
if ($self->{setenv_vars}) {
if ($name =~ /^setenv$/i) {
croak("Error in config file $filename, line $$line_num: ".
" can't use setenv_vars " .
"with malformed SetEnv directive") if @val != 2;
$ENV{"$val[0]"} = $val[1];
} elsif ($name =~ /^unsetenv$/i) {
croak("Error in config file $filename, line $$line_num: ".
"can't use setenv_vars " .
"with malformed UnsetEnv directive") unless @val;
delete $ENV{$_} for @val;
}
}
# Include processing
# because of the way our inheritance works, we navigate multiple files in reverse
if ($name =~ /$include_re/) {
for my $f (reverse @val) {
# if they specified a root_directive (ServerRoot) and
ApacheFormat.pm view on Meta::CPAN
To parse a real Apache config file (ex. C<httpd.conf>) you'll need to
use some non-default options. Here's a reasonable starting point:
$config = Config::ApacheFormat->new(
root_directive => 'ServerRoot',
hash_directives => [ 'AddHandler' ],
include_directives => [ 'Include',
'AccessConfig',
'ResourceConfig' ],
setenv_vars => 1,
fix_booleans => 1);
=head1 TODO
Some possible ideas for future development:
=over 4
- Nathan Wiger ported many features from Apache::ConfigFile in an
effort to combine the two modules. These features include:
o The fix_booleans option, which allows automatic conversion
of yes/on/true to 1 and no/off/false to 0
o The expand_vars option, allowing reuse of previously-defined
directives as $directive
o The setenv_vars option, which will automatically place
variables defined via the SetEnv directive into the %ENV
hash
o The hash_directives option, which allows proper handling of
directives where the first value is really a key
(ex. AddHandler).
o The duplicate_directives option, which allows the programmer
to choose how duplicate directives are handled (by default
the last one is kept, allowing subsequent configs to
t/02block.t
t/03leak.t
t/04include.t
t/05autoload.t
t/06validate.t
t/07largeconf.t
t/08error.t
t/09includedir.t
t/10fixbools.t
t/11expandvars.t
t/12setenvars.t
t/basic.conf
t/block.conf
t/error.conf
t/error_block.conf
t/error_include.conf
t/error_includer.conf
t/expandvars.conf
t/first.conf
t/fixbools.conf
t/httpd.conf
t/included.conf
t/includedir.conf
t/includer.conf
t/large.conf
t/second.conf
t/setenvars.conf
t/includer_with_root.conf
t/crazy_includer.conf
- Nathan Wiger ported many features from Apache::ConfigFile in an
effort to combine the two modules. These features include:
o The fix_booleans option, which allows automatic conversion
of yes/on/true to 1 and no/off/false to 0
o The expand_vars option, allowing reuse of previously-defined
directives as $directive
o The setenv_vars option, which will automatically place
variables defined via the SetEnv directive into the %ENV
hash
o The hash_directives option, which allows proper handling of
directives where the first value is really a key
(ex. AddHandler).
o The duplicate_directives option, which allows the programmer
to choose how duplicate directives are handled (by default
the last one is kept, allowing subsequent configs to
t/12setenvars.t view on Meta::CPAN
use Test::More tests => 13;
BEGIN { use_ok 'Config::ApacheFormat'; }
$ENV{PRESET} = $ENV{VARS} = 1;
my $config = Config::ApacheFormat->new(setenv_vars => 1, expand_vars => 1);
$config->read("t/setenvars.conf");
is($config->get('SPECIALNESS'), "Super");
isnt($ENV{SPECIALNESS}, "Super");
is($config->get('toughness'), '*Negative*');
isnt($ENV{TOUGHNESS}, '*Negative*');
is($config->get('bindir'), 'bin');
is($ENV{bindir}, undef);
is($config->get('ORACLE_HOME'), '/oracle/bin');
isnt($ENV{'ORACLE_HOME'}, '/oracle/bin');
is($ENV{'SUPER'}, ($config->get('setenv'))[1]);
is($ENV{PRESET}, undef);
is($ENV{VARS}, undef);
is($config->get('SomeVar'), 'yabba');
t/httpd.conf view on Meta::CPAN
LoadModule anon_auth_module libexec/mod_auth_anon.so
LoadModule dbm_auth_module libexec/mod_auth_dbm.so
LoadModule digest_module libexec/mod_digest.so
LoadModule proxy_module libexec/libproxy.so
LoadModule cern_meta_module libexec/mod_cern_meta.so
LoadModule expires_module libexec/mod_expires.so
LoadModule headers_module libexec/mod_headers.so
LoadModule usertrack_module libexec/mod_usertrack.so
LoadModule example_module libexec/mod_example.so
LoadModule unique_id_module libexec/mod_unique_id.so
LoadModule setenvif_module libexec/mod_setenvif.so
LoadModule perl_module libexec/libperl.so
# Reconstruction of the complete module list from all available modules
# (static and shared ones) to achieve correct module execution order.
# [WHENEVER YOU CHANGE THE LOADMODULE SECTION ABOVE UPDATE THIS, TOO]
ClearModuleList
AddModule mod_mmap_static.c
AddModule mod_vhost_alias.c
AddModule mod_env.c
AddModule mod_log_config.c
t/httpd.conf view on Meta::CPAN
AddModule mod_auth_dbm.c
AddModule mod_digest.c
AddModule mod_proxy.c
AddModule mod_cern_meta.c
AddModule mod_expires.c
AddModule mod_headers.c
AddModule mod_usertrack.c
AddModule mod_example.c
AddModule mod_unique_id.c
AddModule mod_so.c
AddModule mod_setenvif.c
AddModule mod_perl.c
#
# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
#ExtendedStatus On
### Section 2: 'Main' server configuration
t/httpd.conf view on Meta::CPAN
# request will *not* be available to such a script.
ErrorDocument 402 /errors/402.html
ErrorDocument 403 /errors/403.html
ErrorDocument 404 /errors/404.html
ErrorDocument 500 /errors/500.html
#
# Customize behaviour based on the browser
#
<IfModule mod_setenvif.c>
#
# The following directives modify normal HTTP response behavior.
# The first directive disables keepalive for Netscape 2.x and browsers that
# spoof it. There are known problems with these browser implementations.
# The second directive is for Microsoft Internet Explorer 4.0b2
# which has a broken HTTP/1.1 implementation and does not properly
# support keepalive when it is used on 301 or 302 (redirect) responses.
#
BrowserMatch "Mozilla/2" nokeepalive
t/large.conf view on Meta::CPAN
LoadModule autoindex_module libexec/mod_autoindex.so
LoadModule dir_module libexec/mod_dir.so
LoadModule cgi_module libexec/mod_cgi.so
LoadModule asis_module libexec/mod_asis.so
LoadModule imap_module libexec/mod_imap.so
LoadModule action_module libexec/mod_actions.so
LoadModule alias_module libexec/mod_alias.so
LoadModule rewrite_module libexec/mod_rewrite.so
LoadModule access_module libexec/mod_access.so
LoadModule auth_module libexec/mod_auth.so
LoadModule setenvif_module libexec/mod_setenvif.so
LoadModule p14_module libexec/mod_p14.so
LoadModule expires_module libexec/mod_expires.so
LoadModule headers_module libexec/mod_headers.so
LoadModule proxy_module libexec/libproxy.so
LoadModule status_module libexec/mod_status.so
LoadModule arm_module libexec/mod_arm.so
ClearModuleList
AddModule mod_env.c
AddModule mod_log_config.c
t/large.conf view on Meta::CPAN
AddModule mod_dir.c
AddModule mod_cgi.c
AddModule mod_asis.c
AddModule mod_imap.c
AddModule mod_actions.c
AddModule mod_alias.c
AddModule mod_rewrite.c
AddModule mod_access.c
AddModule mod_auth.c
AddModule mod_so.c
AddModule mod_setenvif.c
AddModule mod_perl.c
AddModule apache_ssl.c
AddModule mod_p14.c
AddModule mod_headers.c
AddModule mod_expires.c
AddModule mod_proxy.c
AddModule mod_status.c
AddModule mod_arm.c
LogLevel warn
( run in 0.454 second using v1.01-cache-2.11-cpan-3989ada0592 )