mod_perl logo
perl icon







previous page: Apache::RequestIO - Perl API for Apache request record IOpage up: mod_perl APIsnext page: Apache::RequestUtil - Perl API for Apache request record utils


Apache::RequestRec - Perl API for Apache request record accessors











Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

By Dave Rolsky, Ken Williams
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


Table of Contents

Synopsis

  use Apache::RequestRec ();
  sub handler{
      my $r = shift;
      ...
      my $auth_type = $r->auth_type;
      ...
      my $s = $r->server;
      my $dir_config = $r->dir_config;
  }

META: to be completed



TOP

Description

Apache::RequestRec provides the Perl API for Apache request object.



TOP

API

Apache::RequestRec provides the following functions and/or methods:



TOP

proxyreq

META: Autogenerated - needs to be reviewed/completed

  $ret = $r->proxyreq($val);


TOP

pool

META: Autogenerated - needs to be reviewed/completed

The pool associated with the request

  $p = $r->pool();


TOP

connection

META: Autogenerated - needs to be reviewed/completed

The connection record to the client

  $c = $r->connection();


TOP

server

Get the Apache::Server object for the server the request $r is running under.

  $s = $r->server();


TOP

next

META: Autogenerated - needs to be reviewed/completed

Pointer to the redirected request if this is an external redirect

  $next_r = $r->next();


TOP

prev

META: Autogenerated - needs to be reviewed/completed

Pointer to the previous request if this is an internal redirect

  $prev_r = $r->prev();


TOP

main

Get the main request record

  $main_r = $r->main();


TOP

the_request

META: Autogenerated - needs to be reviewed/completed

First line of request

  $request = $r->the_request();


TOP

assbackwards

META: Autogenerated - needs to be reviewed/completed

HTTP/0.9, "simple" request (e.g. GET /foo\n w/no headers)

  $status = $r->assbackwards($newval);


TOP

header_only

META: Autogenerated - needs to be reviewed/completed

HEAD request, as opposed to GET

  $status = $r->header_only();


TOP

protocol

META: Autogenerated - needs to be reviewed/completed

Protocol string, as given to us, or HTTP/0.9

  $protocol = $r->protocol();


TOP

proto_num

META: Autogenerated - needs to be reviewed/completed

Protocol version number of protocol; 1.1 = 1001

  $proto_num = $r->proto_num();


TOP

hostname

META: Autogenerated - needs to be reviewed/completed

Host, as set by full URI or Host:

  $hostname = $r->hostname();


TOP

request_time

META: Autogenerated - needs to be reviewed/completed

Time when the request started

  $request_time = $r->request_time();


TOP

status_line

META: Autogenerated - needs to be reviewed/completed

Status line, if set by script

  $status_line = $r->status_line();


TOP

status

META: Autogenerated - needs to be reviewed/completed

Get/set status line

  $status = $r->status($new_status);
  $status = $r->status();


TOP

method

META: Autogenerated - needs to be reviewed/completed

Request method (eg. GET, HEAD, POST, etc.)

  $method = $r->method();


TOP

method_number

META: Autogenerated - needs to be reviewed/completed

Apache::M_GET, Apache::M_POST, etc.

  $methno = $r->method_number();


TOP

allowed

META: Autogenerated - needs to be reviewed/completed

'allowed' is a bitvector of the allowed methods.

  $allowed = $r->allowed();

A handler must ensure that the request method is one that it is capable of handling. Generally modules should DECLINE any request methods they do not handle. Prior to aborting the handler like this the handler should set r->allowed to the list of methods that it is willing to handle. This bitvector is used to construct the "Allow:" header required for OPTIONS requests, and HTTP_METHOD_NOT_ALLOWED and HTTP_NOT_IMPLEMENTED status codes.

Since the default_handler deals with OPTIONS, all modules can usually decline to deal with OPTIONS. TRACE is always allowed, modules don't need to set it explicitly.

Since the default_handler will always handle a GET, a module which does *not* implement GET should probably return HTTP_METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET handler can't be installed by mod_actions.



TOP

allowed_xmethods

META: Autogenerated - needs to be reviewed/completed

Array of extension methods

  $array = $r->allowed_xmethods();


TOP

allowed_methods

META: Autogenerated - needs to be reviewed/completed

List of allowed methods

  $list = $r->allowed_methods();


TOP

bytes_sent

META: Autogenerated - needs to be reviewed/completed

body byte count, for easy access

  $bytes_sent = $r->bytes_sent();


TOP

mtime

META: Autogenerated - needs to be reviewed/completed

Last modified time of the requested resource

  $mtime = $r->mtime($new_mtime);
  $mtime = $r->mtime();


TOP

remaining

META: Autogenerated - needs to be reviewed/completed

Remaining bytes left to read from the request body

  $bytes = $r->remaining();

META: I think this method is not needed if the deprecated client_block methods aren't used, (and plain $r-<read() is used instead).



TOP

headers_in

META: Autogenerated - needs to be reviewed/completed

  $headers_in = $r->headers_in();


TOP

headers_out

META: Autogenerated - needs to be reviewed/completed

MIME header environment for the response

  $headers_out = $r->headers_out();


TOP

err_headers_out

META: Autogenerated - needs to be reviewed/completed

MIME header environment for the response, printed even on errors and persist across internal redirects

  $err_headers_out = $r->err_headers_out();

The difference between headers_out and err_headers_out is that the latter are printed even on error, and persist across internal redirects (so the headers printed for ErrorDocument handlers will have them).



TOP

notes

META: Autogenerated - needs to be reviewed/completed

Notes from one module to another

  $notes = $r->notes();
  $notes = $r->notes($new_notes);

The 'notes' is for notes from one module to another, with no other set purpose in mind...



TOP

handler

META: Autogenerated - needs to be reviewed/completed

  $handler = $r->handler();
  $handler = $r->handler($new_handler);


TOP

content_encoding

META: Autogenerated - needs to be reviewed/completed

  $ce = $r->content_encoding();


TOP

content_languages

META: Autogenerated - needs to be reviewed/completed

Array of strings representing the content languages

  $array_header = $r->content_languages();


TOP

user

META: Autogenerated - needs to be reviewed/completed

If an authentication check was made, this gets set to the user name.

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


TOP

ap_auth_type

If an authentication check was made, get or set the ap_auth_type slot in the request record

  $auth_type = $r->ap_auth_type();
  $r->ap_auth_type($newval);

ap_auth_type holds the authentication type that has been negotiated between the client and server during the actual request. Generally, ap_auth_type is populated automatically when you call $r->get_basic_auth_pw so you don't really need to worry too much about it, but if you want to roll your own authentication mechanism then you will have to populate ap_auth_type yourself.

Note that $r->ap_auth_type was $r->connection->auth_type in the mod_perl 1.0 API.



TOP

no_local_copy

META: Autogenerated - needs to be reviewed/completed

There is no local copy of this response

  $status = $r->no_local_copy();


TOP

unparsed_uri

META: Autogenerated - needs to be reviewed/completed

The URI without any parsing performed

  $unparsed_uri = $r->unparsed_uri();


TOP

uri

META: Autogenerated - needs to be reviewed/completed

The path portion of the URI

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


TOP

filename

META: Autogenerated - needs to be reviewed/completed

The filename on disk corresponding to this response

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


TOP

canonical_filename

META: Autogenerated - needs to be reviewed/completed

  $canon_filename = $r->canonical_filename();


TOP

path_info

META: Autogenerated - needs to be reviewed/completed

The PATH_INFO extracted from this request

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


TOP

args

META: Autogenerated - needs to be reviewed/completed

The QUERY_ARGS extracted from this request

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


TOP

used_path_info

META: Autogenerated - needs to be reviewed/completed

Flag for the handler to accept or reject path_info on the current request. All modules should respect the AP_REQ_ACCEPT_PATH_INFO and AP_REQ_REJECT_PATH_INFO values, while AP_REQ_DEFAULT_PATH_INFO indicates they may follow existing conventions. This is set to the user's preference upon HOOK_VERY_FIRST of the fixups.

  $ret = $r->used_path_info($newval);


TOP

per_dir_config

META: Autogenerated - needs to be reviewed/completed

These are config vectors, with one void* pointer for each module (the thing pointed to being the module's business). * Options set in config files, etc.

  $per_dir_config = $r->per_dir_config();


TOP

request_config

META: Autogenerated - needs to be reviewed/completed

Notes on *this* request

  $ret = $r->request_config($newval);


TOP

output_filters

META: Autogenerated - needs to be reviewed/completed

A list of output filters to be used for this request

  $output_filters = $r->output_filters();


TOP

input_filters

META: Autogenerated - needs to be reviewed/completed

A list of input filters to be used for this request

  $input_filters = $r->input_filters();


TOP

proto_output_filters

META: Autogenerated - needs to be reviewed/completed

A list of protocol level output filters to be used for this request

  $proto_output_filters = $r->proto_output_filters();


TOP

proto_input_filters

META: Autogenerated - needs to be reviewed/completed

A list of protocol level input filters to be used for this request

  $proto_input_filters = $r->proto_input_filters();


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::RequestIO - Perl API for Apache request record IOpage up: mod_perl APIsnext page: Apache::RequestUtil - Perl API for Apache request record utils