Net::FastCGI::IO(3pm)

πŸ“¦
version 0.14 Β· 2 versions
  • 0.14 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.14 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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_header reaches end-of-file before reading any octets, it returns a false value.
  • if it's unsuccessful, read_header returns a false value and $! contains the error from the sysread call.
  • if read_header hits end-of-file after some but not all of the needed octets, the function returns a false value and sets $! to EPIPE.

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_record reaches end-of-file before reading any octets, it returns a false value.
  • if unsuccessful, read_record returns a false value and $! contains the error from the sysread call.
  • if read_record encounters end-of-file after some but not all of the needed octets, the function returns a false value and sets $! to EPIPE.

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, undef and $! contains the error from the syswrite call.

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, undef and $! contains the error from the syswrite call.

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, undef and $! contains the error from the syswrite call.

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 or undef for 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 or undef for 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 πŸ‘€


🫢 AUTHOR 🫢

Christian Hansen chansen@cpan.org


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