The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME HTTP::Server::EV::CGI - Contains http request data and some extra functions. =head1 GETTING DATA =item $cgi->{headers}{header_name} = value

To get last parsed from form value use =item $cgi->{get}{url_filed_name} = url_filed_value =item $cgi->{cookies}{cookie_name} = cookie_value =item $cgi->{post}{form_filed_name} = form_filed_value =item $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') =item $cgi->post('filed_name') =item $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 =head1 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 =head2 $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 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. Sends cookies buffer to browser

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

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 22:

'=item' outside of any '=over'

Around line 107:

You forgot a '=back' before '=head2'