| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Engine::Zeus::Base; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
16
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw[Catalyst::Engine]; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
833
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1428464
|
use Zeus::ModPerl (); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Zeus::ModPerl::Constants (); |
|
8
|
|
|
|
|
|
|
use Zeus::ModPerl::File (); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Zeus::ModPerl::Constants->import(':common'); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use URI; |
|
13
|
|
|
|
|
|
|
use URI::http; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/zeus/); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Catalyst::Engine::Zeus::Base - Base class for Zeus Engine |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
See L<Catalyst>. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This class overloads some methods from C<Catalyst::Engine>. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=over 4 |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item $c->zeus |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Returns an C<Zeus::ModPerl> object. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=back |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 OVERLOADED METHODS |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
This class overloads some methods from C<Catalyst::Engine>. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over 4 |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item $c->finalize_body |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub finalize_body { |
|
50
|
|
|
|
|
|
|
my $c = shift; |
|
51
|
|
|
|
|
|
|
$c->zeus->print( $c->response->body ); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item $c->finalize_headers |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub finalize_headers { |
|
59
|
|
|
|
|
|
|
my $c = shift; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
for my $name ( $c->response->headers->header_field_names ) { |
|
62
|
|
|
|
|
|
|
next if $name =~ /^Content-(Length|Type)$/i; |
|
63
|
|
|
|
|
|
|
my @values = $c->response->header($name); |
|
64
|
|
|
|
|
|
|
$c->zeus->headers_out->add( $name => $_ ) for @values; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
if ( $c->response->header('Set-Cookie') && $c->response->status >= 300 ) { |
|
68
|
|
|
|
|
|
|
my @values = $c->response->header('Set-Cookie'); |
|
69
|
|
|
|
|
|
|
$c->zeus->err_headers_out->add( 'Set-Cookie' => $_ ) for @values; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$c->zeus->status( $c->response->status ); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
if ( my $type = $c->response->header('Content-Type') ) { |
|
75
|
|
|
|
|
|
|
$c->zeus->content_type($type); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
if ( my $length = $c->response->content_length ) { |
|
79
|
|
|
|
|
|
|
$c->zeus->set_content_length($length); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$c->zeus->send_http_header; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
return 0; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item $c->handler |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub handler ($$) { |
|
92
|
|
|
|
|
|
|
shift->SUPER::handler(@_); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item $c->prepare_body |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub prepare_body { |
|
100
|
|
|
|
|
|
|
my $c = shift; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $body = undef; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
while ( read( STDIN, my $buffer, 8192 ) ) { |
|
105
|
|
|
|
|
|
|
$body .= $buffer; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$c->request->body($body); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item $c->prepare_connection |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub prepare_connection { |
|
116
|
|
|
|
|
|
|
my $c = shift; |
|
117
|
|
|
|
|
|
|
$c->request->address( $c->zeus->connection->remote_ip ); |
|
118
|
|
|
|
|
|
|
$c->request->hostname( $c->zeus->connection->remote_host ); |
|
119
|
|
|
|
|
|
|
$c->request->protocol( $c->zeus->protocol ); |
|
120
|
|
|
|
|
|
|
$c->request->user( $c->zeus->user ); |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
if ( $ENV{HTTPS} || $c->zeus->get_server_port == 443 ) { |
|
123
|
|
|
|
|
|
|
$c->request->secure(1); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item $c->prepare_headers |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub prepare_headers { |
|
132
|
|
|
|
|
|
|
my $c = shift; |
|
133
|
|
|
|
|
|
|
$c->request->method( $c->zeus->method ); |
|
134
|
|
|
|
|
|
|
$c->request->header( %{ $c->zeus->headers_in } ); |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item $c->prepare_path |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub prepare_path { |
|
142
|
|
|
|
|
|
|
my $c = shift; |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
my $base; |
|
145
|
|
|
|
|
|
|
{ |
|
146
|
|
|
|
|
|
|
my $scheme = $c->request->secure ? 'https' : 'http'; |
|
147
|
|
|
|
|
|
|
my $host = $c->zeus->hostname; |
|
148
|
|
|
|
|
|
|
my $port = $c->zeus->get_server_port; |
|
149
|
|
|
|
|
|
|
my $path = $c->zeus->location || '/'; |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
unless ( $path =~ /\/$/ ) { |
|
152
|
|
|
|
|
|
|
$path .= '/'; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
$base = URI->new; |
|
156
|
|
|
|
|
|
|
$base->scheme($scheme); |
|
157
|
|
|
|
|
|
|
$base->host($host); |
|
158
|
|
|
|
|
|
|
$base->port($port); |
|
159
|
|
|
|
|
|
|
$base->path($path); |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
$base = $base->canonical->as_string; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my $location = $c->zeus->location || '/'; |
|
165
|
|
|
|
|
|
|
my $path = $c->zeus->uri || '/'; |
|
166
|
|
|
|
|
|
|
$path =~ s/^($location)?\///; |
|
167
|
|
|
|
|
|
|
$path =~ s/^\///; |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
$c->req->base($base); |
|
170
|
|
|
|
|
|
|
$c->req->path($path); |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item $c->prepare_request($r) |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub prepare_request { |
|
178
|
|
|
|
|
|
|
my ( $c, $r ) = @_; |
|
179
|
|
|
|
|
|
|
$c->zeus($r); |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item $c->run |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub run { } |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=back |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
L<Catalyst> L<Catalyst::Engine>. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 AUTHOR |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Christian Hansen C<ch@ngmedia.com> |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
|
201
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; |