line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SOAP::Transport::HTTP::Nginx; |
2
|
1
|
|
|
1
|
|
4544
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
499
|
use SOAP::Transport::HTTP; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use base qw(SOAP::Transport::HTTP::Server); |
6
|
|
|
|
|
|
|
# can be required/evaled only from nginx environment |
7
|
|
|
|
|
|
|
# preserve for other code |
8
|
|
|
|
|
|
|
eval{ require nginx }; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use constant HTTP_HEADERS => qw( |
11
|
|
|
|
|
|
|
Accept |
12
|
|
|
|
|
|
|
Accept-Charset |
13
|
|
|
|
|
|
|
Accept-Encoding |
14
|
|
|
|
|
|
|
Accept-Language |
15
|
|
|
|
|
|
|
Accept-Ranges |
16
|
|
|
|
|
|
|
Age |
17
|
|
|
|
|
|
|
Allow |
18
|
|
|
|
|
|
|
Authorization |
19
|
|
|
|
|
|
|
Cache-Control |
20
|
|
|
|
|
|
|
Connection |
21
|
|
|
|
|
|
|
Content-Disposition |
22
|
|
|
|
|
|
|
Content-Encoding |
23
|
|
|
|
|
|
|
Content-Language |
24
|
|
|
|
|
|
|
Content-Length |
25
|
|
|
|
|
|
|
Content-Location |
26
|
|
|
|
|
|
|
Content-MD5 |
27
|
|
|
|
|
|
|
Content-Range |
28
|
|
|
|
|
|
|
Content-Type |
29
|
|
|
|
|
|
|
Cookie |
30
|
|
|
|
|
|
|
Date |
31
|
|
|
|
|
|
|
ETag |
32
|
|
|
|
|
|
|
Expires |
33
|
|
|
|
|
|
|
Host |
34
|
|
|
|
|
|
|
If-Modified-Since |
35
|
|
|
|
|
|
|
If-None-Match |
36
|
|
|
|
|
|
|
Last-Modified |
37
|
|
|
|
|
|
|
Location |
38
|
|
|
|
|
|
|
Referer |
39
|
|
|
|
|
|
|
Server |
40
|
|
|
|
|
|
|
Set-Cookie |
41
|
|
|
|
|
|
|
User-Agent |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
SOAP::Transport::HTTP::Nginx - transport for nginx (L) http server for SOAP::Lite module. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 VERSION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Version 0.01 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Provide support for HTTP Nginx transport. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 FUNCTIONS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item DESTROY |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Destructor. Add tracing if object was initialized so. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub DESTROY { SOAP::Trace::objects('()') } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item new |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Constructor. "Autocalled" from server side. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub new { |
79
|
|
|
|
|
|
|
my $self = shift; |
80
|
|
|
|
|
|
|
unless (ref $self) { |
81
|
|
|
|
|
|
|
my $class = ref($self) || $self; |
82
|
|
|
|
|
|
|
$self = $class->SUPER::new(@_); |
83
|
|
|
|
|
|
|
SOAP::Trace::objects('()'); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
return $self; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item handler |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Handler server function. "Autocalled" from server side. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub handler { |
96
|
|
|
|
|
|
|
my $self = shift->new; |
97
|
|
|
|
|
|
|
my $r = shift; |
98
|
|
|
|
|
|
|
my $content = shift; |
99
|
|
|
|
|
|
|
my $cont_len = $r->header_in('Content-length'); |
100
|
|
|
|
|
|
|
unless($cont_len > 0) { |
101
|
|
|
|
|
|
|
no strict "subs"; |
102
|
|
|
|
|
|
|
return HTTP_BAD_REQUEST; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$self->request( |
106
|
|
|
|
|
|
|
HTTP::Request->new( |
107
|
|
|
|
|
|
|
$r->request_method() => $r->uri, |
108
|
|
|
|
|
|
|
HTTP::Headers->new( |
109
|
|
|
|
|
|
|
map { $_ => $r->header_in($_) } &HTTP_HEADERS(), |
110
|
|
|
|
|
|
|
), |
111
|
|
|
|
|
|
|
$content |
112
|
|
|
|
|
|
|
) |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
$self->SUPER::handle; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# TODO: check this out |
117
|
|
|
|
|
|
|
# we will specify status manually for Apache, because |
118
|
|
|
|
|
|
|
# if we do it as it has to be done, returning SERVER_ERROR, |
119
|
|
|
|
|
|
|
# Apache will modify our content_type to 'text/html; ....' |
120
|
|
|
|
|
|
|
# which is not what we want. |
121
|
|
|
|
|
|
|
# will emulate normal response, but with custom status code |
122
|
|
|
|
|
|
|
# which could also be 500. |
123
|
|
|
|
|
|
|
$r->status($self->response->code); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$r->print($self->response->content); |
126
|
|
|
|
|
|
|
return $self->{OK}; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item configure |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Configure server. "Autocalled" from server side. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub configure { |
136
|
|
|
|
|
|
|
my $self = shift->new; |
137
|
|
|
|
|
|
|
my $config = shift->dir_config; |
138
|
|
|
|
|
|
|
for (%$config) { |
139
|
|
|
|
|
|
|
$config->{$_} =~ /=>/ |
140
|
|
|
|
|
|
|
? $self->$_({split /\s*(?:=>|,)\s*/, $config->{$_}}) |
141
|
|
|
|
|
|
|
: ref $self->$_() |
142
|
|
|
|
|
|
|
? () # hm, nothing can be done here |
143
|
|
|
|
|
|
|
: $self->$_(split /\s+|\s*,\s*/, $config->{$_}) |
144
|
|
|
|
|
|
|
if $self->can($_); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
return $self; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
{ |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item handle |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Alias for handler. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# just create alias |
158
|
|
|
|
|
|
|
sub handle; |
159
|
|
|
|
|
|
|
*handle = \&handler |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=back |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
SOAP::Transport::HTTP base HTTP transport module |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 SEE ALSO |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
See SOAP::Lite for details. |
171
|
|
|
|
|
|
|
See examples/* for examples. |
172
|
|
|
|
|
|
|
See http://httpnginx.sourceforge.net, http://sourceforge.net/scm/?type=svn&group_id=257229 for project details/svn_code. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 AUTHOR |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Alexander Soudakov, C<< >> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 BUGS |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
181
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
182
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 SUPPORT |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
perldoc SOAP::Transport::HTTP::Nginx |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
You can also look for information at: |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=over 4 |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
L |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
L |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * CPAN Ratings |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
L |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * Search CPAN |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
L |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=back |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Copyright 2009 Alexander Soudakov, all rights reserved. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
217
|
|
|
|
|
|
|
under the same terms as Perl itself. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=cut |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
12; |