view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
print( STDERR "apxs specified? ", ( $ref->{apxs} ? "yes at $ref->{apxs}" : 'no' ), "\n" ) if( $MY_DEBUG );
if( !$ref->{apxs} )
{
my $apxs;
eval
{
require Apache2::BuildConfig;
require File::Spec;
require File::Which;
};
# perl -MApache2::BuildConfig -MData::Dump -lE 'my $c=Apache2::BuildConfig->new; say Data::Dump::dump($c)'
if( !$@ )
{
my $build = Apache2::BuildConfig->new;
$apxs = File::Spec->catfile( $build->{APXS_BINDIR}, 'apxs' ) if( $build->{APXS_BINDIR} );
undef( $apxs ) unless( -e( $apxs ) );
print( STDERR "Found apxs at $apxs\n" ) if( $MY_DEBUG );
}
if( !$apxs )
{
my $server = $api->server;
my $version = $api->server_version;
$api->set_handlers( $name => $code_reference );
$api->warn( @some_warnings );
my $hash = apr1_md5( $clear_password );
my $hash = apr1_md5( $clear_password, $salt );
my $ht = $api->htpasswd( $clear_password );
my $ht = $api->htpasswd( $clear_password, salt => $salt );
my $hash = $ht->hash;
say "Does our password match ? ", $ht->matches( $user_clear_password ) ? "yes" : "not";
VERSION
v0.5.1
DESCRIPTION
This module provides a comprehensive, powerful, yet simple framework to
access Apache mod_perl's API <https://perl.apache.org/docs/2.0/api/> and
documented appropriately.
Apache mod_perl is an awesome framework, but quite complexe with a steep
password file used in web basic authentication.
Upon error, this will die.
CONSTANTS
"mod_perl" provides constants through Apache2::Constant and
APR::Constant. Apache2::API makes all those constants available using
their respective package name, such as:
use Apache2::API;
say Apache2::Const::HTTP_BAD_REQUEST; # 400
You can import constants into your namespace by specifying them when
loading Apache2::API, such as:
use Apache2::API qw( HTTP_BAD_REQUEST );
say HTTP_BAD_REQUEST; # 400
Be careful, however, that there are over 400 Apache2 constants and some
common constant names in Apache2::Constant and APR::Constant, so it is
recommended to use the fully qualified constant names rather than
importing them into your namespace.
Some constants are special like "OK", "DECLINED" or "DECLINE_CMD"
Apache underlines
<https://perl.apache.org/docs/2.0/user/handlers/http.html#toc_HTTP_Reque
my $server = $api->server;
my $version = $api->server_version;
$api->set_handlers( $name => $code_reference );
$api->warn( @some_warnings );
my $hash = apr1_md5( $clear_password );
my $hash = apr1_md5( $clear_password, $salt );
my $ht = $api->htpasswd( $clear_password );
my $ht = $api->htpasswd( $clear_password, salt => $salt );
my $hash = $ht->hash;
say "Does our password match ? ", $ht->matches( $user_clear_password ) ? "yes" : "not";
# VERSION
v0.5.1
# DESCRIPTION
This module provides a comprehensive, powerful, yet simple framework to access [Apache mod\_perl's API](https://perl.apache.org/docs/2.0/api/) and documented appropriately.
Apache mod\_perl is an awesome framework, but quite complexe with a steep learning curve and methods all over the place. So much so that [they have developed a module dedicated to find appropriate methods](https://perl.apache.org/docs/2.0/user/coding...
The password returned is suitable to be used and saved in an Apache password file used in web basic authentication.
Upon error, this will die.
# CONSTANTS
`mod_perl` provides constants through [Apache2::Constant](https://metacpan.org/pod/Apache2%3A%3AConstant) and [APR::Constant](https://metacpan.org/pod/APR%3A%3AConstant). [Apache2::API](https://metacpan.org/pod/Apache2%3A%3AAPI) makes all those const...
use Apache2::API;
say Apache2::Const::HTTP_BAD_REQUEST; # 400
You can import constants into your namespace by specifying them when loading [Apache2::API](https://metacpan.org/pod/Apache2%3A%3AAPI), such as:
use Apache2::API qw( HTTP_BAD_REQUEST );
say HTTP_BAD_REQUEST; # 400
Be careful, however, that there are over 400 Apache2 constants and some common constant names in [Apache2::Constant](https://metacpan.org/pod/Apache2%3A%3AConstant) and [APR::Constant](https://metacpan.org/pod/APR%3A%3AConstant), so it is recommended...
Some constants are special like `OK`, `DECLINED` or `DECLINE_CMD`
Apache [underlines](https://perl.apache.org/docs/2.0/user/handlers/http.html#toc_HTTP_Request_Cycle_Phases) that "all handlers in the chain will be run as long as they return Apache2::Const::OK or Apache2::Const::DECLINED. Because stacked handlers is...
- `Apache2::Const::OK`
The only value that can be returned by all handlers is `Apache2::Const::OK`, which tells Apache that the handler has successfully finished its execution.
lib/Apache2/API.pm view on Meta::CPAN
my $server = $api->server;
my $version = $api->server_version;
$api->set_handlers( $name => $code_reference );
$api->warn( @some_warnings );
my $hash = apr1_md5( $clear_password );
my $hash = apr1_md5( $clear_password, $salt );
my $ht = $api->htpasswd( $clear_password );
my $ht = $api->htpasswd( $clear_password, salt => $salt );
my $hash = $ht->hash;
say "Does our password match ? ", $ht->matches( $user_clear_password ) ? "yes" : "not";
=head1 VERSION
v0.5.3
=head1 DESCRIPTION
This module provides a comprehensive, powerful, yet simple framework to access L<Apache mod_perl's API|https://perl.apache.org/docs/2.0/api/> and documented appropriately.
Apache mod_perl is an awesome framework, but quite complexe with a steep learning curve and methods all over the place. So much so that L<they have developed a module dedicated to find appropriate methods|https://perl.apache.org/docs/2.0/user/coding/...
lib/Apache2/API.pm view on Meta::CPAN
The password returned is suitable to be used and saved in an Apache password file used in web basic authentication.
Upon error, this will die.
=head1 CONSTANTS
C<mod_perl> provides constants through L<Apache2::Constant> and L<APR::Constant>. L<Apache2::API> makes all those constants available using their respective package name, such as:
use Apache2::API;
say Apache2::Const::HTTP_BAD_REQUEST; # 400
You can import constants into your namespace by specifying them when loading L<Apache2::API>, such as:
use Apache2::API qw( HTTP_BAD_REQUEST );
say HTTP_BAD_REQUEST; # 400
Be careful, however, that there are over 400 Apache2 constants and some common constant names in L<Apache2::Constant> and L<APR::Constant>, so it is recommended to use the fully qualified constant names rather than importing them into your namespace.
Some constants are special like C<OK>, C<DECLINED> or C<DECLINE_CMD>
Apache L<underlines|https://perl.apache.org/docs/2.0/user/handlers/http.html#toc_HTTP_Request_Cycle_Phases> that "all handlers in the chain will be run as long as they return Apache2::Const::OK or Apache2::Const::DECLINED. Because stacked handlers is...
=over 4
=item * C<Apache2::Const::OK>
lib/Apache2/API/Password.pod view on Meta::CPAN
=head1 SYNOPSIS
use Apache2::API::Password;
# Create a new hash from a cleartext password (random salt)
# MD5-crypt (APR1, "$apr1$") - default
my $ht = Apache2::API::Password->new( 'secret', create => 1 );
my $hash = $ht->hash; # "$apr1$abcd1234$...."
# Create APR1 with a provided salt (max 8 chars; [./0-9A-Za-z])
my $ht2 = Apache2::API::Password->new( 'secret', create => 1, salt => 'hfT7jp2q' );
say $ht2->hash;
# Wrap an existing APR1 ($apr1$) hash and verify user input
my $ht3 = Apache2::API::Password->new( '$apr1$hfT7jp2q$DcU1Hf5w2Q/9G8yqv1hbl.' );
my $ok = $ht3->matches( 'secret' );
# Bcrypt ($2y$), choose a cost (04..31); defaults to 12
my $b = Apache2::API::Password->new('s3cret', create => 1, algo => 'bcrypt', bcrypt_cost => 12);
say $b->hash; # "$2y$12$..."
# SHA-crypt ($5$ = SHA-256, $6$ = SHA-512), optionally set rounds
my $s6 = Apache2::API::Password->new('s3cret', create => 1, algo => 'sha512', sha_rounds => 150000);
say $s6->hash; # "$6$rounds=150000$..."
# Accessors
my $hash_password = $ht->hash;
# parsed from the hash
my $salt = $ht3->salt;
=head1 VERSION
v0.1.1
lib/Apache2/API/Password.pod view on Meta::CPAN
Compute a fresh hash using the instance salt and compare with the stored L<hash|/hash>.
Returns true if the cleartext password matches.
=head1 EXAMPLES
=head2 Creating a C<.htpasswd> line
my $user = 'john';
my $ht = Apache2::API::Password->new( 's3cret', create => 1 );
say join( ':', $user, $ht->hash );
=head2 Verifying a login
my $stored = '$apr1$hfT7jp2q$DcU1Hf5w2Q/9G8yqv1hbl.';
my $ht = Apache2::API::Password->new( $stored );
if( $ht->matches( $input_password ) )
{
# ok
}
lib/Apache2/API/Request.pm view on Meta::CPAN
my $dt = $req->str2datetime( $http_date_string );
my $rc = $req->subnet_of( $ip, $mask );
# APR::Table object
my $env = subprocess_env;
my $dir = $req->temp_dir;
my $r = $req->the_request;
my $dt = $req->time2datetime( $time );
say $req->time2str( $seconds );
# text/plain
my $type = $req->type;
my $raw = $req->unparsed_uri;
# Apache2::API::Request::Params
my $uploads = $req->uploads;
my $uri = $req->uri;
my $decoded = $req->url_decode( $url );
my $encoded = $req->url_encode( $url );
lib/Apache2/API/Status.pm view on Meta::CPAN
=encoding utf8
=head1 NAME
Apache2::API::Status - Apache2 Status Codes
=head1 SYNOPSIS
use Apache2::API::Status ':common';
use Apache2::API::Status ':all';
say Apache2::API::Status::HTTP_TOO_MANY_REQUESTS;
# returns code 429
use Apache2::API::Status;
# in German: Zu viele Anfragen
say $Apache2::API::Status::HTTP_CODES->{de_DE}->{429};
# same
say $Apache2::API::Status::HTTP_CODES->{de}->{429};
# In English: Too Many Requests
say $Apache2::API::Status::HTTP_CODES->{en_GB}->{429};
# same
say $Apache2::API::Status::HTTP_CODES->{en}->{429};
# in French: Trop de requête
say $Apache2::API::Status::HTTP_CODES->{fr_FR}->{429};
# same
say $Apache2::API::Status::HTTP_CODES->{fr}->{429};
# In Japanese: ãªã¯ã¨ã¹ãéå¤§ã§æå¦ãã
say $Apache2::API::Status::HTTP_CODES->{ja_JP}->{429};
# same
say $Apache2::API::Status::HTTP_CODES->{ja}->{429};
# In Korean: ë무 ë§ì ìì²
say $Apache2::API::Status::HTTP_CODES->{ko_KR}->{429};
# same
say $Apache2::API::Status::HTTP_CODES->{ko}->{429};
# In Russian: ÑлиÑком много запÑоÑов
say $Apache2::API::Status::HTTP_CODES->{ru_RU}->{429};
# same
say $Apache2::API::Status::HTTP_CODES->{ru}->{429};
# In simplified Chinese: 太å¤è¯·æ±
say $Apache2::API::Status::HTTP_CODES->{zh_CN}->{429};
# In Taiwanese (traditional) Chinese: 太å¤è«æ±
say $Apache2::API::Status::HTTP_CODES->{zh_TW}->{429};
But maybe more simply:
my $status = Apache2::API::Status->new;
say $status->status_message( 429 => 'ja_JP' );
# Or without the language code parameter, it will default to en_GB
say $status->status_message( 429 );
# Is success
say $status->is_info( 102 ); # true
say $status->is_success( 200 ); # true
say $status->is_redirect( 302 ); # true
say $status->is_error( 404 ); # true
say $status->is_client_error( 403 ); # true
say $status->is_server_error( 501 ); # true
=head1 VERSION
v0.2.1
=head1 DESCRIPTION
This module allows to get the localised version of the HTTP status for a given code for currently supported languages: fr_FR (French), en_GB (British English) and ja_JP (Japanese), de_DE (German), ko_KR (Korean), ru_RU (Russian), zh_CN (simplified Ch...
It also provides some functions to check if a given code is an information, success, redirect, error, client error or server error code.
t/00.load.t view on Meta::CPAN
# t/00.load.t - check module loading and create testing directory
BEGIN
{
use strict;
use warnings;
use lib './lib';
use Test2::V0;
}
# To build the list of modules:
# find ./lib -type f -name "*.pm" -print | xargs perl -lE 'my @f=sort(@ARGV); for(@f) { s,./lib/,,; s,\.pm$,,; s,/,::,g; substr( $_, 0, 0, q{use ok( ''} ); $_ .= q{'' );}; say $_; }'
BEGIN
{
use ok( 'Apache2::API' );
use ok( 'Apache2::API::DateTime' );
use ok( 'Apache2::API::Headers::Accept' );
use ok( 'Apache2::API::Headers::AcceptCommon' );
use ok( 'Apache2::API::Headers::AcceptLanguage' );
use ok( 'Apache2::API::Query' );
use ok( 'Apache2::API::Request' );
use ok( 'Apache2::API::Request::Params' );
t/02.datetime.t view on Meta::CPAN
require( "./t/env.pl" ) if( -e( "t/env.pl" ) );
};
use strict;
use warnings;
my $fmt = Apache2::API::DateTime->new;
isa_ok( $fmt, 'Apache2::API::DateTime' );
# To generate this list:
# perl -lnE '/^sub (?!init|[A-Z]|_)/ and say "can_ok( \$fmt, \''", [split(/\s+/, $_)]->[1], "\'' );"' ./lib/Apache2/API/DateTime.pm
can_ok( $fmt, 'format_datetime' );
can_ok( $fmt, 'parse_date' );
can_ok( $fmt, 'parse_datetime' );
can_ok( $fmt, 'str2datetime' );
can_ok( $fmt, 'str2time' );
can_ok( $fmt, 'time2datetime' );
can_ok( $fmt, 'time2str' );
my $dt = DateTime->now;
$dt->set_formatter( $fmt );
t/03.query.t view on Meta::CPAN
require( "./t/env.pl" ) if( -e( "t/env.pl" ) );
};
use strict;
use warnings;
my $qq = Apache2::API::Query->new( 'foo=1&foo=2&bar=3;bog=abc;bar=7;fluffy=3' );
isa_ok( $qq, 'Apache2::API::Query' );
# To generate this list:
# perl -lnE '/^sub (?!init|[A-Z]|_)/ and say "can_ok( \$qq, \''", [split(/\s+/, $_)]->[1], "\'' );"' ./lib/Apache2/API/Query.pm
can_ok( $qq, 'strip' );
can_ok( $qq, 'strip_except' );
can_ok( $qq, 'strip_null' );
can_ok( $qq, 'strip_like' );
can_ok( $qq, 'replace' );
can_ok( $qq, 'stringify' );
can_ok( $qq, 'qstringify' );
can_ok( $qq, 'revert' );
can_ok( $qq, 'has_changed' );
can_ok( $qq, 'hash' );
t/04.status.t view on Meta::CPAN
{
# use_ok( 'Apache2::API::Status', 'all' );
use ok( 'Apache2::API::Status', qw( :all ) );
};
my $s = Apache2::API::Status->new;
isa_ok( $s => 'Apache2::API::Status' );
# for m in `egrep -E '^sub ([a-z]\w+)' ./lib/Apache2/API/Status.pm| awk '{ print $2 }'`; do echo "can_ok( \$s => '$m' );"; done
# or
# egrep -E '^sub ' ./lib/Apache2/API/Status.pm | perl -lnE 'my $m = [split(/\s+/, $_)]->[1]; say "can_ok( \$s, ''$m'' );"'
# perl -lnE '/^sub (?!init|[A-Z]|_)/ and say "can_ok( \$s, \''", [split(/\s+/, $_)]->[1], "\'' );"' ./lib/Apache2/API/Status.pm
can_ok( $s, 'convert_short_lang_to_long' );
can_ok( $s, 'is_info' );
can_ok( $s, 'is_success' );
can_ok( $s, 'is_redirect' );
can_ok( $s, 'is_error' );
can_ok( $s, 'is_client_error' );
can_ok( $s, 'is_server_error' );
can_ok( $s, 'status_message' );
can_ok( $s, 'supported_languages' );
t/07.accept.t view on Meta::CPAN
use ok( 'Apache2::API::Headers::Accept' ) || BAIL_OUT( 'Unable to load Apache2::API::Headers::Accept' );
};
use strict;
use warnings;
my $accept = Apache2::API::Headers::Accept->new( 'text/html, application/json;q=0.5', debug => $DEBUG );
isa_ok( $accept, 'Apache2::API::Headers::Accept' );
# To generate this list:
# perl -lnE '/^sub (?!init|[A-Z]|_)/ and say "can_ok( \$accept, \''", [split(/\s+/, $_)]->[1], "\'' );"' ./lib/Apache2/API/Headers/AcceptCommon.pm ./lib/Apache2/API/Headers/Accept.pm
can_ok( $accept, 'header' );
can_ok( $accept, 'match' );
can_ok( $accept, 'preferences' );
can_ok( $accept, 'media_types' );
sub is_match
{
my( $hdr, $supported, $expect, $name ) = @_;
my $ac = Apache2::API::Headers::Accept->new( $hdr, debug => $DEBUG );
my $got = $ac->match( $supported );
t/08.accept_language.t view on Meta::CPAN
use ok( 'Apache2::API::Headers::AcceptLanguage' ) || BAIL_OUT( 'Unable to load Apache2::API::Headers::AcceptLanguage' );
};
use strict;
use warnings;
my $al = Apache2::API::Headers::AcceptLanguage->new( 'en-GB, fr-FR;q=0.8', debug => $DEBUG );
isa_ok( $al, 'Apache2::API::Headers::AcceptLanguage' );
# To generate this list:
# perl -lnE '/^sub (?!init|[A-Z]|_)/ and say "can_ok( \$al, \''", [split(/\s+/, $_)]->[1], "\'' );"' ./lib/Apache2/API/Headers/AcceptCommon.pm ./lib/Apache2/API/Headers/AcceptLanguage.pm
can_ok( $al, 'header' );
can_ok( $al, 'match' );
can_ok( $al, 'preferences' );
can_ok( $al, 'languages' );
can_ok( $al, 'locales' );
sub is_match
{
my( $hdr, $offers, $expect, $name ) = @_;
my $al = Apache2::API::Headers::AcceptLanguage->new( $hdr, debug => $DEBUG );
t/lib/Test/Apache2/API.pm view on Meta::CPAN
sub server { return( shift->_test({ method => 'server', expect => 'Apache2::ServerRec', type => 'isa' }) ); }
sub server_version { return( shift->_test({ method => 'server_version', expect => 'version', type => 'isa' }) ); }
sub _target { return( shift->api ); }
1;
# NOTE: POD
# Use this to generate the tests list:
# egrep -E '^sub ' ./t/lib/Test/Apache2/API.pm | perl -lnE 'my $m = [split(/\s+/, $_)]->[1]; say "=head2 $m\n"'
__END__
=encoding utf8
=head1 NAME
Test::Apache2::API - Apache2::API Testing Class
=head1 SYNOPSIS
t/lib/Test/Apache2/API/Request.pm view on Meta::CPAN
# url_encode
# user
sub user_agent { return( shift->_test({ method => 'user_agent', expect => 'Test-Apache2-API/v0.1.0' }) ); }
sub _target { return( shift->api->request ); }
1;
# NOTE: POD
# Use this to generate the tests list:
# egrep -E '^sub ' ./t/lib/Test/Apache2/API/Request.pm | perl -lnE 'my $m = [split(/\s+/, $_)]->[1]; say "=head2 $m\n"'
__END__
=encoding utf8
=head1 NAME
Test::Apache2::API::Request - Apache2::API::Request Testing Class
=head1 SYNOPSIS
t/lib/Test/Apache2/API/Response.pm view on Meta::CPAN
# x_content_type_options
# x_dns_prefetch_control
# x_frame_options
# x_xss_protection
sub _target { return( shift->api->response ); }
1;
# NOTE: POD
# Use this to generate the tests list:
# egrep -E '^sub ' ./t/lib/Test/Apache2/API/Response.pm | perl -lnE 'my $m = [split(/\s+/, $_)]->[1]; say "=head2 $m\n"'
__END__
=encoding utf8
=head1 NAME
Test::Apache2::API::Response - Apache2::API::Response Testing Class
=head1 SYNOPSIS