Ivan Ratnikov


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


    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


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


$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



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


Returns file descriptor (int)


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.


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


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"; 


Attaches socket to handle but doesn't use HTTP::Server::EV::BufTie magick and buffered HTTP::Server::EV::Buffer otput.


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


Flush all buffered data and close received connection.


Initialize a page generation timer. Called automatically on every request


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



HTTP status string. '200 OK' by default


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


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

All other args will be converted to headers.

$cgi->urldecode( $str );

Returns urldecoded utf8 string


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.


Stop request processing


Starts stopped request processing.


Drop user connection

1 POD Error

The following errors were encountered while parsing the POD:

Around line 22:

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