The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Egg::Request - HTTP request processing for Egg.

SYNOPSIS

  # The request object is obtained.
  my $req= $e->request;
  
  # The query data is acquired.
  my $foo= $req->param('foo');
    or
  my $foo= $req->params->{foo};
  
  # Cookie is acquired.
  my $baa= $req->cookie('baa')->value;
    or
  my $baa= $req->cookie_value('baa');
  
  # The request passing is acquired.
  my $path= $req->path;
  
  # ...etc.

DESCRIPTION

This module offers processing and the function that relates to the HTTP request.

CONFIGURATION

max_snip_deep

Depth of directory that can be requested.

  # If it is 'max_snip_deep = 3', the following request becomes Forbidden.
  
  http://foo.tld/baa/zuu/hoge/bad_content

request

Option to set or to pass to main body for request.

  • DISABLE_UPLOADS

    The file upload is invalidated.

    * Please refer to 'Egg::Plugin::Upload' for the file upload.

  • TEMP_DIR

    Work folder for file upload chiefly

  • POST_MAX

    Maximum of standard input accepted when request method is POST.

METHODS

r

The object that actually does the request processing is returned.

For instance, if it is Apache::Request, and usual CGI if it is operating by mod_perl, the object of CGI is restored.

  $request-E<gt>r->param;

* The method that can be used depends on the module of the object because it is a direct call.

path

The request passing is returned.

* There is a thing different from 'PATH_INFO' of the environment variable because returned information is processed to process it with Egg.

is_get

When the request method is GET, ture is restored.

is_post

When the request method is POST, true is restored.

is_head

When the request method is HEAD, true is restored.

http_user_agent

Refer to 'HTTP_USER_AGENT' of the environment variable.

  • Alias: agent, user_agent

server_protocol

Refer to 'SERVER_PROTOCOL' of the environment variable.

  • Alias: protocol

remote_user

Refer to 'REMOTE_USER' of the environment variable.

  • Alias: user

script_name

Refer to 'SCRIPT_NAME' of the environment variable.

request_uri

Refer to 'REQUEST_URI' of the environment variable.

* A value different from the uri method might return.

path_info

Refer to 'PATH_INFO' of the environment variable.

http_referer

Refer to 'HTTP_REFERER' of the environment variable.

  • Alias: referer

http_accept_encoding

Refer to 'HTTP_ACCEPT_ENCODING' of the environment variable.

  • Alias: accept_encoding

remote_addr

Refer to 'REMOTE_ADDR' of the environment variable.

  • Alias: addr, address

Default is '127.0.0.1'.

request_method

Refer to 'REQUEST_METHOD' of the environment variable.

  • Alias: method

Default is 'GET'.

server_name

Refer to 'SERVER_NAME' of the environment variable.

Default is 'localhost'.

server_software

Refer to 'SERVER_SOFTWARE' of the environment variable.

Default is 'cmdline'.

server_port

Refer to 'SERVER_PORT' of the environment variable.

  • Alias: port

Default is '80'.

mp_version

The version of the mod_perl is returned if it operates by mod_perl.

new

Constructor. When the project is usually started, this is called. It is not necessary to call it specifying it.

snip ( [PARTS_NUMBER] )

The ARRAY reference for which $request->path is resolved by '/' delimitation is returned.

* The depth of passing that can be requested by 'max_snip_deep' of configuration can be setup. Default is undefined.

parameters

The request query is returned by the HASH reference.

  • Alias: params

  while (my($key, $value)= each %{$request->params}) {
    print "$key = $value \n";
  }

param ( [KEY], [VALUE] )

When the argument is omitted, the key list of the request query is returned with ARRAY.

When KEY is specified, the value of the corresponding request query is returned.

When both KEY and VALUE are given, the value is set.

  my $value= $request->param('param_name');
  
  $request->param( in_param => 'in_value' );

Cookie corresponding to KEY is returned.

Because it is an object that is returned that CGI::Cookie returns, it is necessary to use the value method to refer to the value in addition. see CGI::Cookie,

  my $cookie= $request->cookie('get_param');
  
  my $value = $cookie->value;

cookies

Fetch of "CGI::Cookie " is returned. * It is HASH reference that returns.

  my $cookies = $request->cookies;
  
  while (my($key, $cookie)= each %$cookies) {
        print "$key = ". $cookie->value ."\n";
  }

Caene of the value method of Cookie corresponding to KEY is returned. $request->cookie([KEY])->value is done in a word at a time.

  my $value= $request->cookie_value('cookie_name');

secure

True is returned concluding that the SSL communication is done when HTTPS of the environment variable is effective or 'SERVER_PORT' is 443.

scheme

If $request->secure is true, 'Https' is returned though 'Http' returns usually.

uri

The result of assembling URI based on $request->path is returned.

  • Alias: url

remote_host

If environment variable 'REMOTE_HOST' is obtained, the value is returned. If it is not good, gethostbyaddr is called and acquisition is tried. Finally, $request->remote_addr is returned.

host_name

As for the value that $request->host returns, the port number is sometimes included. This method returns the host name that doesn't contain the port number without fail.

host

'HTTP_HOST' of the environment variable or 'SERVER_NAME' is returned.

Default is 'localhost',

args

The value of 'QUERY_STRING' of the environment variable or 'REDIRECT_QUERY_STRING' is returned.

response

It is an accessor to the Egg::Response object.

SEE ALSO

CGI::Cookie, Egg::Request::CGI Egg::Request::FastCGI Egg::Response, Egg::Release,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT

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:

Around line 427:

L<> starts or ends with whitespace