CGI-Tiny
view release on metacpan or search on metacpan
lib/CGI/Tiny.pod view on Meta::CPAN
=item file
L<File::Temp> object storing the file contents in a temporary file, which will
be cleaned up when the CGI script ends by default. The filehandle will be open
with the C<seek> pointer at the start of the file for reading.
=back
=head3 upload_names
my $arrayref = $cgi->upload_names;
Retrieve C<multipartE<sol>form-data> file upload names, decoded to Unicode
characters, as an ordered array reference, without duplication.
B<NOTE:> This will read the text form fields into memory as in L</"uploads">.
=head3 upload
my $upload = $cgi->upload('foo');
Retrieve a named C<multipartE<sol>form-data> file upload. If the upload name
was passed multiple times, returns the last value. Use L</"upload_array">
to get multiple uploads with the same name.
See L</"uploads"> for details on the representation of the upload.
B<NOTE:> This will read the text form fields into memory as in L</"uploads">.
=head3 upload_array
my $arrayref = $cgi->upload_array('foo');
Retrieve all C<multipartE<sol>form-data> file uploads of the specified name as
an ordered array reference.
See L</"uploads"> for details on the representation of the uploads.
B<NOTE:> This will read the text form fields into memory as in L</"uploads">.
=head2 Response
=head3 set_nph
$cgi = $cgi->set_nph;
$cgi = $cgi->set_nph(1);
If set to a true value or called without a value before rendering response
headers, CGI::Tiny will act as a
L<NPH (Non-Parsed Header)|https://tools.ietf.org/html/rfc3875#section-5> script
and render full HTTP response headers. This may be required for some CGI
servers, or enable unbuffered responses or HTTP extensions not supported by the
CGI server.
No effect after response headers have been rendered.
=head3 set_response_body_buffer
$cgi = $cgi->set_response_body_buffer(128*1024);
Sets the buffer size (number of bytes to read at once) for streaming a C<file>
or C<handle> response body with L</"render"> or L</"render_chunk">. Defaults to
the value of the C<CGI_TINY_RESPONSE_BODY_BUFFER> environment variable or
131072 (128 KiB). A value of 0 will use the default value.
=head3 set_response_status
$cgi = $cgi->set_response_status(404);
$cgi = $cgi->set_response_status('500 Internal Server Error');
Sets the response HTTP status code. A full status string including a
human-readable message will be used as-is. A bare status code must be a known
L<HTTP status code|https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml>
and will have the standard human-readable message appended.
No effect after response headers have been rendered.
The CGI protocol assumes a status of C<200 OK> if no response status is set.
=head3 set_response_disposition
$cgi = $cgi->set_response_disposition('attachment');
$cgi = $cgi->set_response_disposition(attachment => $filename);
$cgi = $cgi->set_response_disposition('inline'); # default behavior
$cgi = $cgi->set_response_disposition(inline => $filename);
Sets the response C<Content-Disposition> header to indicate how the client
should present the response, with an optional filename specified in Unicode
characters. C<attachment> suggests to download the content as a file, and
C<inline> suggests to display the content inline (the default behavior). No
effect after response headers have been rendered.
=head3 set_response_type
$cgi = $cgi->set_response_type('application/xml');
Sets the response C<Content-Type> header, to override autodetection in
L</"render"> or L</"render_chunk">. C<undef> will remove the override. No
effect after response headers have been rendered.
=head3 set_response_charset
$cgi = $cgi->set_response_charset('UTF-8');
Set charset to use when rendering C<text>, C<html>, or C<xml> response content,
defaults to C<UTF-8>.
=head3 add_response_header
$cgi = $cgi->add_response_header('Content-Language' => 'en');
Adds a custom response header. No effect after response headers have been
rendered.
B<NOTE:> Header names are case insensitive and CGI::Tiny does not attempt to
deduplicate or munge headers that have been added manually. Headers are printed
in the response in the same order added, and adding the same header multiple
times will result in multiple instances of that response header.
=head3 add_response_cookie
( run in 1.565 second using v1.01-cache-2.11-cpan-39bf76dae61 )