NetSDS::App::FCGI - FastCGI applications superclass
# Run application MyFCGI->run(); 1; # Application package itself package MyFCGI; use base 'NetSDS::App::FCGI'; sub process { my ($this) = @_; $this->data('Hello World'); $this->mime('text/plain'); $this->charset('utf-8'); }
NetSDS::App::FCGI module contains superclass for FastCGI applications. This class is based on NetSDS::App module and inherits all its functionality like logging, configuration processing, etc.
NetSDS::App::FCGI
NetSDS::App
Paramters: class parameters
Returns:
This method provides.....
my $https_header = $this->cgi->https('X-Some-Header');
Paramters: new status to set
Returns: response status value
$this->status('200 OK');
Paramters: new MIME type for response
$this->mime('text/xml'); # output will be XML data
$this->mime('text/plain'); $this->charset('koi8-r'); # ouput as KOI8-R text
Paramters: new data "as is"
$this->mime('text/plain'); $this->data('Hello world!');
Paramters: new URL (relative or absolute)
This method send reponse with 302 status and new location.
if (havent_data()) { $this->redirect('http://www.google.com'); # to google! };
Paramters:
Paramters: new headers as hash reference
$this->headers({ 'X-Beer' => 'Guiness', );
Paramters: none
This method implements common FastCGI (or CGI) loop.
Paramters: hash (name, value, expires)
$this->set_cookie(name => 'sessid', value => '343q5642653476', expires => '+1h');
Paramters: cookie name
Returns cookie value by it's name
my $sess = $this->get_cookie('sessid');
Paramters: CGI parameter name
Returns: CGI parameter value
This method returns CGI parameter value by it's name.
my $cost = $this->param('cost');
Paramters: URL parameter name
Returns: URL parameter value
This method works similar to param() method, but returns only parameters from the query string.
my $action = $this->url_param('a');
Paramters: request header name
Returns: header value
This method returns HTTP request header value by name.
my $beer = $this->http('X-Beer');
This method returns HTTPS request header value by name and is almost the same as http() method except of it works with SSL requests.
my $beer = $this->https('X-Beer');
Just proxying raw_cookie() method from CGI.pm
raw_cookie()
my $ua_info = $this->user_agent();
if ($this->request_method eq 'POST') { $this->log("info", "Something POST'ed from client"); }
Returns: script name from CGI.pm
if ($this->path_info eq '/help') { $this->data('Help yourself'); }
warn "Client from: " . $this->remote_host();
Returns: IP address of client from REMOTE_ADDR environment
if ($this->remote_addr eq '10.0.0.1') { $this->data('Welcome people from our gateway!'); }
Fetching cookies from HTTP request to object req_cookies variable.
req_cookies
See samples catalog for more example code.
samples
Unknown yet
CGI, CGI::Fast, NetSDS::App
None
Michael Bochkaryov <misha@rattler.kiev.ua>
To install NetSDS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm NetSDS
CPAN shell
perl -MCPAN -e shell install NetSDS
For more information on module installation, please visit the detailed CPAN module installation guide.