NetSDS...p::FCGI(3pm)
π NetSDS...p::FCGI(3pm) π
okay bestie, sit down, hydrate, because we're talking about NetSDS::App::FCGI β the FastCGI superclass that runs the whole show. This is the manual page (the perl v5.32.1 one, filed under NetSDS...p::FCGI(3pm)), and I'm gonna walk you through every single thing in it. no skips. no cap. π«Ά
β¨ NAME β¨
NetSDS::App::FCGI β the FastCGI applications superclass. she's the mom of your app, literally. π
π SYNOPSIS π
here's the vibe, first you run it:
# Run application
MyFCGI->run();
1;
and then the app package itself, looking all cute and self-assured:
# Application package itself
package MyFCGI;
use base 'NetSDS::App::FCGI';
sub process {
my ($self) = @_;
$self->data('Hello World');
$self->mime('text/plain');
$self->charset('utf-8');
}
see how process is where you live? that's your main character moment. set the data, set the MIME, set the charset, done. slay. π
π¦ DESCRIPTION π¦
so "NetSDS::App::FCGI" is the module that holds the superclass for FastCGI applications. it's built on top of the "NetSDS::App" module and inherits all of its functionality β logging, configuration processing, etc. all of it. she got it from her mama. π
πΈ CLASS API πΈ
new(%params) β class constructor π
ngl, normally you should not invoke the application framework's constructor directly. hands off, bestie, let the framework do her thing.
cgi() β accessor to CGI.pm request handler β¨
my $https_header = $self->cgi->https('X-Some-Header');
status([$new_status]) β set response HTTP status π
- Paramters: new status to set
- Returns: response status value
$self->status('200 OK');
mime() β set response MIME type π
- Paramters: new MIME type for response
$self->mime('text/xml'); # output will be XML data
charset() β set response character set if necessary πΈ
$self->mime('text/plain');
$self->charset('koi8-r'); # ouput as KOI8-R text
data($new_data) β set response data π
- Paramters: new data "as is"
$self->mime('text/plain');
$self->data('Hello world!');
redirect($redirect_url) β send HTTP redirect π₯
- Paramters: new URL (relative or absolute)
this method send reponse with 302 status and new location.
if (havent_data()) {
$self->redirect('http://www.google.com'); # to google!
};
cookie() β π
- Paramters:
- Returns:
This method provides.....
(no for real, that's the whole entry. she's mysterious. lowkey iconic.)
headers($headers_hashref) β set/get response HTTP headers π
- Paramters: new headers as hash reference
$self->headers({
'X-Beer' => 'Guiness',
);
main_loop() β main FastCGI loop π
- Paramters: none
This method implements common FastCGI (or CGI) loop.
set_cookie(%params) β set cookie πͺ
- Paramters: hash (name, value, expires)
$self->set_cookie(name => 'sessid', value => '343q5642653476', expires => '+1h');
get_cookie(%params) β get cookie by name πͺ
- Paramters: cookie name
- Returns: cookie value by it's name
my $sess = $self->get_cookie('sessid');
param($name) β CGI request parameter π
- Paramters: CGI parameter name
- Returns: CGI parameter value
This method returns CGI parameter value by it's name.
my $cost = $self->param('cost');
url_param($name) β CGI request parameter π
- 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 = $self->url_param('a');
http($http_field) β request HTTP header π
- Paramters: request header name
- Returns: header value
This method returns HTTP request header value by name.
my $beer = $self->http('X-Beer');
https($https_field) β request HTTPS header π
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 = $self->https('X-Beer');
raw_cookie() β get raw cookie data πͺ
Just proxying "raw_cookie()" method from CGI.pm
user_agent() β User-Agent request header π¦
my $ua_info = $self->user_agent();
request_method() β HTTP request method β
if ($self->request_method eq 'POST') {
$self->log("info", "Something POST'ed from client");
}
script_name() β CGI script name π
- Returns: script name from CGI.pm
path_info() β get PATH_INFO value π
if ($self->path_info eq '/help') {
$self->data('Help yourself');
}
remote_host() β remote (client) host name π
warn "Client from: " . $self->remote_host();
remote_addr() β remote (client) IP address π
- Returns: IP address of client from REMOTE_ADDR environment
if ($self->remote_addr eq '10.0.0.1') {
$self->data('Welcome people from our gateway!');
}
_set_req_cookies() β fetching request cookies (internal method) π
Fetching cookies from HTTP request to object "req_cookies" variable. internal means internal, bestie β don't come for her.
π EXAMPLES π
See "samples" catalog for more example code. go look, there's lore in there.
π SEE ALSO π
CGI, CGI::Fast, NetSDS::App β the whole friend group. π«Ά
βοΈ AUTHOR βοΈ
Michael Bochkaryov <misha@rattler.kiev.ua> β thank you for your service, king. π
π LICENSE π
Copyright (C) 2008-2009 Net Style Ltd.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
fr fr, that "WITHOUT ANY WARRANTY" part is doing a lot of heavy lifting. read it. it means what it says. π
okay that's the whole page, every flag, every method, every param, every example, untouched and unbothered. π
perl v5.32.1 β 2021-12-26 β NetSDS...p::FCGI(3pm)
bye bestie, go write a process sub and eat something πβ¨π
π¦ where this page comes from
- debian bookworm: libnetsds-perl 1.301-4 Β· GPL-2.0-or-later
- debian trixie: libnetsds-perl 1.301-4 Β· GPL-2.0-or-later
- ubuntu jammy: libnetsds-perl 1.301-4 Β· GPL-2.0-or-later
- ubuntu noble: libnetsds-perl 1.301-4 Β· GPL-2.0-or-later
- ubuntu resolute: libnetsds-perl 1.301-4 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms