This file is indexed.

/usr/share/perl5/HTML/Mason/PSGIHandler.pm is in libhtml-mason-psgihandler-perl 0.52-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package HTML::Mason::PSGIHandler;
BEGIN {
  $HTML::Mason::PSGIHandler::VERSION = '0.52';
}
use strict;
use 5.008_001;

use base qw( HTML::Mason::CGIHandler );
use CGI::PSGI;
use HTML::Mason::Exceptions;

sub new {
    my $class = shift;
    $class->SUPER::new(
        request_class => 'HTML::Mason::Request::PSGI',
        @_,
    );
}

sub handle_psgi {
    my $self = shift;
    my $env  = shift;

    my $p = {
        comp => $env->{PATH_INFO},
        cgi  => CGI::PSGI->new($env),
    };

    my $r = $self->create_delayed_object('cgi_request', cgi => $p->{cgi});
    $self->interp->set_global('$r', $r);

    my $output;
    $self->interp->out_method( \$output );
    $self->interp->delayed_object_params('request', cgi_request => $r);

    my @result = $self->invoke_mason($r, $p);
    die if $@;

    return [ $r->psgi_header(-Status => $result[0]), [ defined $output ? $output : () ] ];
}

sub invoke_mason {
    my ($self, $r, $p) = @_;
    my %args = $self->request_args($r);

    my @result;
    if (wantarray) {
        @result = eval { $self->interp->exec($p->{comp}, %args) };
    } elsif ( defined wantarray ) {
        $result[0] = eval { $self->interp->exec($p->{comp}, %args) };
    } else {
        eval { $self->interp->exec($p->{comp}, %args) };
    }

    return @result;
}

sub HTML::Mason::FakeApache::psgi_header {
    my $self = shift;
    my $h = $self->headers_out;
    my $e = $self->err_headers_out;

    my %args = (tied(%$h)->cgi_headers, tied(%$e)->cgi_headers, @_);
    if (exists $h->{Location}) {
        %args = (%args, -Status => 302);
    }

    return $self->query->psgi_header(%args);
}

package HTML::Mason::Request::PSGI;
BEGIN {
  $HTML::Mason::Request::PSGI::VERSION = '0.52';
}
use strict;
use base qw(HTML::Mason::Request::CGI);

use HTML::Mason::Exceptions;

sub exec {
    my $self = shift;
    my $r = $self->cgi_request;
    my $retval;

    eval { $retval = $self->HTML::Mason::Request::exec(@_) };

    if (my $err = $@) {
        $retval = isa_mason_exception($err, 'Abort')   ? $err->aborted_value
                : isa_mason_exception($err, 'Decline') ? $err->declined_value
                :                                        rethrow_exception $err;
    }

    return $retval;
}

package HTML::Mason::PSGIHandler;

1;
__END__

=encoding utf-8

=for stopwords

=head1 NAME

HTML::Mason::PSGIHandler - PSGI handler for HTML::Mason

=head1 SYNOPSIS

  # app.psgi
  use HTML::Mason::PSGIHandler;

  my $h = HTML::Mason::PSGIHandler->new(
      comp_root => "/path/to/doc_root", # required
  );

  my $handler = sub {
      my $env = shift;
      $h->handle_psgi($env);
  };

=head1 DESCRIPTION

HTML::Mason::PSGIHandler is a PSGI handler for HTML::Mason. It's based
on HTML::Mason::CGIHandler and allows you to process Mason templates on
any web servers that support PSGI.

=head1 SUPPORT

=over 4

=item * Git Repository

The latest code is available from the git repository at
L<http://github.com/abh/HTML-Mason-PSGIHandler>.

To send patches, make a fork on github and send a pull request.

=item * Bugs

Please report bugs at L<http://github.com/abh/HTML-Mason-PSGIHandler/issues>.

=back

=head1 AUTHORS

Ask Bjørn Hansen E<lt>miyagawa@bulknews.netE<gt>, Ricardo Signes E<lt>rjbs@cpan.orgE<gt>,
Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>.

=head1 LICENSE

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

=head1 SEE ALSO

L<CGI::PSGI> L<Plack> L<PSGI> L<HTML::Mason::CGIHandler>

=cut