EV::CGI(3)

NAME
HTTP::Server::EV::CGI - Contains http request data and some extra functions.

GETTING DATA
    To get headers and CGI compatible ENV vars use

    $cgi->{ headers }{ header_name } = value

    To get last parsed from form value use

    $cgi->{ get }{ url_filed_name }

    $cgi->{ cookies }{ cookie_name }

    $cgi->{ post }{ form_filed_name }

    $cgi->{ file }{ form_file-filed_name } - HTTP::Server::EV::MultipartFile object

To get reference to array of all elements with same name ( selects, checkboxes, ...) use

$cgi->get('filed_name')
$cgi->post('filed_name')
$cgi->file('filed_name')
$cgi->param('filed_name');

Returns one or list of elements depending on call context. Prefers returning GET values if exists.

Never returns HTTP::Server::EV::MultipartFile files, use $cgi->{ file }{ filed_name } or $cgi->file('filed_name')

All values are utf8 encoded

NON BLOCKING OUTPUT
$cgi->{buffer} = HTTP::Server::EV::Buffer object

$cgi->buffer - returns non blocking filehandle tied to HTTP::Server::EV::Buffer object

$cgi->attach(*STDOUT) - attaches STDOUT to socket makes it non blocking

METHODS

  $cgi->next
Drops port listener callback processing. Don`t use it somewhere except HTTP::Server::EV port listener callback or set goto label NEXT_REQ:

  $cgi->fd
Returns file descriptor (int)

  $cgi->fh
Returns perl file handle attached to socket. Non buffered and blocking, use $cgi->{buffer}->print() or $cgi->buffer handle instead for sending data without attaching socket.

  $cgi->buffer
Returns handle tied to HTTP::Server::EV::Buffer object. Writing to this handle buffered and non-blocking

  $cgi->attach(*FH)
Attaches client socket to FH. Uses HTTP::Server::EV::BufTie to support processing requests in Coro threads when using Coro::EV Uses HTTP::Server::EV::Buffer to provide non-blocking output.

        $server->listen( 8080 , sub {
                my $cgi = shift;

                $cgi->attach(*STDOUT); # attach STDOUT to socket

                $cgi->header; # print http headers

                print "Test page";
        });

  $cgi->copy(*FH)
Attaches socket to handle but doesn't use HTTP::Server::EV::BufTie magick and buffered HTTP::Server::EV::Buffer otput.

  $cgi->print($data)
Buffered non-blocking print to socket. Same as $cgi->{buffer}->print or $cgi->buffer handle

  $cgi->flush and $cgi->flush_wait
Same as $cgi->{buffer}->flush and $cgi->{buffer}->flush_wait

  $cgi->close
Flush all buffered data and close received connection.

  $cgi->start_timer
Initialize a page generation timer. Called automatically on every request

  $cgi->flush_timer
Returns string like '0.12345678' with page generation time

  $cgi->set_cookies({ name=> 'value', name2=> 'value2' }, $sec_lifetime );
Takes hashref with cookies as first argumet. Second(optional) argument is cookies lifetime in seconds(1 month by default)

  $cgi->header( \%args );
Prints http headers and cookies buffer to socket

Args:

STATUS
    HTTP status string. '200 OK' by default

Server
    Server header. 'Perl HTTP::Server::EV' by default

Content-Type
    Content-Type header. 'text/html' by default

All other args will be converted to headers.

  $cgi->urldecode( $str );
Returns urldecoded utf8 string

NOT RECEIVED REQUEST METHODS
You should call these methods only after HTTP::Server::EV::PortListener on_multipart callback, when server receives POST data. You shouldn`t call them after request has been received.

  $cgi->stop;
Stop request processing

  $cgi->start;
Starts stopped request processing.

  $cgi->drop;
Drop user connection

POD ERRORS
Hey! The above document had some coding errors, which are explained below:

Around line 22:
    You can't have =items (as at line 26) unless the first thing after the =over is an =item