NAME

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

GETTING DATA

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

To get last parsed from form value use

$cgi->{get}{url_filed_name} = url_filed_value
$cgi->{post}{form_filed_name} = form_filed_value
$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

METHODS

$cgi->next;

Ends port listener callback processing. Don`t use it somewhere except HTTP::Server::EV port listener callback

$cgi->fd;

Returns file descriptor (int)

$cgi->fh;

Returns perl file handle

$cgi->attach(*FH);

Attaches client socket to FH. $server->listen( 8080 , sub { my $cgi = shift;

	$cgi->attach(local *STDOUT); # attach STDOUT to socket
	
	$cgi->header; # print http headers
	
	print "Test page"; 
});

$cgi->close;

Close received socket.

$cgi->start_timer

Initalize a page generation timer. Called automatically on every request

$cgi->flush_timer

Returns string like '0.12345' 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 urlecoded utf8 string