This module must be used together with FCGI::EV. It will handle CGI requests received by FCGI::EV. Both blocking and non-blocking CGI request handling supported.

It will validate size of STDIN: do not accept size larger than configured in $MAX_STDIN (1 MB by default), do not accept incomplete STDIN (less than $ENV{CONTENT_LENGTH} bytes) - in both cases HTTP reply "417 Expectation Failed" will be returned to browser.

In non-blocking mode it optionally may call user callback function if web server disconnect before CGI sent it reply (to interrupt processing this request, if possible).

It compatible with CGI.pm (CGI.pm must be loaded before FCGI::EV::Std to activate this feature, and you'll need CGI::Stateless module), but may also work with other modules which parse CGI parameters - in this case these modules must support work in persistent environment and user probably has to re-initialize that module state between requests.

There no user-callable methods in this module. Instead, it will call user functions.

In default configuration it will work in blocking mode and will call main::main() on each incoming request, with prepared %ENV, STDIN and STDOUT, so user code may work just as usual CGI application. Other CGI requests will not be processed until main::main() returns. Data printed by main::main() to STDOUT will be sent to web server only after main::main() returns.

It also possible to configure FCGI::EV::Std to work in non-blocking mode. In this case on each incoming requests it will call main::main($server), where $server is FCGI::EV object. In this case main::main() shouldn't do any blocking operations (like using SQL database) but may setup any events (I/O, timer, etc.) using EV module and should returns quickly. Other CGI requests will be processed in parallel while this CGI request wait for events. After CGI will have some data to send, it should use $server->stdout($data, $is_eof) method (if $server is still defined - it may become undef if connection to web server related to this CGI request was already closed). In addition, FCGI::EV::Std may be configured to call any user function, say, main::hup($server) if connection to web server will be closed before CGI sent it reply. WARNING! User shouldn't keep non-weaken() references to $server in it code!

If true, then user function set in $FCGI::EV::Std::MAIN will be called in blocking mode and without any parameters.

If false, then user function set in $FCGI::EV::Std::MAIN will be called in non-blocking mode, with parameter $server. Also, if $FCGI::EV::Std::HUP set to user function, then it will be called if connection to web server is closed before CGI sent it reply.

User function called only in non-blocking mode to notify about closed connection and, if possible, interrupt current CGI request.

This function got one parameter - $server object. It's same $server as was given to $FCGI::EV::Std::MAIN function when this request was started (this is how user can identify which of currently executing requests was interrupted). The $server object will be destroyed shortly after that.

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.