Apache2-API
view release on metacpan or search on metacpan
lib/Apache2/API/Request.pm view on Meta::CPAN
}
}
if( $vers )
{
$self->{_server_version} = $SERVER_VERSION = version->parse( $vers );
return( $self->{_server_version} );
}
return( '' );
}
# e.g. set_basic_credentials( $user, $password );
sub set_basic_credentials { return( shift->_try( 'request', 'set_basic_credentials', @_ ) ); }
# set_handlers( PerlCleanupHandler => [] );
# $ok = $r->set_handlers($hook_name => \&handler);
# $ok = $r->set_handlers($hook_name => ['Foo::Bar::handler', \&handler2]);
# $ok = $r->set_handlers($hook_name => []);
# $ok = $r->set_handlers($hook_name => undef);
# https://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html#C_set_handlers_
sub set_handlers { return( shift->_try( 'request', 'set_handlers', @_ ) ); }
sub slurp_filename { return( shift->_try( 'request', 'slurp_filename' ) ); }
lib/Apache2/API/Request.pm view on Meta::CPAN
my $server = $req->server;
my $addr = $req->server_addr;
my $admin = $req->server_admin;
my $hostname = $req->server_hostname;
my $name = $req->server_name;
my $port = $req->server_port;
my $proto = $req->server_protocol;
my $sig = $req->server_signature;
my $software = $req->server_software;
my $vers = $req->server_version;
$req->set_basic_credentials( $user => $password );
$req->set_handlers( $name => $code_ref );
my $data = $req->slurp_filename;
# Apache2::Connection object
my $socket = $req->socket;
my $status = $req->status;
my $line = $req->status_line;
my $dt = $req->str2datetime( $http_date_string );
my $rc = $req->subnet_of( $ip, $mask );
# APR::Table object
lib/Apache2/API/Request.pm view on Meta::CPAN
=head2 auth_name
my $auth_name = $req->auth_name();
my $auth_name = $req->auth_name( $new_auth_name );
Sets or gets the current Authorization realm, i.e. the per directory configuration directive C<AuthName>
The C<AuthName> directive creates protection realm within the server document space. To quote RFC 1945 "These realms allow the protected resources on a server to be partitioned into a set of protection spaces, each with its own authentication scheme ...
The client uses the root URL of the server to determine which authentication credentials to send with each HTTP request. These credentials are tagged with the name of the authentication realm that created them. Then during the authentication stage th...
=head2 auth_type
my $auth_type = $req->auth_type();
my $auth_type = $req->auth_type( $new_auth_type );
Sets or gets the type of authorization required for this request, i.e. the per directory configuration directive C<AuthType>
Normally C<AuthType> would be set to C<Basic> to use the basic authentication scheme defined in RFC 1945, Hypertext Transfer Protocol (HTTP/1.0). However, you could set to something else and implement your own authentication scheme.
lib/Apache2/API/Request.pm view on Meta::CPAN
apxs -q -v HTTPD_VERSION
If this does not work too, it will try to call the Apache binary (C<apache2> or C<httpd>) like:
apache2 -v
and extract the version.
It returns the version found as a L<version> object, or an empty string if nothing could be found.
=head2 set_basic_credentials
Provided with a user name and a password, this populates the incoming request headers table (C<headers_in>) with authentication headers for Basic Authorization as if the client has submitted those in first place:
$req->set_basic_credentials( $username, $password );
See L<Apache2::RequestUtil> for more information.
=head2 set_handlers
Set a list of handlers to be called for a given phase. Any previously set handlers are forgotten.
See L<Apache2::RequestUtil/set_handlers> for more information.
$ok = $req->set_handlers( $hook_name => \&handler );
lib/Apache2/API/Response.pm view on Meta::CPAN
unless( $self->{checkonly} )
{
return( $self->error( "No Apache2::API::Request was provided." ) ) if( !$r );
return( $self->error( "Apache2::API::Request provided ($r) is not an object!" ) ) if( !Scalar::Util::blessed( $r ) );
return( $self->error( "I was expecting an Apache2::API::Request, but instead I got \"$r\"." ) ) if( !$r->isa( 'Apache2::API::Request' ) );
}
return( $self );
}
# Response header: <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials>
sub allow_credentials { return( shift->_set_get_one( 'Access-Control-Allow-Credentials', @_ ) ); }
# Response header <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers>
sub allow_headers { return( shift->_set_get_one( 'Access-Control-Allow-Headers', @_ ) ); }
# <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods>
sub allow_methods { return( shift->_set_get_one( 'Access-Control-Allow-Methods', @_ ) ); }
# <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin>
sub allow_origin { return( shift->_set_get_one( 'Access-Control-Allow-Origin', @_ ) ); }
lib/Apache2/API/Response.pm view on Meta::CPAN
=head1 SYNOPSIS
use Apache2::API::Response;
# $r is the Apache2::RequestRec object
my $resp = Apache2::API::Response->new( request => $r, debug => 1 );
# or, to test it outside of a modperl environment:
my $resp = Apache2::API::Response->new( request => $r, debug => 1, checkonly => 1 );
# Access-Control-Allow-Credentials
my $cred = $resp->allow_credentials;
# Access-Control-Allow-Headers
$resp->allow_headers( $custom_header );
# Access-Control-Allow-Methods
$resp->allow_methods( $method );
$reso->allow_origin( $origin );
# Alt-Svc
my $alt = $resp->alt_svc;
my $nbytes = $resp->bytes_sent;
# Cache-Control
my $cache = $resp->cache_control;
lib/Apache2/API/Response.pm view on Meta::CPAN
Optional. If set with a positive integer, this will activate verbose debugging message
=item * C<request>
This is a required parameter to be sent with a value set to a L<Apache2::RequestRec> object
=back
=head1 METHODS
=head2 allow_credentials
Sets or gets the HTTP header field C<Access-Control-Allow-Credentials>
See L<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials>
=head2 allow_headers
Sets or gets the HTTP header field C<Access-Control-Allow-Credentials>
See L<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers>
t/lib/Test/Apache2/API/Request.pm view on Meta::CPAN
# server_addr
# server_admin
# server_hostname
# server_name
# server_port
# server_protocol
# server_signature
# server_software
# server_version
# set_basic_credentials
# set_handlers
# slurp_filename
sub socket { return( shift->_test({ method => 'socket', expect => 'APR::Socket', type => 'isa' }) ); }
# status
# status_line
# str2datetime
# str2time
# subnet_of
t/lib/Test/Apache2/API/Response.pm view on Meta::CPAN
use Apache2::API;
use Scalar::Util;
# 2021-11-1T17:12:10+0900
use Test::Time time => 1635754330;
use constant HAS_SSL => ( $ENV{HTTPS} || ( defined( $ENV{SCRIPT_URI} ) && substr( lc( $ENV{SCRIPT_URI} ), 0, 5 ) eq 'https' ) ) ? 1 : 0;
};
use strict;
use warnings;
# allow_credentials
# allow_headers
# allow_methods
# allow_origin
# alt_svc
# bytes_sent
# cache_control
# clear_site_data
sub connection { return( shift->_test({ method => 'connection', expect => 'Apache2::Connection', type => 'isa' }) ); }
( run in 0.267 second using v1.01-cache-2.11-cpan-4d50c553e7e )