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

NAME

Egg::Request - WEB request processing for Egg.

SYNOPSIS

  # The object is acquired.
  my $req= $e->request;
    
  # The query data is acquired specifying the name.
  my $data= $req->param('query_name');
    
  # The mass of the query data is obtained. 
  my $params= $req->params;
    
  # Passing the requested place is obtained.
  my $path= $req->path
  
  # Cookie is acquired specifying the name.
  my $cookie= $req->cookie('cookie_name');
  
  # The mass of Cookie is acquired.
  my $cookies= $req->cookies;
  
  # The content of cookie is acquired. $cookie-E<gt>value is done at the same time.
  my $cookie_value= $req->cookie_value('cookie_name');

DESCRIPTION

The WEB request processing for the Egg framework is done.

If mod_perl can be used, it is composed by Egg::Request::Apache system class though this module is usually composed in the shape succeeded to to Egg::Request::CGI.

Please set environment variable [PROJECT_NAME]_REQUEST_CLASS when you use another request class. Please look at the source of 'bin/dispatch.fcgi' about the use example. After Egg::Request::FastCGI is set to the environment variable in the BEGIN block, it starts.

METHODS

The main body of this module is built into the component of the project.

request

The handler object of this module is returned.

  • Alias = req

HANDLER METHODS

new

Constructor. It is not necessary to call from the application.

  my $req= $e->request;

r

The object that is basic of the processing of this module is returned. In a word, the object of CGI.pm or Apache::Request is restored.

mp_version

The version of mod_perl is returned.

0 returns whenever it is not composed of the Egg::Apache system.

is_get

When the request method is GET, true is restored.

is_post

When the request method is POST, true is restored.

is_head

The request method returns and GET and POST return HEAD request and considering true when not is.

Please use 'request_method' or 'Method' when you want to check the request method in detail.

parameters

The mass of request query is returned by the HASH reference.

  $e->parameters->{'query_name'};
  • Alias = params

param ([KEY], [VALUE])

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

When KEY is given, the content of the corresponding request query is returned.

When VALUE is given, the request query is set.

  my @key_list= $req->param;
  
  my $hoge= $req->param('hoge');
  
  $req->param( hoge => 'boo' );

snip

It relays it to $e->snip. Please look at the document of Egg::Util.

cookies

The data received with cookie is returned. The object of CGI::Cookie is restored.

  while (my($key, $value)= each %{$req->cookies}) {
    $cookie{$key}= $value->value;
  }

The content of cookie specified with KEY is acquired.

It is necessary to use the value method further for obtaining data.

  my $gao= $req->cookie('gao')->value;

This method doesn't support the set of the value.

Cookie returned with the response header must be used and set must use the cookie method of Egg::Response.

Cookie specified with KEY is returned and the result of receipt value is returned.

  my $gao= $req->cookie_value('gao');

path

Passing information on the requested place is returned.

remote_user

The content of environment variable REMOTE_USER is returned.

  • Alias = user

script_name

The content of environment variable SCRIPT_NAME is returned.

request_uri

The content of environment variable REQUEST_URI is returned.

path_info

The content of environment variable PATH_INFO is returned.

http_referer

The content of environment variable HTTP_REFERER is returned.

  • Alias = referer

http_accept_encoding

The content of environment variable HTTP_ACCEPT_ENCODING is returned.

  • Alias = accept_encoding

remote_addr

The content of environment variable REMOTE_ADDR is returned.

Default is '127.0.0.1'.

  • Alias = addr

request_method

The content of environment variable REQUEST_METHOD is returned.

Default is GET.

  • Alias = method

server_name

The content of environment variable SERVER_NAME is returned.

Default is localhost.

server_software

The content of environment variable SERVER_SOFTWARE is returned.

Default is cmdline.

server_protocol

The content of environment variable SERVER_PROTOCOL is returned.

Default is 'HTTP/1.1'.

  • Alias = protocol

http_user_agent

The content of environment variable HTTP_USER_AGENT is returned.

Default is local.

  • Alias = agent, user_agent

server_port

The content of environment variable SERVER_PORT is returned.

Default is 80.

  • Alias = port

secure

True is returned if the request is due to SSL.

scheme

The URI scheme when requesting it is returned.

uri

It composes of information that receives requested URI again and it returns it.

  • Alias = url

remote_host

Host information on the requested client is returned. Remote_addr is returned when not obtaining it.

host

Host information on the WEB server under operation is returned.

host_name

When the port number is included in the content of host, the value in which it is excluded is returned.

output ([HEDER_SCALAR_REF], [BODY_SCALAR_REF])

The received content is output to STDOUT.

result

The response status is returned from Egg::Response as a receipt result code.

When the response status is undefined or 200, 0 is always returned.

SEE ALSO

Egg::Release Egg::Request::CGI, Egg::Request::FastCGI, Egg::Request::Apache, Egg::Base, ModPerl::VersionUtil, URI

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

Copyright (C) 2008 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.