Net::FastCGI::IO(3pm)
π Net::FastCGI::IO π
okay bestie, so this is Net::FastCGI::IO from the User Contributed Perl Documentation β it's a Perl module and it hands you a whole lil toolbox of functions for reading and writing FastCGI messages. that's the whole vibe. no cap. π¦
β¨ SYNOPSIS β¨
# FCGI_Header
@values = read_header($fh);
$header = read_header($fh);
$result = write_header($fh, $type, $request_id, $content_length, $padding_length);
# FCGI_Record
@values = read_record($fh);
$record = read_record($fh);
$result = write_record($fh, $type, $request_id);
$result = write_record($fh, $type, $request_id, $content);
# FCGI_Record Stream
$result = write_stream($fh, $type, $request_id, $content);
$result = write_stream($fh, $type, $request_id, $content, $terminate);
# I/O ready
$result = can_read($fh, $timeout);
$result = can_write($fh, $timeout);
πΈ DESCRIPTION πΈ
so basically, this module gives you unbuffered blocking I/O functions to read and write FastCGI messages. that's it, that's the whole thing, and honestly? iconic. π
π FUNCTIONS π
π read_header
it's gonna attempt to read a FCGI_Header from the file handle $fh. slay.
Usage
($type, $request_id, $content_length, $padding_length)
= read_header($fh);
$header = read_header($fh);
say $header->{type};
say $header->{request_id};
say $header->{content_length};
say $header->{padding_length};
Arguments
$fhβ the file handle you're reading from. it must be a file handle with a file descriptor, and ngl the file handle mode should be set to binary. fr fr.
Returns
upon successful completion, you get the return value of parse_header in Net::FastCGI::Protocol. otherwise you get a false value (undef in scalar context and an empty list in list context). π
- if
read_headerreaches end-of-file before reading any octets, it returns a false value. - if it's unsuccessful,
read_headerreturns a false value and$!contains the error from thesysreadcall. - if
read_headerhits end-of-file after some but not all of the needed octets, the function returns a false value and sets$!toEPIPE.
Implementation
the implementation calls sysread in a loop, restarting if sysread returns undef with $! set to EINTR. if sysread doesn't provide all the requested octets, read_header keeps calling sysread until either all the octets have been read, it reaches end-of-file, or an error occurs. lowkey relentless. πͺ
π read_record
attempts to read a FCGI_Record from file handle $fh. bestie it's giving "record read."
Usage
($type, $request_id, $content)
= read_record($fh);
$record = read_record($fh);
say $record->{type};
say $record->{request_id};
Arguments
$fhβ the file handle to read from. must be a file handle with a file descriptor. file handle mode should be set to binary.
Returns
upon successful completion, the return value of parse_record in Net::FastCGI::Protocol. otherwise, a false value (undef in scalar context and an empty list in list context). π
- if
read_recordreaches end-of-file before reading any octets, it returns a false value. - if unsuccessful,
read_recordreturns a false value and$!contains the error from thesysreadcall. - if
read_recordencounters end-of-file after some but not all of the needed octets, the function returns a false value and sets$!toEPIPE.
Implementation
same energy as above: sysread in a loop, restarting if sysread returns undef with $! set to EINTR. if sysread doesn't provide all the requested octets, read_record continues to call sysread until either all the octets have been read, it reaches end-of-file, or an error occurs. β¨
π write_header
attempts to write a FCGI_Header to file handle $fh. yes queen, write it. βοΈ
Usage
$result = write_header($fh, $type, $request_id, $content_length, $padding_length);
Arguments
$fhβ the file handle to write to. must be a file handle with a file descriptor. file handle mode should be set to binary.$typeβ an unsigned 8-bit integer.$request_idβ an unsigned 16-bit integer.$content_lengthβ an unsigned 16-bit integer.$padding_lengthβ an unsigned 8-bit integer.
Returns
$resultβ upon successful completion, the number of octets actually written. otherwise,undefand$!contains the error from thesyswritecall.
Implementation
the implementation calls syswrite in a loop, restarting if syswrite returns undef with $! set to EINTR. if syswrite doesn't output all the requested octets, write_header continues to call syswrite until all the octets have been written or an error occurs. π₯
π write_record
attempts to write a FCGI_Record to file handle $fh.
Usage
$result = write_record($fh, $type, $request_id);
$result = write_record($fh, $type, $request_id, $content);
Arguments
$fhβ the file handle to write to. must be a file handle with a file descriptor. file handle mode should be set to binary.$typeβ an unsigned 8-bit integer.$request_idβ an unsigned 16-bit integer.$content(optional) β a string of octets containing the content, and it cannot exceed 65535 octets in length. that's a hard limit bestie, respect it. π«
Returns
$resultβ upon successful completion, the number of octets actually written. otherwise,undefand$!contains the error from thesyswritecall.
Implementation
syswrite in a loop, restarting if syswrite returns undef with $! set to EINTR. if syswrite doesn't output all the requested octets, write_record continues to call syswrite until all the octets have been written or an error occurs. β
π write_stream
attempts to write a FCGI_Record stream to file handle $fh. stream mode activated. π
Usage
$result = write_stream($fh, $type, $request_id, $content);
$result = write_stream($fh, $type, $request_id, $content, $terminate);
Arguments
$fhβ the file handle to write to. must be a file handle with a file descriptor. file handle mode should be set to binary.$typeβ an unsigned 8-bit integer.$request_idβ an unsigned 16-bit integer.$contentβ a string of octets containing the stream content.$terminate(optional) β a boolean indicating whether or not the stream should be terminated. defaults to false.
Returns
$resultβ upon successful completion, the number of octets actually written. otherwise,undefand$!contains the error from thesyswritecall.
Implementation
you already know: syswrite in a loop, restarting if syswrite returns undef with $! set to EINTR. if syswrite doesn't output all the requested octets, write_stream continues to call syswrite until all the octets have been written or an error occurs. π
π can_read
determines whether or not the given file handle $fh is ready for reading within the given timeout $timeout. vibe check on your file handle, essentially. π
Usage
$result = can_read($fh, $timeout);
Arguments
$fhβ the file handle to test for readiness. must be a file handle with a file descriptor.$timeoutβ maximum interval to wait. can be set to either a non-negative numeric value orundeffor infinite wait.
Returns
upon successful completion, 0 or 1. otherwise, undef and $! contains the select error.
Implementation
the implementation calls select in a loop, restarting if select returns -1 with $! set to EINTR and $timeout has not elapsed.
π can_write
determines whether or not the given file handle $fh is ready for writing within the given timeout $timeout. the sibling of can_read, equally iconic. π
Usage
$result = can_write($fh, $timeout);
Arguments
$fhβ the file handle to test for readiness. must be a file handle with a file descriptor.$timeoutβ maximum interval to wait. can be set to either a non-negative numeric value orundeffor infinite wait.
Returns
upon successful completion, 0 or 1. otherwise, undef and $! contains the select error.
Implementation
the implementation calls select in a loop, restarting if select returns -1 with $! set to EINTR and $timeout has not elapsed.
π EXPORTS π
none by default, sorry bestie. all functions can be exported using the :all tag or individually. your call, main character. π
π¨ DIAGNOSTICS π¨
- (F) Usage: %s β subroutine called with wrong number of arguments. bestie. count your args. π
- (W Net::FastCGI::IO) FastCGI: Could not read %s
- (W Net::FastCGI::IO) FastCGI: Could not write %s
π SEE ALSO π
- FastCGI Specification Version 1.0 β <http://www.fastcgi.com/devkit/doc/fcgi-spec.html>
- The Common Gateway Interface (CGI) Version 1.1 β <http://tools.ietf.org/html/rfc3875>
- Net::FastCGI::Constant
- Net::FastCGI::Protocol
π«Ά AUTHOR π«Ά
Christian Hansen chansen@cpan.org
π COPYRIGHT π
Copyright 2008-2010 by Christian Hansen.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay that's the whole page, we ate and left no crumbs πβ¨ this was perl v5.36.0, dated 2022-11-21, and the page is Net::FastCGI::IO(3pm) β mwah, bye bestie ππ§
π¦ where this page comes from
- debian bookworm: libnet-fastcgi-perl 0.14-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-fastcgi-perl 0.14-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-fastcgi-perl 0.14-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-fastcgi-perl 0.14-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-fastcgi-perl 0.14-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms