The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

PSA::Response::HTTP - a HTTP response object

SYNOPSIS

 my $response = PSA::Response::HTTP->new();

 # redirects
 $response->make_redirect("http://where/");

 # response built from templates, template toolkit in this case
 $response->set_template([Template => "filename", $vars ])

 # manually set the body of the document
 $response->set_data($document_body);

 # SENDFILE
 $response->set_file($filename);

 # set a cookie
 $response->set_cookie(new CGI::Cookie(...));

 # issue the response - select the filehandle you want to write to
 # first
 $response->issue();

 # allow response to contain "Template" templates
 $response->issue(Template => sub { $template->process(@_) });

DESCRIPTION

new

Creates a new PSA::Response::HTTP object

$response->set_static

Sets some headers that permit caching of the file

$response->cgiheader

returns a valid CGI header for this page

$response->make_redirect($uri)

Turns this response into a redirect

$response->trigger()

$response->issue(Toolkit => sub { ... })

Issues this HTTP response - if the response was made a template response (with set_template), then it calls the appropriate sub with the args as passed to set_template.

If the response is a file, as set by $response->set_file(), then that file is printed out.

set_file($value)

Not only does it set the value of $value, but has a guess at the mime type too.

set_data_magic($data)

Sets the response to the specified data format, then auto-guesses the file contents and sets the MIME type accordingly

set_header($name => $value)

Sets an HTTP header for this response, in either CGI.pm or HTTP form

is_null

Returns 1 if the response has no data, template or file.