Catalyst-Controller-WrapCGI

 view release on metacpan or  search on metacpan

lib/Catalyst/Controller/WrapCGI.pm  view on Meta::CPAN

  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
/];

sub _filtered_env {
  my ($self, $env) = @_;
  my @ok;

  my $pass_env = $self->{CGI}{pass_env};
  $pass_env = []            if not defined $pass_env;
  $pass_env = [ $pass_env ] unless ref $pass_env;

  my $kill_env = $self->{CGI}{kill_env};
  $kill_env = $DEFAULT_KILL_ENV unless defined $kill_env;
  $kill_env = [ $kill_env ]  unless ref $kill_env;

  if (@$pass_env) {
    for (@$pass_env) {
      if (m!^/(.*)/\z!) {
        my $re = qr/$1/;
        push @ok, grep /$re/, keys %$env;
      } else {
        push @ok, $_;
      }
    }
  } else {
    @ok = keys %$env;
  }

  for my $k (@$kill_env) {
    if ($k =~ m!^/(.*)/\z!) {
      my $re = qr/$1/;
      @ok = grep { ! /$re/ } @ok;
    } else {
      @ok = grep { $_ ne $k } @ok;
    }
  }
  return { map {; $_ => $env->{$_} } @ok };
}

__PACKAGE__->meta->make_immutable;

=head1 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 C<STDOUT> pointing to a temp
file.

=head1 ACKNOWLEDGEMENTS

Original development sponsored by L<http://www.altinity.com/>

=head1 SEE ALSO

L<Catalyst::Controller::CGIBin>, L<CatalystX::GlobalContext>,
L<Catalyst::Controller>, L<CGI>, L<Catalyst>

=head1 BUGS

Please report any bugs or feature requests to C<bug-catalyst-controller-wrapcgi
at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Controller-WrapCGI>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.

=head1 AUTHOR

Matt S. Trout C<< <mst at shadowcat.co.uk> >>

=head1 CONTRIBUTORS

Caelum: Rafael Kitover <rkitover@cpan.org>

confound: Hans Dieter Pearcey <hdp@cpan.org>

rbuels: Robert Buels <rbuels@gmail.com>

Some code stolen from Tatsuhiko Miyagawa's L<CGI::Compile>.

=head1 COPYRIGHT & LICENSE

Copyright (c) 2008-2015 L<Catalyst::Controller::WrapCGI/AUTHOR> and
L<Catalyst::Controller::WrapCGI/CONTRIBUTORS>.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

__PACKAGE__; # End of Catalyst::Controller::WrapCGI

# vim: expandtab shiftwidth=2 ts=2 tw=80:



( run in 0.896 second using v1.01-cache-2.11-cpan-2398b32b56e )