=head1 NAME Net::FastCGI::Protocol - Provides functions to build and parse FastCGI messages. =head1 SYNOPSIS # FCGI_Header $octets = build_header($type, $request_id, $content_length, $padding_length); @values = parse_header($octets); # FCGI_BeginRequestBody $octets = build_begin_request_body($role, $flags); @values = parse_begin_request_body($octets); # FCGI_EndRequestBody $octets = build_end_request_body($application_status, $protocol_status); @values = parse_end_request_body($octets); # FCGI_UnknownTypeBody $octets = build_unknown_type_body($type); @values = parse_unknown_type_body($octets); # FCGI_BeginRequestRecord $octets = build_begin_request_record($request_id, $role, $flags); # FCGI_EndRequestRecord $octets = build_end_request_record($request_id, $application_status, $protocol_status); # FCGI_UnknownTypeRecord $octets = build_unknown_type_record($type); # FCGI_Record $octets = build_record($type, $request_id); $octets = build_record($type, $request_id, $content); # FCGI_NameValuePair's $octets = build_params($params); $params = parse_params($octets); # FCGI Byte Streams $octets = build_stream($type, $request_id, $octets); $octets = build_stream($type, $request_id, $octets, $terminate); =head1 DESCRIPTION Provides functions to build and parse FastCGI messages. =head1 FUNCTIONS =head2 build_begin_request_body Builds a C. I $octets = build_begin_request_body($role, $flags); I =over 4 =item C<$role> An unsigned 16-bit integer. =item C<$flags> An unsigned 8-bit integer. =back I =over 4 =item C<$octets> A string of octets containing the body. String is 8 octets in length. =back =head2 build_begin_request_record Builds a C. I $octets = build_begin_request_record($request_id, $role, $flags); I =over 4 =item C<$request_id> An unsigned 16-bit integer. =item C<$role> An unsigned 16-bit integer. =item C<$flags> An unsigned 8-bit integer. =back I =over 4 =item C<$octets> A string of octets containing the record. String is 16 octets in length. =back =head2 build_end_request_body Builds a C. I $octets = build_end_request_body($application_status, $protocol_status); I =over 4 =item C<$application_status> An unsigned 32-bit integer. =item C<$protocol_status> An unsigned 8-bit integer. =back I =over 4 =item C<$octets> A string of octets containing the body. String is 8 octets in length. =back =head2 build_end_request_record Builds a C. I $octets = build_end_request_record($request_id, $application_status, $protocol_status); I =over 4 =item C<$request_id> An unsigned 16-bit integer. =item C<$application_status> An unsigned 32-bit integer. =item C<$protocol_status> An unsigned 8-bit integer. =back I =over 4 =item C<$octets> A string of octets containing the record. String is 16 octets in length. =back =head2 build_header Builds a C. I $octets = build_header($type, $request_id, $content_length, $padding_length); I =over 4 =item C<$type> An unsigned 8-bit integer. =item C<$request_id> An unsigned 16-bit integer. =item C<$content_length> An unsigned 16-bit integer. =item C<$padding_length> An unsigned 8-bit integer. =back I =over 4 =item C<$octets> A string of octets containing the header. String is 8 octets in length. =back =head2 build_params Builds C's. I $octets = build_params($params); I =over 4 =item C<$params> A hash reference containing name/value pairs. =back I =over 4 =item C<$octets> =back =head2 build_record Builds a C. I $octets = build_record($type, $request_id); $octets = build_record($type, $request_id, $content); I =over 4 =item C<$type> An unsigned 8-bit integer. =item C<$request_id> An unsigned 16-bit integer. =item C<$content> (optional) A string of octets containing the content, must be less than or equal to 65535 octets in length. =back I =over 4 =item C<$octets> A string of octets containing the record. =back =head2 build_stream Builds a series of byte streams records. I $octets = build_stream($type, $request_id, $content); $octets = build_stream($type, $request_id, $content, $terminate); I =over 4 =item C<$type> An unsigned 8-bit integer. =item C<$request_id> An unsigned 16-bit integer. =item C<$content> A string of octets containing the stream content. =item C<$terminate> A boolean indicating whether or not the stream should be terminated. =back I =over 4 =item C<$octets> A string of octets containing the stream. =back =head2 build_unknown_type_body Builds a C. I $octets = build_unknown_type_body($type); I =over 4 =item C<$type> An unsigned 8-bit integer. =back I =over 4 =item C<$octets> A string of octets containing the body. String is 8 octets in length. =back =head2 build_unknown_type_record Builds a C. I $octets = build_unknown_type_record($type); I =over 4 =item C<$type> An unsigned 8-bit integer. =back I =over 4 =item C<$octets> A string of octets containing the record. String is 16 octets in length. =back =head2 parse_begin_request_body Parses a C. I ($role, $flags) = parse_begin_request_body($octets); I =over 4 =item C<$octets> A string of octets containing the body, must be greater than or equal to 8 octets in length. =back I =over 4 =item C<$role> An unsigned 16-bit integer. =item C<$flags> An unsigned 8-bit integer. =back =head2 parse_end_request_body Parses a C. I ($application_status, $protocol_status) = parse_end_request_body($octets); I =over 4 =item C<$octets> A string of octets containing the body, must be greater than or equal to 8 octets in length. =back I =over 4 =item C<$application_status> An unsigned 32-bit integer. =item C<$flags> An unsigned 8-bit integer. =back =head2 parse_header Parses a C. I ($type, $request_id, $content_length, $padding_length) = parse_header($octets); I =over 4 =item C<$octets> A string of octets containing the header, must be greater than or equal to 8 octets in length. =back I =over 4 =item C<$type> An unsigned 8-bit integer. =item C<$request_id> An unsigned 16-bit integer. =item C<$content_length> An unsigned 16-bit integer. =item C<$padding_length> An unsigned 8-bit integer. =back =head2 parse_params Parses C's. I $params = parse_params($octets); I =over 4 =item C<$octets> A string of octets containing C's. =back I =over 4 =item C<$params> A hash reference containing name/value pairs. =back =head2 parse_unknown_type_body Parses a C. I $type = parse_unknown_type_body($octets); I =over 4 =item C<$octets> C<$octets> must be greater than or equal to 8 octets in length. =back I =over 4 =item C<$type> An unsigned 8-bit integer. =back =head2 get_type_name I $name = get_type_name($type); I =over 4 =item C<$type> An unsigned 8-bit integer. =back I =over 4 =item C<$name> A string containing the name of the type. =back =head2 get_role_name I $name = get_role_name($type); I =over 4 =item C<$role> An unsigned 16-bit integer. =back I =over 4 =item C<$name> A string containing the name of the role. =back =head2 get_protocol_status_name I $name = get_protocol_status_name($protocol_status); I =over 4 =item C<$protocol_status> An unsigned 8-bit integer. =back I =over 4 =item C<$name> A string containing the name of the protocol status. =back =head2 is_known_type I $boolean = is_known_type($type); I =over 4 =item C<$type> An unsigned 8-bit integer. =back I =over 4 =item C<$boolean> A boolean indicating whether or not C<$type> is a known FastCGI v1 type. =back =head2 is_management_type I $boolean = is_management_type($type); I =over 4 =item C<$type> An unsigned 8-bit integer. =back I =over 4 =item C<$boolean> A boolean indicating whether or not C<$type> is a management type. =back =head2 is_discrete_type I $boolean = is_discrete_type($type); I =over 4 =item C<$type> An unsigned 8-bit integer. =back I =over 4 =item C<$boolean> A boolean indicating whether or not C<$type> is a discrete type. =back =head2 is_stream_type I $boolean = is_stream_type($type); I =over 4 =item C<$type> An unsigned 8-bit integer. =back I =over 4 =item C<$boolean> A boolean indicating whether or not C<$type> is a stream type. =back =head1 EXPORTS None by default. All functions can be exported using the C<:all> tag or individually. =head1 DIAGNOSTICS =over 4 =item B<(F)> Usage: %s =item B<(F)> Argument "%s" must be greater than or equal to %u octets in length =item B<(F)> Argument "%s" must be less than or equal to %u octets in length =item B<(F)> Unexpected end of octets while parsing FCGI_NameValuePair =item B<(F)> Unsupported FastCGI version: %u =back =head1 SEE ALSO =over 4 =item L =item L =back =head1 AUTHOR Christian Hansen C =head1 COPYRIGHT Copyright (c) 2008 Christian Hansen. All rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.