view release on metacpan or search on metacpan
CHANGES
CONTRIBUTING.md
lib/Apache2/API.pm
lib/Apache2/API/DateTime.pm
lib/Apache2/API/Headers/Accept.pm
lib/Apache2/API/Headers/AcceptCommon.pm
lib/Apache2/API/Headers/AcceptLanguage.pm
lib/Apache2/API/Password.pod
lib/Apache2/API/Query.pm
lib/Apache2/API/Request.pm
lib/Apache2/API/Request/Params.pm
lib/Apache2/API/Request/Upload.pm
lib/Apache2/API/Response.pm
lib/Apache2/API/Status.pm
"Apache2::Reload" : "0",
"Apache2::Request" : "0",
"Apache2::RequestIO" : "0",
"Apache2::RequestRec" : "0",
"Apache2::RequestUtil" : "0",
"Apache2::Response" : "0",
"Apache2::ServerUtil" : "0",
"Apache2::SubRequest" : "0",
"Apache::Test" : "0",
"Cookie" : "v0.2.4",
"DateTime" : "1.57",
"DateTime::Format::Strptime" : "1.79",
"DateTime::TimeZone" : "2.51",
"DateTime::TimeZone::Catalog::Extend" : "v0.3.0",
"Encode" : "3.01",
"Exporter" : "5.70",
"HTTP::AcceptLanguage" : "0.02",
"JSON" : "4.03",
"JSON::XS" : "4.03",
"Module::Generic" : "v1.2.4",
"Regexp::Common" : "0",
"Scalar::Util" : "1.50",
"URI" : "0",
"URI::Escape" : "3.31",
Apache2::Reload: '0'
Apache2::Request: '0'
Apache2::RequestIO: '0'
Apache2::RequestRec: '0'
Apache2::RequestUtil: '0'
Apache2::Response: '0'
Apache2::ServerUtil: '0'
Apache2::SubRequest: '0'
Apache::Test: '0'
Cookie: v0.2.4
DateTime: '1.57'
DateTime::Format::Strptime: '1.79'
DateTime::TimeZone: '2.51'
DateTime::TimeZone::Catalog::Extend: v0.3.0
Encode: '3.01'
Exporter: '5.70'
HTTP::AcceptLanguage: '0.02'
JSON: '4.03'
JSON::XS: '4.03'
Module::Generic: v1.2.4
Regexp::Common: '0'
Scalar::Util: '1.50'
URI: '0'
URI::Escape: '3.31'
Makefile.PL view on Meta::CPAN
'Apache2::Response' => 0,
'Apache2::ServerUtil' => 0,
'Apache2::SubRequest' => 0,
'APR::Base64' => 0,
'APR::Pool' => 0,
'APR::Request::Apache2' => 0,
'APR::Request::Cookie' => 0,
'APR::Socket' => 0,
'APR::UUID' => 0,
'Cookie' => 'v0.2.4',
'DateTime' => '1.57',
'DateTime::Format::Strptime' => '1.79',
'DateTime::TimeZone' => '2.51',
'DateTime::TimeZone::Catalog::Extend' => 'v0.3.0',
# 'Devel::Confess' => 0,
'Encode' => '3.01',
'Exporter' => '5.70',
'HTTP::AcceptLanguage' => '0.02',
'JSON' => '4.03',
'JSON::XS' => '4.03',
'Module::Generic' => 'v1.2.4',
'Regexp::Common' => 0,
'Scalar::Util' => '1.50',
'URI' => 0,
A list of handlers configured to run at the child_exit phase:
@handlers = @{ $res->get_handlers( 'PerlChildExitHandler' ) || []};
gettext( 'string id' )
Get the localised version of the string passed as an argument.
This is supposed to be superseded by the package inheriting from
Apache2::API, if any.
header_datetime( DateTime object )
Given a DateTime object, this sets it to GMT time zone and set the
proper formatter (Apache2::API::DateTime) so that the stringification is
compliant with HTTP headers standard.
htpasswd
my $ht = $api->htpasswd( $clear_password, create => 1 );
my $ht = $api->htpasswd( $clear_password, create => 1, salt => $salt );
my $ht = $api->htpasswd( $md5_password );
my $bool = $ht->matches( $user_input_password );
This instantiates a new Apache2::API::Password object by providing its
constructor whatever arguments was received.
See for more information
<https://perl.apache.org/docs/general/testing/testing.html>
API CORE MODULES
Apache2::RequestIO, Apache2::RequestRec
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
Apache2::API::DateTime, Apache2::API::Query, Apache2::API::Request,
Apache2::API::Request::Params, Apache2::API::Request::Upload,
Apache2::API::Response, Apache2::API::Status
Apache2::Request, Apache2::RequestRec, Apache2::RequestUtil
COPYRIGHT & LICENSE
Copyright (c) 2023 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated
files under the same terms as Perl itself.
A list of handlers configured to run at the child\_exit phase:
@handlers = @{ $res->get_handlers( 'PerlChildExitHandler' ) || []};
## gettext( 'string id' )
Get the localised version of the string passed as an argument.
This is supposed to be superseded by the package inheriting from [Apache2::API](https://metacpan.org/pod/Apache2%3A%3AAPI), if any.
## header\_datetime( DateTime object )
Given a [DateTime](https://metacpan.org/pod/DateTime) object, this sets it to GMT time zone and set the proper formatter ([Apache2::API::DateTime](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3ADateTime)) so that the stringification is compliant with...
## htpasswd
my $ht = $api->htpasswd( $clear_password, create => 1 );
my $ht = $api->htpasswd( $clear_password, create => 1, salt => $salt );
my $ht = $api->htpasswd( $md5_password );
my $bool = $ht->matches( $user_input_password );
This instantiates a new [Apache2::API::Password](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3APassword) object by providing its constructor whatever arguments was received.
## API CORE MODULES
[Apache2::RequestIO](https://metacpan.org/pod/Apache2%3A%3ARequestIO), [Apache2::RequestRec](https://metacpan.org/pod/Apache2%3A%3ARequestRec)
# AUTHOR
Jacques Deguest <`jack@deguest.jp`>
# SEE ALSO
[Apache2::API::DateTime](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3ADateTime), [Apache2::API::Query](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3AQuery), [Apache2::API::Request](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3ARequest), [Apache2:...
[Apache2::Request](https://metacpan.org/pod/Apache2%3A%3ARequest), [Apache2::RequestRec](https://metacpan.org/pod/Apache2%3A%3ARequestRec), [Apache2::RequestUtil](https://metacpan.org/pod/Apache2%3A%3ARequestUtil)
# COPYRIGHT & LICENSE
Copyright (c) 2023 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated
files under the same terms as Perl itself.
SHA256 01ea73e8ee89d89bc553abaa0a5b36d35d0ba575d1297d9365aeec5dd1e6dc43 CHANGES
SHA256 25f6ba69275b57663835eccaa5d12acdb4352a4e19db38aadef10373c1cfe84f CONTRIBUTING.md
SHA256 edfd0d22397be2200f9759277852e3b562411caf05de790071cd2f612cb1ac84 MANIFEST
SHA256 399a53d94ff7d529e28b81058fde1be3ae48d949cc50f0be0e8a82b485d9431d META.json
SHA256 8ed4420c13e59c7fcbb58859f69c2e980e78a198ea22416664b5f45eacb0653d META.yml
SHA256 fabf03fde294bfb208698b623b5ff07aaeef9b38167a86ccaf2cc52ac4061cc2 Makefile.PL
SHA256 9b55a1a4f44f40b324f9a3e5a6f817b6d04e273848833c0a743a6f5bf2508ab6 README
SHA256 b57f3467d0831a5700ec21a1575daaad0e59d810b184ff32095aab1d739f3211 README.md
SHA256 afbc473ac098cd4081dd7908c48b62d801d921f5bba179beff5d8ec0923d6808 lib/Apache2/API.pm
SHA256 89caca2638565695b42e31278286e61d4da7a5d8da3d573d9b88e6bb77d00d69 lib/Apache2/API/DateTime.pm
SHA256 81947d998030a60af61c02a90d3c874532e18342220460cc57942a4e8c62711b lib/Apache2/API/Headers/Accept.pm
SHA256 5fe01d9fbe0b21d6741db442bd08a9be8ebfb03218a0e9c85385087c07514fd8 lib/Apache2/API/Headers/AcceptCommon.pm
SHA256 ff84773ea01e952b3ec5748751f16fb60e61b02b0f00f355801a3129c0e0a795 lib/Apache2/API/Headers/AcceptLanguage.pm
SHA256 4b15b78dd220b1b99cd047668b46f6b5295de5eb4ace02c3de020a13e3ce3c53 lib/Apache2/API/Password.pod
SHA256 cd188ea43b1d40b2b104afa22b272ae8794d2020461f8a78eeb1aa54e7228183 lib/Apache2/API/Query.pm
SHA256 6b8ada21bb2d492ff92c8dc1e474ee2049d0e52a1fd34550740ae45aa2b42f34 lib/Apache2/API/Request.pm
SHA256 16cdff5ee90b55fd4528fa14f073112da38009a80a5745b89ff678f68f20e181 lib/Apache2/API/Request/Params.pm
SHA256 01f02c3be02e2291038d8fa38e21f46ee7ed9556a4aed5b75bc76d327cba33c4 lib/Apache2/API/Request/Upload.pm
SHA256 79ee6c062ceab472a170ee3b46347895a6a5f6a1d2f31ad9136ae1a6491dab8f lib/Apache2/API/Response.pm
SHA256 d3439e54bbfc4d790689639905b20977a876381e91bbaefb58f82027a8ad1af1 lib/Apache2/API/Status.pm
lib/Apache2/API.pm view on Meta::CPAN
# This gives a chance to return a localised version of our string to the user
sub gettext { return( $_[1] ); }
sub header_datetime
{
my $self = shift( @_ );
my $dt;
if( @_ )
{
return( $self->error( "Date time provided (", ( $_[0] // 'undef' ), ") is not an object." ) ) if( !Scalar::Util::blessed( $_[0] ) );
return( $self->error( "Object provided (", ref( $_[0] ), ") is not a DateTime object." ) ) if( !$_[0]->isa( 'DateTime' ) );
$dt = shift( @_ );
}
$dt = DateTime->now if( !defined( $dt ) );
my $fmt = Apache2::API::DateTime->new;
$dt->set_formatter( $fmt );
return( $dt );
}
sub htpasswd
{
my $self = shift( @_ );
my $rv = Apache2::API::Password->new( @_ );
if( !defined( $rv ) && Apache2::API::Password->error )
{
lib/Apache2/API.pm view on Meta::CPAN
A list of handlers configured to run at the child_exit phase:
@handlers = @{ $res->get_handlers( 'PerlChildExitHandler' ) || []};
=head2 gettext( 'string id' )
Get the localised version of the string passed as an argument.
This is supposed to be superseded by the package inheriting from L<Apache2::API>, if any.
=head2 header_datetime( DateTime object )
Given a L<DateTime> object, this sets it to GMT time zone and set the proper formatter (L<Apache2::API::DateTime>) so that the stringification is compliant with HTTP headers standard.
=head2 htpasswd
my $ht = $api->htpasswd( $clear_password, create => 1 );
my $ht = $api->htpasswd( $clear_password, create => 1, salt => $salt );
my $ht = $api->htpasswd( $md5_password );
my $bool = $ht->matches( $user_input_password );
This instantiates a new L<Apache2::API::Password> object by providing its constructor whatever arguments was received.
lib/Apache2/API.pm view on Meta::CPAN
=head2 API CORE MODULES
L<Apache2::RequestIO>, L<Apache2::RequestRec>
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
L<Apache2::API::DateTime>, L<Apache2::API::Query>, L<Apache2::API::Request>, L<Apache2::API::Request::Params>, L<Apache2::API::Request::Upload>, L<Apache2::API::Response>, L<Apache2::API::Status>
L<Apache2::Request>, L<Apache2::RequestRec>, L<Apache2::RequestUtil>
=head1 COPYRIGHT & LICENSE
Copyright (c) 2023 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated
files under the same terms as Perl itself.
lib/Apache2/API/DateTime.pm view on Meta::CPAN
# -*- perl -*-
##----------------------------------------------------------------------------
## Apache2 API Framework - ~/lib/Apache2/API/DateTime.pm
## Version v0.1.2
## Copyright(c) 2023 DEGUEST Pte. Ltd.
## Author: Jacques Deguest <jack@deguest.jp>
## Created 2023/05/30
## Modified 2024/09/04
## All rights reserved
##
##
## This program is free software; you can redistribute it and/or modify it
## under the same terms as Perl itself.
##----------------------------------------------------------------------------
package Apache2::API::DateTime;
BEGIN
{
use strict;
use warnings;
warnings::register_categories( 'Apache2::API' );
use parent qw( Module::Generic );
use vars qw( $VERSION );
use APR::Date;
use DateTime;
our $VERSION = 'v0.1.2';
};
use strict;
use warnings;
sub format_datetime
{
my( $self, $dt ) = @_;
$dt = DateTime->now unless( defined( $dt ) );
$dt = $dt->clone->set_time_zone( 'GMT' );
return( $dt->strftime( '%a, %d %b %Y %H:%M:%S GMT' ) );
}
# Using APR::Date::parse_http instead?
# <https://perl.apache.org/docs/2.0/api/APR/Date.html#toc_C_parse_http_>
sub parse_date
{
my $self = shift( @_ );
my $date = shift( @_ ) || return( $self->error( "No date to parse was provided." ) );
lib/Apache2/API/DateTime.pm view on Meta::CPAN
$dt = $self->_parse_timestamp( $date );
return( $self->pass_error ) if( !defined( $dt ) );
return( $dt );
}
else
{
# try-catch
local $@;
eval
{
$dt = DateTime->from_epoch( epoch => $time );
};
if( $@ )
{
return( $self->error( "Error instantiating a DateTime object with the epoch value equivalent of the date provided $date: $@" ) );
}
return( $dt );
}
}
sub str2datetime { return( shift->parse_datetime( @_ ) ); }
sub str2time
{
my $self = shift( @_ );
my $dt = $self->str2datetime( @_ );
return if( !defined( $dt ) );
return( $dt->epoch );
}
sub time2datetime
{
my $self = shift( @_ );
my $time = shift( @_ );
$time = time() unless( defined( $time ) );
my $dt = DateTime->from_epoch( epoch => $time );
$dt->set_formatter( $self );
return( $dt );
}
sub time2str
{
my $self = shift( @_ );
my $dt = $self->time2datetime( @_ );
$dt->set_formatter( $self );
my $str = "$dt";
lib/Apache2/API/DateTime.pm view on Meta::CPAN
# NOTE: sub THAW is inherited
1;
# NOTE: POD
__END__
=encoding utf8
=head1 NAME
Apache2::API::DateTime - HTTP DateTime Manipulation and Formatting
=head1 SYNOPSIS
use Apache2::API::DateTime;
my $d = Apache2::API::DateTime->new( debug => 3 );
my $dt = DateTime->now;
$dt->set_formatter( $d );
print( "$dt\n" );
## will produce
Sun, 15 Dec 2019 15:32:12 GMT
my( @parts ) = $d->parse_date( $date_string );
my $datetime_object = $d->str2datetime( $date_string );
$datetime_object->set_formatter( $d );
my $timestamp_in_seconds = $d->str2time( $date_string );
my $datetime_object = $d->time2datetime( $timestamp_in_seconds );
my $datetime_string = $d->time2str( $timestamp_in_seconds );
=head1 VERSION
v0.1.2
=head1 DESCRIPTION
This module contains methods to create and manipulate datetime representation from and to L<DateTime> object or unix timestamps.
When using it as a formatter to a L<DateTime> object, this will make sure it is properly formatted for its use in HTTP headers and cookies.
=head1 METHODS
=head2 new
This initiates the package and take the following parameters:
=over 4
=item * C<debug>
Optional. If set with a positive integer, this will activate verbose debugging message
=back
=head2 format_datetime
Provided a L<DateTime> object, this returns a HTTP compliant string representation, such as:
Sun, 15 Dec 2019 15:32:12 GMT
that can be used in HTTP headers and cookies' expires property as per rfc6265.
=head2 parse_date
Given a datetime string, this returns, in list context, a list of day, month, year, hour, minute, second and time zone or an iso 8601 datetime string in scalar context.
This is used by the method L</str2datetime>
=head2 parse_datetime
Provided with a date string, and this will parse it and return a L<DateTime> object, or sets an L<error|Module::Generic/error> and return C<undef> or an empty list depending on the context.
=head2 str2datetime
Given a string that looks like a date, this will parse it and return a L<DateTime> object.
=head2 str2time
Given a string that looks like a date, this returns its representation as a unix timestamp in second since epoch.
In the background, it calls L</str2datetime> for parsing.
=head2 time2datetime
Given a unix timestamp in seconds since epoch, this returns a L<DateTime> object.
=head2 time2str
Given a unix timestamp in seconds since epoch, this returns a string representation of the timestamp suitable for HTTP headers and cookies. The format is like C<Sat, 14 Dec 2019 22:12:30 GMT>
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
L<DateTime>
=head1 COPYRIGHT & LICENSE
Copyright (c) 2023 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated
files under the same terms as Perl itself.
=cut
lib/Apache2/API/Headers/Accept.pm view on Meta::CPAN
L<Apache2::API::Headers::AcceptCommon/preferences> and sorted results are cached per object.
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
L<Apache2::API::Headers::AcceptCommon>, L<Apache2::API::Headers::AcceptLanguage>, RFC 7231, RFC 9110.
L<Apache2::API::DateTime>, L<Apache2::API::Query>, L<Apache2::API::Request>, L<Apache2::API::Request::Params>, L<Apache2::API::Request::Upload>, L<Apache2::API::Response>, L<Apache2::API::Status>
L<Apache2::Request>, L<Apache2::RequestRec>, L<Apache2::RequestUtil>
=head1 COPYRIGHT & LICENSE
Copyright (c) 2023 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated
files under the same terms as Perl itself.
lib/Apache2/API/Headers/AcceptCommon.pm view on Meta::CPAN
All state is per object; no shared mutable globals. Thus, this module is safe to use in threads.
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
L<Apache2::API::Headers::Accept>, L<Apache2::API::Headers::AcceptLanguage>, L<Module::Generic::HeaderValue>, RFC 7231, RFC 9110.
L<Apache2::API::DateTime>, L<Apache2::API::Query>, L<Apache2::API::Request>, L<Apache2::API::Request::Params>, L<Apache2::API::Request::Upload>, L<Apache2::API::Response>, L<Apache2::API::Status>
L<Apache2::Request>, L<Apache2::RequestRec>, L<Apache2::RequestUtil>
=head1 COPYRIGHT & LICENSE
Copyright (c) 2025 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated
files under the same terms as Perl itself.
lib/Apache2/API/Headers/AcceptLanguage.pm view on Meta::CPAN
Based on L<HTTP::AcceptLanguage> by Kazuhiro Osawa
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
L<Apache2::API::Headers::Accept>, L<Apache2::API::Headers::AcceptCommon>, L<Locale::Unicode>, RFC 5646 (BCP 47), RFC 7231, RFC 9110.
L<Apache2::API::DateTime>, L<Apache2::API::Query>, L<Apache2::API::Request>, L<Apache2::API::Request::Params>, L<Apache2::API::Request::Upload>, L<Apache2::API::Response>, L<Apache2::API::Status>
L<Apache2::Request>, L<Apache2::RequestRec>, L<Apache2::RequestUtil>
=head1 COPYRIGHT & LICENSE
Copyright (c) 2023 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated
files under the same terms as Perl itself.
lib/Apache2/API/Request.pm view on Meta::CPAN
use APR::Pool ();
use APR::Request ();
use APR::Socket ();
use APR::SockAddr ();
use APR::Request::Cookie;
use APR::Request::Apache2;
# For subnet_of() method
use APR::IpSubnet ();
use Apache2::API::Request::Params;
use Apache2::API::Request::Upload;
use Apache2::API::DateTime;
use Apache2::API::Query;
use Apache2::API::Status;
use Cookie::Jar;
use DateTime;
use Encode ();
use File::Which ();
use HTTP::AcceptLanguage;
use JSON ();
use Module::Generic::HeaderValue;
use Scalar::Util;
use URI;
use URI::Escape;
our $VERSION = 'v0.4.1';
our( $SERVER_VERSION, $ERROR );
lib/Apache2/API/Request.pm view on Meta::CPAN
code => Apache2::Const::HTTP_BAD_REQUEST,
message => "Error while decoding payload received from http client: $@"
}) );
}
# Cache the request body so other handlers can access it too.
$self->pnotes( REQUEST_BODY => $payload );
$self->pnotes( REQUEST_BODY_PROCESSED => 1 );
return( $payload );
}
sub datetime { return( Apache2::API::DateTime->new( debug => shift->debug ) ); }
sub decode
{
my $self = shift( @_ );
return( APR::Request::decode( shift( @_ ) ) );
}
sub discard_request_body { return( shift->_try( 'request', 'discard_request_body' ) ); }
# Do not track: 1 or 0
lib/Apache2/API/Request.pm view on Meta::CPAN
sub request { return( shift->_set_get_object_without_init( 'request', 'Apache2::Request', @_ ) ); }
sub request_scheme { return( shift->env( 'REQUEST_SCHEME', @_ ) ); }
# sub request_time { return( shift->request->request_time ); }
sub request_time
{
my $self = shift( @_ );
my $t = $self->request->request_time;
my $dt = DateTime->from_epoch( epoch => $t );
# An Apache2::API::DateTime object
my $fmt = $self->datetime;
$dt->set_formatter( $fmt );
return( $dt );
}
sub request_uri { return( shift->env( 'REQUEST_URI', @_ ) ); }
sub requires { return( shift->_try( 'request', 'requires' ) ); }
sub satisfies { return( shift->_try( 'request', 'satisfies' ) ); }
lib/Apache2/API/Request.pm view on Meta::CPAN
my $addr = $req->remote_addr;
my $host = $req->remote_host;
my $string = $req->remote_ip;
my $port = $req->remote_port;
$req->reply( Apache2::Const::FORBIDDEN => { message => "Get away" } );
# Apache2::RequestRec
my $r = $req->request;
my $scheme = $req->request_scheme;
# DateTime object
my $dt = $req->request_time;
my $uri = $req->request_uri;
my $filename = $req->script_filename;
my $name = $req->script_name;
my $uri = $req->script_uri;
# Apache2::ServerUtil object
my $server = $req->server;
my $addr = $req->server_addr;
my $admin = $req->server_admin;
my $hostname = $req->server_hostname;
lib/Apache2/API/Request.pm view on Meta::CPAN
# package inheriting from Apache2::API
PerlResponseHandler My::API
# 2Mb upload limit
PerlSetVar PAYLOAD_MAX_SIZE 2097152
</Directory>
This is just an example and not a recommandation. Your mileage may vary.
=head2 datetime
Returns a new L<Apache2::API::DateTime> object, which is used to parse and format dates for HTTP.
See L<Apache2::API/parse_datetime> and L<Apache2::API/format_datetime>
=head2 decode
Given a url-encoded string, this returns the decoded string, by calling L<APR::Request/decode>
This uses L<APR::Request> XS method.
See also L<rfc3986|https://datatracker.ietf.org/doc/html/rfc3986>
lib/Apache2/API/Request.pm view on Meta::CPAN
=head2 id
Returns the connection id; unique at any point in time, by calling L<Apache2::Connection/id>.
See L<Apache2::Connection> for more information.
This is the same as L</connection_id>
=head2 if_modified_since
Returns the value of the HTTP header If-Modified-Since as a C<DateTime> object.
If no such header exists, it returns C<undef> or an empty list depending on the context.
=head2 if_none_match
Sets or gets the value of the HTTP header C<If-None-Match>
See also L</headers>
=head2 input_filters
lib/Apache2/API/Request.pm view on Meta::CPAN
It can take as argument, only a key and it will then retrieve the corresponding value, or it can take a key and value pair to set them using L<Apache2::API::Request::Params/param>
If the value is an array, this will set multiple entry of the key for each value provided.
This uses Apache L<APR::Table> and works for both C<POST> and C<GET> methods.
If the methods received was a C<GET> method, this method returns the value of the L</query> method instead.
=head2 parse_date
Alias to L<Apache2::API::DateTime/parse_date>
=head2 path
Get the value for the environment variable C<PATH>
See also L</env>
=head2 path_info
my $path_info = $req->path_info();
lib/Apache2/API/Request.pm view on Meta::CPAN
Returns the embedded L<Apache2::RequestRec> object provided initially at object instantiation.
=head2 request_scheme
Gets or sets the environment variable C<REQUEST_SCHEME>
=head2 request_time
Read-only.
Returns the time when the request started as a L<DateTime> object with L<Apache2::API::DateTime> as the formatter.
=head2 request_uri
This returns the current value for the environment variable C<REQUEST_URI>, or set its value if an argument is provided.
The uri provided by this environment variable include the path info if any.
For example, assuming you have a cgi residing in C</cgi-bin/prog.cgi> and it is called with the path info C</some/value>, the value returned would then be C</cgi-bin/prog.cgi/some/value>
=head2 requires
lib/Apache2/API/Request.pm view on Meta::CPAN
This method is also handy when you extend the HTTP protocol and add new response codes. For example you could invent a new error code and tell Apache to use that in the response like so:
$req->status_line( "499 We have been FooBared" );
return( Apache2::Const::OK );
Here 499 is the new response code, and We have been FooBared is the custom response message.
=head2 str2datetime
Alias to L<Apache2::API::DateTime/str2datetime>
=head2 str2time
Alias to L<Apache2::API::DateTime/str2time>
=head2 subnet_of
Provided with an ip address (v4 or v6), and optionally a subnet mask, and this will return a boolean value indicating if the current connection ip address is part of the provided subnet.
The mask can be a string or a number of bits.
It uses L<APR::IpSubnet> and performs the test using the object from L<APR::SockAddr> as provided with L</remote_addr>
my $ok = $req->subnet_of( '127.0.0.1' );
lib/Apache2/API/Request.pm view on Meta::CPAN
my $request = $req->the_request();
my $old_request = $req->uri( $new_request );
Get or set the first HTTP request header as a string by calling L<Apache2::RequestRec/the_request>. For example:
GET /foo/bar/my_path_info?args=3 HTTP/1.0
=head2 time2datetime
Alias to L<Apache2::API::DateTime/time2datetime>
=head2 time2str
Alias to L<Apache2::API::DateTime/time2str>
=head2 type
Returns the content type of the request received. This value is set at object initiation phase.
So for example, if the HTTP request C<Content-type> is
Content-Type: application/json; charset=utf-8
Then, L</type> would return C<application/json>
t/00.load.t view on Meta::CPAN
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' );
use ok( 'Apache2::API::Request::Upload' );
use ok( 'Apache2::API::Response' );
use ok( 'Apache2::API::Status' );
};
t/02.datetime.t view on Meta::CPAN
BEGIN
{
use strict;
use warnings;
use lib './lib';
use open ':std' => ':utf8';
use vars qw( $DEBUG );
use Test2::V0;
# 2021-11-1T167:12:10+0900
use Test::Time time => 1635754330;
use ok( 'Apache2::API::DateTime' );
use ok( 'DateTime' ) || bail_out( "No DateTime module installed" );
our $DEBUG = exists( $ENV{AUTHOR_TESTING} ) ? $ENV{AUTHOR_TESTING} : 0;
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 );
is( $dt->stringify, 'Mon, 01 Nov 2021 08:12:10 GMT', 'format_datetime' );
my @tests = (
['Mon, 01 Nov 2021 08:12:10 GMT','2021-11-01T08:12:10','rfc822/rfc1123 format'],
['Monday, 01-Nov-21 08:12:10 GMT','2021-11-01T08:12:10','rfc1036'],
['Mon Nov 1 08:12:10 2021','2021-11-01T08:12:10','ANSI C asctime'],
['01 Nov 2021 08:12:10 GMT','2021-11-01T08:12:10','rfc7231'],
['2021-11-01T08:12:10','2021-11-01T08:12:10','iso8601'],
['2021-11-01 08:12:10','2021-11-01T08:12:10','iso8601'],
);
t/lib/Test/Apache2/API/Request.pm view on Meta::CPAN
);
} }) ); }
# NOTE: special processing
sub query_string { return( shift->_test({ method => 'query_string', expect => 'foo=bar&lang=ja-JP&q=%E6%9C%80%E9%AB%98%E3%81%A0%EF%BC%81' }) ); }
sub referer { return( shift->_test({ method => 'referer', expect => 'https://example.org/some/where.html' }) ); }
sub remote_addr { return( shift->_test({ method => 'remote_addr', expect => 'APR::SockAddr', type => 'isa' }) ); }
sub request_time { return( shift->_test({ method => 'request_time', expect => 'DateTime', type => 'isa' }) ); }
# requires
# satisfies
# script_filename
# script_name
# script_uri
# script_url
# Apache2::ServerUtil->server
sub server { return( shift->_test({ method => 'server', expect => 'Apache2::ServerRec', type => 'isa' }) ); }