Catalyst-Controller-WrapCGI

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

                pass_env /^MYAPP_/
                kill_env MYAPP_BAD
            </CGI>
        </Controller::Foo>

DESCRIPTION

    Allows you to run Perl code in a CGI environment derived from your
    Catalyst context.

    *WARNING*: do not export CGI functions into a Controller, it will break
    with Catalyst 5.8 onward.

    If you just want to run CGIs from files, see
    Catalyst::Controller::CGIBin.

    REMOTE_USER will be set to $c->user->obj->$username_field if available,
    or to $c->req->remote_user otherwise.

CONFIGURATION

 pass_env

    $your_controller->{CGI}{pass_env} should be an array of environment
    variables or regular expressions to pass through to your CGIs. Entries
    surrounded by / characters are considered regular expressions.

 kill_env

    $your_controller->{CGI}{kill_env} should be an array of environment
    variables or regular expressions to remove from the environment before
    passing it to your CGIs. Entries surrounded by / characters are
    considered regular expressions.

    Default is to pass the whole of %ENV, except for entries listed in
    "FILTERED ENVIRONMENT" below.

 username_field

    $your_controller->{CGI}{username_field} should be the field for your
    user's name, which will be read from $c->user->obj. Defaults to
    'username'.

    See "SYNOPSIS" for an example.

METHODS

 cgi_to_response

    $self->cgi_to_response($c, $coderef)

    Does the magic of running $coderef in a CGI environment, and populating
    the appropriate parts of your Catalyst context with the results.

    Calls "wrap_cgi".

 wrap_cgi

    $self->wrap_cgi($c, $coderef)

    Runs $coderef in a CGI environment using HTTP::Request::AsCGI, returns
    an HTTP::Response.

    The CGI environment is set up based on $c.

    The environment variables to pass on are taken from the configuration
    for your Controller, see "SYNOPSIS" for an example. If you don't supply
    a list of environment variables to pass, the whole of %ENV is used
    (with exceptions listed in "FILTERED ENVIRONMENT".

    Used by "cgi_to_response", which is probably what you want to use as
    well.

FILTERED ENVIRONMENT

    If you don't use the "pass_env" option to restrict which environment
    variables are passed in, the default is to pass the whole of %ENV
    except the variables listed below.

      MOD_PERL
      SERVER_SOFTWARE
      SERVER_NAME
      GATEWAY_INTERFACE
      SERVER_PROTOCOL
      SERVER_PORT
      REQUEST_METHOD
      PATH_INFO
      PATH_TRANSLATED
      SCRIPT_NAME
      QUERY_STRING
      REMOTE_HOST
      REMOTE_ADDR
      AUTH_TYPE
      REMOTE_USER
      REMOTE_IDENT
      CONTENT_TYPE
      CONTENT_LENGTH
      HTTP_ACCEPT
      HTTP_USER_AGENT

    %ENV can be further trimmed using "kill_env".

DIRECT SOCKET/NPH SCRIPTS

    This currently won't work:

        #!/usr/bin/perl
    
        use CGI ':standard';
    
        $| = 1;
    
        print header;
    
        for (0..1000) {
            print $_, br, "\n";
            sleep 1;
        }

    because the coderef is executed synchronously with STDOUT pointing to a
    temp file.



( run in 0.608 second using v1.01-cache-2.11-cpan-39bf76dae61 )