GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  NGINX::READBODY (3)

.ds Aq ’

TRANSLATIONS

English: Nginx::ReadBody

Russian: Nginx::ReadBody::Russian

CONTENTS

NAME

Nginx::ReadBody - nginx web server embeded perl module to read and evaluate a request body

Version 0.07

SYNOPSIS



  #nginx.conf (part of)
  location /post_here {
   error_page 345 = @get_there;
   error_page 346 = @good_post;
   error_page 347 = @bad_post;

   if ($request_method != POST)
    { return 345; }

   set $read_body_debug  1;
   set $read_body_check  My::Own::check_userdata;
   set $read_body_done   346;
   set $read_body_nodata 347;
   set $read_body_false  347;

   perl  Nginx::ReadBody::read;
   }



DESCRIPTION

nginx does not provide any methods to evaluate a request body. So this module does.

The Nginx::ReadBody methods

read($request); Intended to be a location handler.
handler($request, $variableName, $defaultValue, $debug) Handlers retriver and registrar. This method is intended to be used from other perl method acts as a location handler.

Method returns a reference to a subroutine defined by $variableName (or $defaultValue).

Value of $variableName is evaluated and the result is cached. See $variableName for details.

Parameters are:
$request nginx request object (see <http://wiki.nginx.org/NginxEmbeddedPerlModule>).
$variableName Name of the nginx.conf variable contains a handler definition.

Definition could be:
Digital code Evaluated to the reference to a subroutine just returning this code. Exactly like this:



    $handler = eval "sub { return $variableValue; }";



Name of the perl subroutine Like My::Own::method.

Evaluated to the reference to the named subroutine. Exactly like this:



    $handler = eval "\\&$variableValue";



Definition of the perl subroutine Like "sub {...}".

Evaluated to the reference to the defined subroutine. Exactly like this:



    $handler = eval $variableValue;



<B>I did not test this option at all!B> Could be dangerous with typos, etc.

In case $variableName value is not in any of these 3 forms or in case eval() failed reference to the subroutine always returning 500 is returned.

$defaultValue Definition should be used in case a variable provided is not set or set to empty string.
$debug Controlls a verbosity of the messages written to the error log. See $read_body_debug.

variable($request, $variableName, $defaultValue, $debug) Smart - ok, not complitely stupid - nginx.conf variable retriever. This method is intended to be used from other perl method acts as a location handler.

Parameters are:
$request nginx request object (see <http://wiki.nginx.org/NginxEmbeddedPerlModule>).
$variableName Name of the variable to retrieve.
$defaultValue Value should be used in case a variable requested is not set or set to empty string. Could be undef.

In case $defaultValue is not undef this variable will be set to this value for the rest of the whole request.

$debug Controlls a verbosity of the messages written to the error log. See $read_body_debug.

nginx.conf variables controlls the Nginx::ReadBody behaviour

$read_body_debug Controlls should debug messages be sent to error log or not.
Digit 0 or (empty string) <B>DefaultB>. No debug messages.
Digit 1 or nonEmptyString Full debug info.
0 but true or negative number Less verbose debug.
$read_body_nodata Should contain a handler definition (see handler).

Default is 400.

In case a request does not have a body this handler is called.

Handler is called with a nginx request object (see <http://wiki.nginx.org/NginxEmbeddedPerlModule>) as a single argument.

This handler should act as a location handler.

$read_body_check Should contain a handler definition (see handler).

Default is 0 but true so in case you did not define your own $read_body_check the request will be passed directly to $read_body_done.

As soon as body is fully received this handler is called to check the content.

Handler is called with a nginx request object (see <http://wiki.nginx.org/NginxEmbeddedPerlModule>) as a single argument.

Should return TRUE or FALSE.

$read_body_done Should contain a handler definition (see handler).

Default is 500 that should be a clear indication you did not define an action should be performed with the request we just received a body for.

As soon as $read_body_check returns TRUE this handler is called.

Handler is called with a nginx request object (see <http://wiki.nginx.org/NginxEmbeddedPerlModule>) as a single argument.

This handler should act as a location handler.

$read_body_false Should contain a handler definition (see handler).

Default is 400.

As soon as $read_body_check returns FALSE this handler is called.

Handler is called with a nginx request object (see <http://wiki.nginx.org/NginxEmbeddedPerlModule>) as a single argument.

This handler should act as a location handler.

    EXPORT

None.

SEE ALSO

<http://wiki.nginx.org/NginxEmbeddedPerlModule>.

AUTHOR

Daniel Podolsky, <tpaba@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Daniel Podolsky

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.4 or, at your option, any later version of Perl 5 you may have available.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 NGINX::READBODY (3) 2010-04-19

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.