Egg::Response - HTTP response processing for Egg.
# The response object is obtained. my $res= $e->response; # An original response header is set. $res->headers->header( 'X-ORIGN' => 'OK' ); # Set Cookie is setup. $res->cookie( new_cookie => 'set_value' ); or $res->cookies->{new_cookie}= 'set_value'; # Refer to set Cookie. print $res->cookies->{new_cookie}->value; # The cash control is setup. $res->no_cache(1); # Redirect it. $res->redirect('/redirect_uri'); # ...etc.
This module offers processing and the function that relates to the HTTP response.
The default of cookie can be setup.
cookie => { domain => 'mydomain', path => '/', expires => '+3M', secure => 0, },
domain
Domain that can be referred.
path
PATH that can be referred.
expires
Validity term.
secure
Secure flag.
Warning: Cookie cannot be referred to from the connection of usual http.
Constructor. When the project is usually started, this is called.
* It is not necessary to call it specifying it.
BEGIN
Accessor to $e->request.
The output contents are maintained by the SCALAR reference.
Egg::Response::Headers object is returned.
The HTTP response header is assembled and it returns it by the SCALAR reference.
When CONTENT_BODY is given, 'Content-Length' header is added.
Set Cookie is set.
If VALUE is a usual character string, it is considered the value value. The following details can be set by giving the HASH reference.
value ... value of cookie. path ... Reference PATH. - Default is '/'. domain ... Reference domain. expires ... Validity term. secure ... Secure flag. - It starts making it to true at the SSL connection. $response->cookie( 'cookie_name' => { value => 'cookie_value', path => '/active', domain => 'mydomain.name', expires => '+3H', secure => 1, });
The content of set Cookie is returned by the HASH reference.
The cash control is set.
When EXPIRES is given, $response->expires is set at the same time. If $response->expires is undefined, it defaults and '-1d' is set.
When LAST_MODIFIED is given, $response->last_modified is set at the same time. If $response->expires is undefined, it defaults and '-1d' is set.
0 Becomes invalid if it gives it. Moreover, please note that $response->last_modified and $response->is_expires also set 0 at the same time.
$response-E<gt>no_cache(1, '-3d', '-3d');
The download file name is set.
As 'Content-disposition: attachment; filename=[FILE_NAME]' result, a is added to the response header.
$response-E<gt>attachment('download.file');
Window taget is specified.
content_encoding is specified.
The status code is setup.
STATUS_CODE sets the figure of the treble that can surely be recognized with the HTTP response header.
When STATUS_STRING is omitted, acquisition is tried from %Egg::Response::Status.
$response-E<gt>status(400);
%Egg::Response::Status is as follows.
200 ... OK 301 ... Moved Permanently 302 ... Moved Temporarily 303 ... See Other 304 ... Not Modified 307 ... Temporarily Redirect 400 ... Bad Request 401 ... Unauthorized 403 ... Forbidden 404 ... Not Found 405 ... Method Not Allowed 500 ... Internal Server Error
The above-mentioned content is revokable from the controller etc.
%Egg::Response::Status= ( 200 => 'OK', 302 => 'Found', 403 => 'Forbidden', 404 => 'Not Found', 500 => 'Internal Error', );
STATUS_STRING set with $response->status is returned.
Half angle space is sure to be included in the head if it has defined it.
Redirecting is setup.
When STATUS is omitted, 302 is set.
The following options can be passed.
target => [TARGET_STRING]
template => [TEMPLATE_PATH]
When this option is given, $e->finished is not set.
And, it outputs it to the screen by processing the given template.
$response->redirect( '/redirect', '307 Temporarily Redirect', { target=> '_parent', template=> 'redirect.tt' } );
The content of $response->body is deleted.
The content of $response->cookies is initialized.
The main variable of the response object is initialized.
The result code corresponding to $response->status is returned.
* Because this method is called from Egg by the automatic operation, it is not necessary to call it specifying it.
The type of the output contents is setup.
As for default, 'content_type' of configuration or 'text/html' is used.
$response-E<gt>content_type('image/png');
* The character set is not set by the automatic operation for the text system. Please include it in a set value.
$response-E<gt>content_type('text/plain; charset=utf-8');
The language of contents is specified.
It defaults if 'content_language' of configuration is set and it is used.
$response-E<gt>content_language('ja');
The flag to assemble the response header of NPH scripting is hoisted.
* As for this method, debugging is not completed.
The Expires header is set.
$response-E<gt>is_expires('+7d');
The last-Modified header is set.
$response-E<gt>last_modified('+1H');
The object is returned.
* The object is HASH reference of the set header.
* The key is a name that lc is done for recognition.
* The content is ARRAY reference and [ "ORIGINAL NAME", "VALUE" ].
my $headers= $e->response->headers; $headers->{X_AnyName}= 'any header.';
Reference to content.
$headers->{X_AnyName}[1];
Refer to all data.
for my $head (values %headers) { print "$head->[0]: $head->[1]\r\n"; }
* The value is returned in order set by Tie::Hash::Indexed.
The value set in [HEAD_NAME] is returned.
When [VALUE] is given, the value is set.
* If [VALUE] is undef, the data that relates to the key is deleted.
$header->header( X_AnyName => 'any_header' );
ƒZƒbƒg�Ï‚Ý‚Ì’l‚ðƒf�[ƒ^‚ð�‰Šú‰»‚µ‚Ü‚·�B
$header->clear;
CGI::Cookie, Egg::Release,
Masatoshi Mizuno <lushe@cpan.org>
Copyright (C) 2007 by Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'ƒZƒbƒg�Ï‚Ý‚Ì’l‚ðƒf�[ƒ^‚ð�‰Šú‰»‚µ‚Ü‚·�B'. Assuming CP1252
To install Egg::Release, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Egg::Release
CPAN shell
perl -MCPAN -e shell install Egg::Release
For more information on module installation, please visit the detailed CPAN module installation guide.