File Coverage

blib/lib/WebDyne/CGI.pm
Criterion Covered Total %
statement 26 35 74.2
branch 3 6 50.0
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 37 50 74.0


line stmt bran cond sub pod time code
1             #
2             # This file is part of WebDyne.
3             #
4             # This software is copyright (c) 2026 by Andrew Speer .
5             #
6             # This is free software; you can redistribute it and/or modify it under
7             # the same terms as the Perl 5 programming language system itself.
8             #
9             # Full license text is available at:
10             #
11             #
12             #
13             package WebDyne::CGI;
14              
15              
16             # Pragma
17             #
18 7     7   67 use strict qw(vars);
  7         12  
  7         325  
19 7     7   78 use vars qw($VERSION $AUTOLOAD);
  7         14  
  7         357  
20 7     7   34 use warnings;
  7         10  
  7         348  
21 7     7   45 no warnings qw(uninitialized redefine);
  7         22  
  7         366  
22              
23              
24             # WebDyne Modules
25             #
26 7     7   36 use WebDyne::Util;
  7         10  
  7         37  
27              
28              
29             # External modules
30             #
31 7     7   38 use Data::Dumper;
  7         19  
  7         2610  
32              
33              
34             # Version information
35             #
36             $VERSION='2.075';
37              
38              
39             # Debug load
40             #
41             0 && debug("Loading %s version $VERSION", __PACKAGE__);
42              
43              
44             #==============================================================================
45              
46             sub new {
47              
48            
49             # Need to work out if supplying Plack::Request or CGI::Simple object
50             #
51 2     2 0 6 my ($class, $r, %param)=@_;
52 2         3 0 && debug("class: $class, r:$r, caller: %s", Dumper([caller(0)]));
53            
54            
55             # Request handler ?
56             #
57 2 50       17 if (ref($r) eq 'WebDyne::Request::PSGI') {
    50          
    50          
58            
59             # Plack
60             #
61 0         0 0 && debug('detected Plack request handler');
62 0         0 require WebDyne::CGI::PSGI;
63 0         0 *new=WebDyne::CGI::PSGI::new;
64            
65            
66             }
67             elsif (ref($r)=~/^Apache2(?:::Request)?/) {
68            
69             # Apache 2
70             #
71 0         0 0 && debug('detected Apache MP2 request handler');
72 0         0 require WebDyne::CGI::Simple;
73 0         0 *new=WebDyne::CGI::Simple::new;
74              
75              
76             }
77             elsif (ref($r)=~/^Apache(?:::Request)?$/) {
78            
79             # Ugh. Apache 1
80             #
81 0         0 0 && debug('detected Apache MP1 request handler');
82 0         0 require WebDyne::CGI::Simple;
83 0         0 *new=WebDyne::CGI::Simple::new;
84            
85              
86             }
87             else {
88            
89             # Command line or everything else is CGI::Simple;
90             #
91 2         7 0 && debug('defaulting to CGI::Simple handler, r:%s', Dumper($r));
92 2         1124 require WebDyne::CGI::Simple;
93            
94             # Note closure - we *don't* want to pass $r or param to CGI::Simple if
95             # not in mod_perl
96 2     9   16 *new=sub { &WebDyne::CGI::Simple::new() };
  5         53  
97            
98             }
99            
100              
101             # Done
102             #
103 2         17 return $class->new($r, %param);
104            
105             }
106              
107             1;
108