Apache2-API
view release on metacpan or search on metacpan
lib/Apache2/API/Request.pm view on Meta::CPAN
} while (!$seen_eos);
$bb->destroy;
return $data;
}
As you can see C<< $req->input_filters >> gives us a pointer to the last of the top of the incoming filters stack.
=head2 is_aborted
This is a more subtle implementation of Apache L<aborted method|Apache2::Connection/aborted> and is described in L<its documentation|https://perl.apache.org/docs/1.0/guide/debug.html#toc_Detecting_Aborted_Connections>.
It attempts to print a null-byte to the connection, L<flush|Apache2::RequestIO/rflush> the Apache buffer and then checks if the connection was L<aborted|Apache2::Connection>.
The reason L<as explained in Apache documentation|https://perl.apache.org/docs/1.0/guide/debug.html#toc_Detecting_Aborted_Connections> is that Apache does not detect if the user dropped the connection until it attempts to read from or write back to i...
It returns true if the connection was aborted, and false otherwise.
=head2 is_auth_required
my $need_auth = $r->is_auth_required;
Check if any authentication is required for the current request, by calling L<Apache2::Access/some_auth_required>
It returns a boolean value.
See also L</has_auth>, which is an alias of this method.
=head2 is_header_only
Returns a boolean value on whether the request is a C<HEAD> request or not, by calling L<Apache2::RequestRec/header_only>
So, it returns true if the client is asking for headers only, false otherwise.
=head2 is_perl_option_enabled
Sets or gets whether a directory level C<PerlOptions> flag is enabled or not. This returns a boolean value, by calling L<Apache2::RequestUtil/is_perl_option_enabled>
For example to check whether the C<SetupEnv> option is enabled for the current request (which can be disabled with C<PerlOptions -SetupEnv>) and populate the environment variables table if disabled:
$req->subprocess_env unless $req->is_perl_option_enabled('SetupEnv');
See also: PerlOptions and the equivalent function for server level PerlOptions flags.
See the L<Apache2::RequestUtil> module documentation for more information.
=head2 is_initial_req
# Are we in the main request?
$is_initial = $req->is_initial_req;
Determines whether the current request is the main request or a sub-request.
This returns a boolean value.
See also L<main|/main>, which returns the main request object.
=head2 is_secure
Returns true (1) if the connection is made under ssl, i.e. of the environment variable C<HTTPS> is set to C<on>, other it returns false (0).
This is done by checking if the environment variable C<HTTPS> is set to C<on> or not.
=head2 json
Returns a L<JSON> object with the C<relaxed> attribute enabled so that it allows more relaxed C<JSON> data.
You can provide an optional hash or hash reference of properties to enable or disable:
my $J = $api->json( pretty => 1, relaxed => 1 );
Each property corresponds to one that is supported by L<JSON>
It also supports C<ordered>, C<order> and C<sort> as an alias to C<canonical>
=head2 keepalive
$status = $c->keepalive();
$status = $c->keepalive($new_status);
This method answers the question: Should the the connection be kept alive for another HTTP request after the current request is completed?
This sets or gets the status by calling L<Apache2::Connection/keepalive>
use Apache2::Const -compile => qw(:conn_keepalive);
# ...
my $c = $req->connection;
if ($c->keepalive == Apache2::Const::CONN_KEEPALIVE) {
# do something
}
elsif ($c->keepalive == Apache2::Const::CONN_CLOSE) {
# do something else
}
elsif ($c->keepalive == Apache2::Const::CONN_UNKNOWN) {
# do yet something else
}
else {
# die "unknown state";
}
Notice that new states could be added later by Apache, so your code should make no assumptions and do things only if the desired state matches.
The method does not return true or false, but one of the states which can be compared against Apache constants (C<:conn_keepalive constants>).
See L<Apache2::Connection> for more information.
=head2 keepalives
my $served = $req->connection->keepalives();
my $served = $req->connection->keepalives( $new_served );
This returns an integer representing how many requests were already served over the current connection.
This method calls L<Apache2::Connection/keepalives>
This method is only relevant for keepalive connections. The core connection output filter C<ap_http_header_filter> increments this value when the response headers are sent and it decides that the connection should not be closed (see "ap_set_keepalive...
If you send your own set of HTTP headers with C<< $req->assbackwards >>, which includes the C<Keep-Alive> HTTP response header, you must make sure to increment the C<keepalives> counter.
See L<Apache2::Connection> for more information.
( run in 0.362 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )