HTTP/Apache.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 64 CC 5 SCAR 26.9
CC
5
Cov
0%
handler
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 14.7
1 package SOAP::Transport::ActiveWorks::HTTP::Apache;
2  
3  
4 BEGIN
5 {
6 use strict;
7 use vars qw($VERSION);
8 $VERSION = '0.28a';
9  
10 use Apache;
11 use Apache::Constants qw(:common :response);
12  
13 require SOAP::Transport::ActiveWorks::HTTP::Proxy;
14 }
15  
16  
17 sub handler {
18 my (undef, $safe_classes) = @_;
19 my $optional_dispatcher;
20  
21 my $r = Apache->request();
22  
23 my %args = $r->args();
24 unless (exists $args{class}) {
25 return BAD_REQUEST;
26 }
27 my $request_class = $args{class};
28 unless (exists $safe_classes->{$request_class}) {
29 return BAD_REQUEST;
30 }
31 if ( $safe_classes->{$request_class}
32 && (ref($safe_classes->{$request_class}) eq "CODE") ) {
33 $optional_dispatcher = $safe_classes->{$request_class};
34 }
35 # my $http_protocol = $r->protocol();
36 my $http_method = $r->method();
37  
38 my $request_header_reader = sub {
39 $r->header_in($_[0]);
40 };
41 my $request_content_reader = sub {
42 $r->read(@_);
43 };
44  
45 my $response_header_writer = sub {
46 # TBD: call err_header_out on error
47 $r->header_out(@_);
48 };
49  
50 my $sent_headers = 0;
51 my $response_content_writer = sub {
52 # TBD: call custom_response on error
53 $r->send_http_header() unless $sent_headers++;
54 $r->print(shift);
55 };
56  
57 my $s = SOAP::Transport::ActiveWorks::HTTP::Proxy->new();
58  
59 $s->handle_request($http_method, $request_class,
60 $request_header_reader,
61 $request_content_reader,
62 $response_header_writer,
63 $response_content_writer,
64 $optional_dispatcher);
65 OK;
66 }
67  
68 1;
69 __END__