| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
|
2
|
|
|
|
|
|
|
package HTTP::Server::Simple::WebDAO; |
|
3
|
1
|
|
|
1
|
|
20434
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
44
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
5
|
1
|
|
|
1
|
|
609
|
use HTTP::Server::Simple::CGI; |
|
|
1
|
|
|
|
|
24099
|
|
|
|
1
|
|
|
|
|
54
|
|
|
6
|
1
|
|
|
1
|
|
12
|
use base qw/HTTP::Server::Simple::CGI/; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
89
|
|
|
7
|
1
|
|
|
1
|
|
324
|
use WebDAO; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use WebDAO::Util; |
|
9
|
|
|
|
|
|
|
use WebDAO::Engine; |
|
10
|
|
|
|
|
|
|
use WebDAO::Session; |
|
11
|
|
|
|
|
|
|
use vars qw($VERSION); |
|
12
|
|
|
|
|
|
|
$VERSION = '0.04'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
HTTP::Server::Simple::WebDAO - WebDAO handler for HTTP::Server::Simple |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
HTTP::Server::Simple::WebDAO; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $srv = new HTTP::Server::Simple::WebDAO::($port); |
|
23
|
|
|
|
|
|
|
$srv->set_config( wdEngine => "Plosurin::HTTP", wdDebug => 3 ); |
|
24
|
|
|
|
|
|
|
$srv->run(); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
HTTP::Server::Simple::WebDAO is a HTTP::Server::Simple based HTTP server |
|
29
|
|
|
|
|
|
|
that can run WebDAO applications. This module only depends on |
|
30
|
|
|
|
|
|
|
L, which itself doesn't depend on any non-core |
|
31
|
|
|
|
|
|
|
modules so it's best to be used as an embedded web server. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
L, L |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 AUTHOR |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Zahatski Aliaksandr |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 LICENSE |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Copyright 2011-2015 by Zahatski Aliaksandr |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
47
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new { |
|
52
|
|
|
|
|
|
|
my $class = shift; |
|
53
|
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
|
54
|
|
|
|
|
|
|
$self->set_config; |
|
55
|
|
|
|
|
|
|
return $self; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub set_config { |
|
60
|
|
|
|
|
|
|
my $self = shift; |
|
61
|
|
|
|
|
|
|
my %args = @_; |
|
62
|
|
|
|
|
|
|
while ( my ( $k, $v ) = each %args ) { |
|
63
|
|
|
|
|
|
|
$self->{$k} = $v; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
$ENV{wdSession} ||= $args{wdSession}; |
|
66
|
|
|
|
|
|
|
$ENV{wdEngine} ||= $args{wdEngine}; |
|
67
|
|
|
|
|
|
|
#preload defaults |
|
68
|
|
|
|
|
|
|
$self->{ini} = WebDAO::Util::get_classes(__env => \%ENV, __preload=>1); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$self; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub handle_request { |
|
74
|
|
|
|
|
|
|
my ( $self, $cgi ) = @_; |
|
75
|
|
|
|
|
|
|
my $ini = $self->{ini}; |
|
76
|
|
|
|
|
|
|
my $sess = "$ini->{wdSession}"->new( |
|
77
|
|
|
|
|
|
|
%{ $ini->{wdSessionPar} }, |
|
78
|
|
|
|
|
|
|
cv => HTTP::Server::Simple::WebDAO::CVcgi->new(env=>\%ENV) |
|
79
|
|
|
|
|
|
|
); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $eng = "$ini->{wdEngine}"->new( |
|
82
|
|
|
|
|
|
|
%{ $ini->{wdEnginePar} }, |
|
83
|
|
|
|
|
|
|
session => $sess, |
|
84
|
|
|
|
|
|
|
); |
|
85
|
|
|
|
|
|
|
$ENV{wdDebug} = $self->{wdDebug} if exists $self->{wdDebug}; |
|
86
|
|
|
|
|
|
|
$sess->ExecEngine($eng); |
|
87
|
|
|
|
|
|
|
$sess->destroy; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
package HTTP::Server::Simple::WebDAO::CVcgi; |
|
91
|
|
|
|
|
|
|
use strict; |
|
92
|
|
|
|
|
|
|
use warnings; |
|
93
|
|
|
|
|
|
|
use WebDAO::CVfcgi; |
|
94
|
|
|
|
|
|
|
use WebDAO::Util; |
|
95
|
|
|
|
|
|
|
use base qw/WebDAO::CVfcgi/; |
|
96
|
|
|
|
|
|
|
use vars qw($VERSION); |
|
97
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
98
|
|
|
|
|
|
|
sub new { |
|
99
|
|
|
|
|
|
|
my $class = shift; |
|
100
|
|
|
|
|
|
|
return $class->WebDAO::CV::new(@_, writer=> sub { |
|
101
|
|
|
|
|
|
|
my $code = $_[0]->[0]; |
|
102
|
|
|
|
|
|
|
my $headers_ref = $_[0]->[1]; |
|
103
|
|
|
|
|
|
|
my $fd = new WebDAO::Fcgi::Writer:: headers=>$headers_ref; |
|
104
|
|
|
|
|
|
|
my $message = $WebDAO::Util::HTTPStatusCode{$code}; |
|
105
|
|
|
|
|
|
|
my $header_str= "HTTP/1.0 $code $message\015\012"; |
|
106
|
|
|
|
|
|
|
while ( my ($header, $value) = splice( @$headers_ref, 0, 2) ) { |
|
107
|
|
|
|
|
|
|
$header_str .= "$header: $value\015\012" |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
$header_str .="\015\012"; |
|
110
|
|
|
|
|
|
|
$fd->write($header_str); |
|
111
|
|
|
|
|
|
|
return $fd |
|
112
|
|
|
|
|
|
|
} ) |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
package HTTP::Server::Simple::WebDAO; |
|
116
|
|
|
|
|
|
|
1; |