The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

CGI::Header::PSGI - Role for generating PSGI response headers

SYNOPSIS

  use parent 'CGI';
  use Role::Tiny::With;

  with 'CGI::Header::PSGI';

  sub crlf { $CGI::CRLF }

  # psgi_header() and psgi_redirect() get imported

VERSION

This document refers to CGI::Header::PSGI 0.05.

DESCRIPTION

This module is a Role::Tiny role to generate PSGI response headers array reference.

This module doesn't case if your query class is orthogonal to a global variable %ENV. For example, CGI::PSGI adds the env() attribute to CGI.pm, and also overrides some methods which refer to %ENV directly. This module doesn't solve these problems at all.

REQUIRED METHODS

Your query class has to implement the following methods:

$query->charset

Returns the character set sent to the browser. Implemented by both of CGI and CGI::Simple.

$query->self_url

Returns the complete URL of your script. Implemented by both of CGI and CGI::Simple.

$query->cache

Implemented by both of CGI and CGI::Simple.

$query->no_cache (optional)

Implemented by CGI::Simple.

$query->nph

Implemented by both of CGI and CGI::Simple.

$query->server_software

Returns the server software and version number. Implemented by both of CGI and CGI::Simple.

$query->crlf

Returns the system specific line ending sequence. Implemented by both of CGI and CGI::Simple.

METHODS

By composing this role, your class is capable of following methods.

($status_code, $headers_aref) = $query->psgi_header( %args )

Works like CGI.pm's header(), but the return format is modified. It returns an array with the status code and arrayref of header pairs that PSGI requires.

Unlike header(), this method doesn't update charset().

($status_code, $headers_aref) = $query->psgi_redirect( %args )

Works like CGI.pm's redirect(), but the return format is modified. It returns an array with the status code and arrayref of header pairs that PSGI requires.

Unlike redirect(), this method doesn't update charset().

SEE ALSO

CGI::PSGI, CGI::Emulate::PSGI, CGI::Simple

AUTHOR

Ryo Anazawa (anazawa@cpan.org)

LICENSE

This module is free software; you can redistibute it and/or modify it under the same terms as Perl itself. See perlartistic.