mod_perl logo
perl icon







previous page: Apache::RequestRec - Perl API for Apache request record accessorspage up: mod_perl APIsnext page: Apache::Response - Perl API for Apache HTTP request response methods


Apache::RequestUtil - Perl API for Apache request record utils











Practical mod_perl

Practical mod_perl

By Stas Bekman, Eric Cholet
The mod_perl Developer's Cookbook

The mod_perl Developer's Cookbook

By Geoffrey Young, Paul Lindner, Randy Kobes
mod_perl Pocket Reference

mod_perl Pocket Reference

By Andrew Ford


Table of Contents

Synopsis

  use Apache::RequestUtil ();
  
  # directory level PerlOptions flags lookup
  $r->subprocess_env unless $r->is_perl_option_enabled('SetupEnv');

META: to be completed



TOP

Description

META: to be completed



TOP

Functions API



TOP

Apache->request()

  $request = Apache->request;


TOP

Methods API



TOP

default_type

META: Autogenerated - needs to be reviewed/completed

Retrieve the value of the DefaultType directive, or text/plain if not set

  $ret = $r->default_type();


TOP

document_root

META: Autogenerated - needs to be reviewed/completed

Retrieve the document root for this server

  $ret = $r->document_root();


TOP

get_limit_req_body

META: Autogenerated - needs to be reviewed/completed

Return the limit on bytes in request msg body

  $ret = $r->get_limit_req_body();


TOP

get_server_name

META: Autogenerated - needs to be reviewed/completed

Get the current server name from the request

  $ret = $r->get_server_name();


TOP

get_server_port

META: Autogenerated - needs to be reviewed/completed

Get the current server port

  $ret = $r->get_server_port();


TOP

is_initial_req

META: Autogenerated - needs to be reviewed/completed

Determine if the current request is the main request or a sub requests

  $ret = $r->is_initial_req();


TOP

add_config

META: Autogenerated - needs to be reviewed/completed

  $ret = $r->add_config($lines, $path, $override);


TOP

location

META: Autogenerated - needs to be reviewed/completed

  $location = $r->location($location);


TOP

location_merge

META: Autogenerated - needs to be reviewed/completed

  $ret = $r->location_merge($location);


TOP

pnotes

META: Autogenerated - needs to be reviewed/completed

Notes from one module to another

  $pnotes = $r->pnotes();
  $pnotes = $r->pnotes($new_pnotes);

Similar to (Apache::RequestRec), but values can be any perl variables. That also means that it can be used only between perl modules.



TOP

no_cache

META: Autogenerated - needs to be reviewed/completed

  $ret = $r->no_cache($flag);


TOP

as_string

META: Autogenerated - needs to be reviewed/completed

  $string = $r->as_string();


TOP

get_handlers

Returns a reference to a list of handlers enabled for a given phase.

  @handlers = $r->get_handlers($hook_name);

For example:

  @handlers = $r->get_handlers('PerlResponseHandler');


TOP

push_handlers

META: Autogenerated - needs to be reviewed/completed

Add one or more handlers to a list of handlers to be called for a given phase.

  $r->push_handlers($hook_name => \&handler);
  $r->push_handlers($hook_name => [\&handler, \&handler2]);

Examples:

  $r->push_handlers(PerlResponseHandler => \&handler);
  $r->push_handlers(PerlResponseHandler => [\&handler, \&handler2]);
  # XXX: not implemented yet
  $r->push_handlers(PerlResponseHandler => sub {...});


TOP

set_handlers

META: Autogenerated - needs to be reviewed/completed

Set a list of handlers to be called for a given phase.

  $r->set_handlers($hook_name => \&handler);
  $r->set_handlers($hook_name => [\&handler, \&handler2]);

Examples:

  $r->set_handlers(PerlResponseHandler => \&handler);
  $r->set_handlers(PerlResponseHandler => [\&handler, \&handler2]);
  # XXX: not implemented yet
  $r->set_handlers(PerlResponseHandler => sub {...});


TOP

set_basic_credentials

META: Autogenerated - needs to be reviewed/completed

  $r->set_basic_credentials($username, $password);


TOP

slurp_filename

META: Autogenerated - needs to be reviewed/completed

Return a reference to contents of $r->filename.

  $content = $r->slurp_filename($tainted);


TOP

is_perl_option_enabled

check whether a directory level PerlOptions flag is enabled or not.

  $result = $r->is_perl_option_enabled($flag);

For example to check whether the SetupEnv option is enabled for the current request (which can be disabled with PerlOptions -SetupEnv) and populate the environment variables table if disabled:

  $r->subprocess_env unless $r->is_perl_option_enabled('SetupEnv');

See also: PerlOptions and the equivalent function for server level PerlOptions flags.



TOP

dir_config

dir_config() provides an interface for the per-directory variable specified by the PerlSetVar and PerlAddVar directives, and also can be manipulated via the APR::Table methods.

  $table  = $r->dir_config();
  $value  = $r->dir_config($key);
  @values = $r->dir_config($key);
  $r->dir_config($key, $val);

The keys are case-insensitive.

  $apr_table = $r->dir_config();

dir_config() called in a scalar context without the $key argument returns a HASH reference blessed into the APR::Table class. This object can be manipulated via the APR::Table methods. For available methods see the APR::Table manpage.

  @values = $r->dir_config($key);

If the $key argument is passed in the list context a list of all matching values will be returned. This method is ineffective for big tables, as it does a linear search of the table. Thefore avoid using this way of calling dir_config() unless you know that there could be more than one value for the wanted key and all the values are wanted.

  $value = $r->dir_config($key);

If the $key argument is passed in the scalar context only a single value will be returned. Since the table preserves the insertion order, if there is more than one value for the same key, the oldest value assosiated with the desired key is returned. Calling in the scalar context is also much faster, as it'll stop searching the table as soon as the first match happens.

  $r->dir_config($key => $val);

If the $key and the $val arguments are used, the set() operation will happen: all existing values associated with the key $key (and the key itself) will be deleted and $value will be placed instead.

  $r->dir_config($key => undef);

If $val is undef the unset() operation will happen: all existing values associated with the key $key (and the key itself) will be deleted.



TOP

See Also

mod_perl 2.0 documentation.



TOP

Copyright

mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 1.1.



TOP

Authors

The mod_perl development team and numerous contributors.







TOP
previous page: Apache::RequestRec - Perl API for Apache request record accessorspage up: mod_perl APIsnext page: Apache::Response - Perl API for Apache HTTP request response methods