Apache2-API

 view release on metacpan or  search on metacpan

lib/Apache2/API/Response.pm  view on Meta::CPAN


This sub request can be inspected to find information about the requested URI.

     $ret = $resp->lookup_uri( $new_uri );
     $ret = $resp->lookup_uri( $new_uri, $next_filter );
     $ret = $resp->lookup_uri( $new_uri, $next_filter, $handler );

See L<Apache2::SubRequest> for more information.

=head2 make_etag

Provided with a boolean value, this constructs an entity tag from the resource information, by calling L<Apache2::Response/make_etag>

If it is a real file, build in some of the file characteristics.

    $etag = $resp->make_etag( $force_weak );

It returns the etag as a string.

=head2 max_age

Sets or gets the HTTP header field C<Access-Control-Max-Age>

See L<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age>

=head2 meets_conditions

Implements condition C<GET> rules for HTTP/1.1 specification. This function inspects the client headers and determines if the response fulfills the specified requirements.

    $status = $resp->meets_conditions();

It returns L<Apache2::Const::OK> if the response fulfils the condition GET rules. Otherwise some other status code (which should be returned to Apache).

=head2 nel

Sets or gets the HTTP header field C<NEL>

See L<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/NEL>

=head2 no_cache

Add or remove cache control headers:

     $prev_no_cache = $resp->no_cache( $boolean );

A true value sets the C<no_cache> request record member to a true value and inserts:

     Pragma: no-cache
     Cache-control: no-cache

into the response headers, indicating that the data being returned is volatile and the client should not cache it.

A false value unsets the C<no_cache> request record member and the mentioned headers if they were previously set.

This method should be invoked before any response data has been sent out.

=head2 no_local_copy

    my $status = $resp->no_local_copy();

Used internally in certain sub-requests to prevent sending C<Apache2::Const::HTTP_NOT_MODIFIED> for a fragment or error documents.

Also affect L</meets_conditions>. If set to a true value, the conditions are always met.

It returns a status integer.

=head2 print

Provided with a list of data, and this sends it to the client, by calling L<Apache2::RequestIO/print>

    $cnt = $resp->print( @msg );

It returns how many bytes were sent (or buffered). If zero bytes were sent, C<print> will return C<0E0>, or C<zero but true>, which will still evaluate to 0 in a numerical context.

The data is flushed only if STDOUT stream's C<$|> is true. Otherwise it is buffered up to the size of the buffer, flushing only excessive data.

=head2 printf

Format and send data to the client (same as perl's C<printf>), by calling L<Apache2::RequestIO/printf>

    $cnt = $resp->printf( $format, @args );

It returns how many bytes were sent (or buffered).

The data is flushed only if STDOUT stream's C<$|> is true. Otherwise it is buffered up to the size of the buffer, flushing only excessive data.

=head2 puts

    $cnt = $req->puts( @msg );

Provided with values, this sends it to the client, by calling L<Apache2::RequestIO/puts>

It returns how many bytes were sent (or buffered).

=head2 redirect

Given an URI, this will prepare the HTTP headers and return the proper code for a C<301> temporary HTTP redirect.

It should be used like this in your code:

    return( $resp->redirect( "https://example.com/somewhere/" ) );

=head2 referrer_policy

Sets or gets the HTTP header field C<Referrer-Policy>

See L<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy>

=head2 request

Returns the L<Apache2::API::Request> object.

=head2 retry_after

Sets or gets the HTTP header field C<Retry-After>

See L<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After>

=head2 rflush

Flush any buffered data to the client, by calling L<Apache2::RequestIO/rflush>



( run in 0.947 second using v1.01-cache-2.11-cpan-b16cb0d3907 )