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 an 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 don`t uses 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
Same as $cgi->{buffer}->flush and $cgi->{buffer}->flush_wait
Flush all buffered data and close received connection.
Initalize a page generation timer. Called automatically on every request
Returns string like '0.12345' with page generation time
Takes hashref with cookies as first argumet. Second(optional) argument is cookies lifetime in seconds(1 month by default)
Prints http headers and cookies buffer to socket
Args:
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.
Returns urldecoded utf8 string
You can 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 received.
Stop request processing
Starts stopped request processing.
Drop user connection
1 POD Error
The following errors were encountered while parsing the POD:
You can't have =items (as at line 26) unless the first thing after the =over is an =item
To install HTTP::Server::EV, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Server::EV
CPAN shell
perl -MCPAN -e shell install HTTP::Server::EV
For more information on module installation, please visit the detailed CPAN module installation guide.