Apache2-API
view release on metacpan or search on metacpan
If none of the above is possible, the data will be returned
uncompressed.
Note that the HTTP header "Vary" will be added the "Accept-Encoding"
value.
push_handlers
Returns the values from "push_handlers" in Apache2::Server by passing it
whatever arguments were provided.
reply
This takes an HTTP code and a message, or an exception object such as
Module::Generic::Exception or any other object that supports the "code"
and "message" method, or just a hash reference, reply will find out if
the code provided is an error and format the replied json appropriately
like:
{ "error": { "code": 400, "message": "Some error" } }
It will json encode the returned data and print it out back to the
client after setting the HTTP returned code.
If a "cleanup" hash property is provided with a callback code reference
as a value, it will be set as a cleanup callback by calling
"$r->pool->cleanup_register". See
<https://perl.apache.org/docs/2.0/user/handlers/http.html#PerlCleanupHan
dler>
The Apache2::API object will be passed as the first and only argument to
the callback routine.
reply_sse
Special reply for Server-Sent Event that need to close the connection if
there was an error.
It takes the same arguments as "reply", call "reply", and if the return
code is an HTTP error, it will close the HTTP connection.
request()
Returns the Apache2::API::Request object. This object is set upon
instantiation.
response
Returns the Apache2::API::Response object. This object is set upon
instantiation.
server()
Returns a Apache2::Server object
server_version
Tries hard to find out the version number of the Apache server. This
returns the value from "server_version" in Apache2::API::Request
set_handlers()
Returns the values from "set_handlers" in Apache2::Server by passing it
whatever arguments were provided.
use_rfc_error
Boolean. When true, this will return rfc9457 style error
<https://www.rfc-editor.org/rfc/rfc9457.html>
warn( @list )
Given a list of string, this sends a warning using "warn" in
Apache2::Log
_try( $object_type, $method_name, @_ )
Given an object type, a method name and optional parameters, this
attempts to call it, passing it whatever arguments were provided and
return its return values.
Apache2 methods are designed to die upon error, whereas our model is
based on returning "undef" and setting an exception with
Module::Generic::Exception, because we believe that only the main
program should be in control of the flow and decide whether to interrupt
abruptly the execution, not some sub routines.
CLASS FUNCTIONS
apr1_md5
my $md5_password = apr1_md5( $clear_password );
my $md5_password = apr1_md5( $clear_password, $salt );
This class function is exported by default.
It takes a clear password, and optionally a salt, and returns an Apache
md5 encoded password.
This function merely instantiates a new Apache2::API::Password object,
and calls the method hash to return the encoded password.
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 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
st_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 a special case. So don't be surprised if you've
( run in 1.345 second using v1.01-cache-2.11-cpan-39bf76dae61 )