NAME

Apache::RequestNotes - pass form and cookie data in pnotes

SYNOPSIS

httpd.conf:

PerlInitHandler Apache::RequestNotes
PerlSetVar MaxPostSize 1024
PerlSetVar DisableUploads On

MaxPostSize is in bytes and defaults to 1024, thus is optional.
DisableUploads defaults to On, and likewise is optional.

DESCRIPTION

Apache::RequestNotes provides a simple interface allowing all phases of the request cycle access to cookie or form input parameters in a consistent manner. Behind the scenes, it uses libapreq functions to parse request data and puts references to the data objects in pnotes.

EXAMPLE

httpd.conf:

PerlInitHandler Apache::RequestNotes

some Perl*Handler or Registry script:

my $input      = $r->pnotes('INPUT');   # Apache::Table reference
my $uploads    = $r->pnotes('UPLOADS'); # Apache::Upload array ref
my $cookies    = $r->pnotes('COOKIES'); # hash reference

# GET and POST data
my $foo        = $input->get('foo');

# uploaded files
foreach my $upload (@$uploads) {
  my $name     = $upload->name'
  my $fh       = $upload->fh;
  my $size     = $upload->size;
}

# cookie data
my $bar        = $cookies->{'bar'};      # one way

my %cookies    = %$cookies if $cookies;  # check, just to be safe
my $baz        = $cookies{'baz'};        # another way

After using Apache::RequestNotes: o $cookies contains a reference to a hash with the names and values of all cookies sent back to your domain and path.

o $input contains a reference to an Apache::Table object and can be
  accessed via Apache::Table methods - if a form contains both GET
  and POST data, both are available via $input.

o $uploads contains a reference to an array containing all the
  Apache::Upload objects for the request, which can be used to
  access uploaded file information.

Once the request is past the Init phase, all other phases can have access to the form input and cookie data without parsing it themselves. This relieves some strain, especially when the GET or POST data is required by numerous handlers along the way.

NOTES

Apache::RequestNotes can really be called from just about any request phase. Thus, if you need to postpone data parsing until after uri translation, using RequestNotes as a PerlFixupHandler should work just fine. Keep in mind that Apache::RequestNotes returns OK, which would preclude it's use in conjuction with other PerlTransHandlers and PerlTypeHandlers (but it doesn't belong there anyway).

MaxPostSize applies to file uploads as well as POST data, so if you plan on uploading files bigger than 1K, you will need to change the default.

$Apache::RequestNotes:err is set if libapreq reports a problem parsing the form data, thus it can be used to verify whether $input and $uploads contain valid objects. Apache::RequestNotes will _not_ return SERVER_ERROR in the event libapreq encounters an error. This may change in future releases.

Verbose debugging is enabled by setting the variable $Apache::RequestNotes::DEBUG=1 to or greater. To turn off all debug information, set your apache LogLevel above info level.

This is alpha software, and as such has not been tested on multiple platforms or environments. It requires PERL_INIT=1, PERL_LOG_API=1, and maybe other hooks to function properly. Doug MacEachern's libapreq is also required - you can get it from CPAN under the Apache tree.

FEATURES/BUGS

Since POST data cannot be read more than once per request, it is improper to both use this module and try to gather form data again via Apache::Request or CGI.pm from, say, a cgi script. I suppose this is a feature...

SEE ALSO

perl(1), mod_perl(1), Apache(3), Apache::Request(3), libapreq(1), Apache::Table(3)

AUTHOR

Geoffrey Young <geoff@cpan.org>

COPYRIGHT

Copyright 2000 Geoffrey Young - all rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.