File Coverage

lib/App/Request.pm
Criterion Covered Total %
statement 17 34 50.0
branch 2 24 8.3
condition 2 5 40.0
subroutine 3 8 37.5
pod 5 5 100.0
total 29 76 38.1


line stmt bran cond sub pod time code
1              
2             #############################################################################
3             ## $Id: Request.pm 9817 2007-07-30 22:46:19Z spadkins $
4             #############################################################################
5              
6             package App::Request;
7             $VERSION = (q$Revision: 9817 $ =~ /(\d[\d\.]*)/)[0]; # VERSION numbers generated by svn
8              
9 1     1   7 use strict;
  1         2  
  1         40  
10              
11 1     1   5 use App;
  1         2  
  1         494  
12              
13             =head1 NAME
14              
15             App::Request - the request
16              
17             =head1 SYNOPSIS
18              
19             # ... official way to get a Request object ...
20             use App;
21             $context = App->context();
22             $request = $context->request(); # get the request
23              
24             # ... alternative way (used internally) ...
25             use App::Request;
26             $request = App::Request->new();
27              
28             =cut
29              
30             #############################################################################
31             # CONSTANTS
32             #############################################################################
33              
34             =head1 DESCRIPTION
35              
36             A Request class ...
37              
38             =cut
39              
40             #############################################################################
41             # CLASS GROUP
42             #############################################################################
43              
44             =head1 Class Group: Request
45              
46             The following classes might be a part of the Request Class Group.
47              
48             =over
49              
50             =item * Class: App::Request
51              
52             =item * Class: App::Request::CGI
53              
54             =back
55              
56             =cut
57              
58             #############################################################################
59             # CONSTRUCTOR METHODS
60             #############################################################################
61              
62             =head1 Constructor Methods:
63              
64             =cut
65              
66             #############################################################################
67             # new()
68             #############################################################################
69              
70             =head2 new()
71              
72             The App::Request->new() method is rarely called directly.
73             That is because the current request is usually accessed through the
74             $context object.
75              
76             * Signature: $request = App::Request->new($context, $named);
77             * Return: $request App::Request
78             * Throws: App::Exception
79             * Since: 0.01
80              
81             Sample Usage:
82              
83             $request = App::Request->new();
84              
85             =cut
86              
87             sub new {
88 1 50   1 1 4 &App::sub_entry if ($App::trace);
89 1         3 my $this = shift;
90 1   33     13 my $class = ref($this) || $this;
91 1         3 my $self = {};
92 1         3 bless $self, $class;
93              
94 1         2 my $context = shift;
95 1         9 $self->{context} = $context;
96              
97 1   50     6 my $args = shift || {};
98 1         5 $self->_init($args);
99              
100 1 50       5 &App::sub_exit($self) if ($App::trace);
101 1         6 return $self;
102             }
103              
104             #############################################################################
105             # PROTECTED METHODS
106             #############################################################################
107              
108             =head1 Protected Methods:
109              
110             The following methods are intended to be called by subclasses of the
111             current class (or environmental, "main" code).
112              
113             =cut
114              
115             #############################################################################
116             # _init()
117             #############################################################################
118              
119             =head2 _init()
120              
121             The _init() method is called from within the standard Request constructor.
122             The _init() method in this class does nothing.
123             It allows subclasses of the Request to customize the behavior of the
124             constructor by overriding the _init() method.
125              
126             * Signature: $request->_init()
127             * Param: void
128             * Return: void
129             * Throws: App::Exception
130             * Since: 0.01
131              
132             Sample Usage:
133              
134             $request->_init();
135              
136             =cut
137              
138             sub _init {
139 0 0   0     &App::sub_entry if ($App::trace);
140 0           my ($self, $args) = @_;
141 0 0         &App::sub_exit() if ($App::trace);
142             }
143              
144             #############################################################################
145             # PUBLIC METHODS
146             #############################################################################
147              
148             =head1 Public Methods
149              
150             =cut
151              
152             #############################################################################
153             # user()
154             #############################################################################
155              
156             =head2 user()
157              
158             The user() method returns the username of the authenticated user.
159             The special name, "guest", refers to the unauthenticated (anonymous) user.
160              
161             * Signature: $username = $request->user();
162             * Param: void
163             * Return: string
164             * Throws:
165             * Since: 0.01
166              
167             Sample Usage:
168              
169             $username = $request->user();
170              
171             =cut
172              
173             sub user {
174 0 0   0 1   &App::sub_entry if ($App::trace);
175 0           my $self = shift;
176 0 0         &App::sub_exit("guest") if ($App::trace);
177 0           "guest";
178             }
179              
180             #############################################################################
181             # http_method()
182             #############################################################################
183              
184             =head2 http_method()
185              
186             Returns the HTTP method used in this request (i.e. "GET" or "POST").
187              
188             * Signature: $http_method = $request->http_method();
189             * Param: void
190             * Return: string
191             * Throws:
192             * Since: 0.01
193              
194             Sample Usage:
195              
196             $http_method = $request->http_method();
197              
198             =cut
199              
200             sub http_method {
201 0 0   0 1   &App::sub_entry if ($App::trace);
202 0 0         &App::sub_exit(undef) if ($App::trace);
203 0           return(undef);
204             }
205              
206             #############################################################################
207             # content_type()
208             #############################################################################
209              
210             =head2 content_type()
211              
212             Returns the content_type of data submitted in a POST, generally "multipart/form-data"
213             or "application/x-www-form-urlencoded".
214              
215             * Signature: $content_type = $request->content_type();
216             * Param: void
217             * Return: string
218             * Throws:
219             * Since: 0.01
220              
221             Sample Usage:
222              
223             $content_type = $request->content_type();
224              
225             =cut
226              
227             sub content_type {
228 0 0   0 1   &App::sub_entry if ($App::trace);
229 0 0         &App::sub_exit(undef) if ($App::trace);
230 0           return(undef);
231             }
232              
233             #############################################################################
234             # get_session_id()
235             #############################################################################
236              
237             =head2 get_session_id()
238              
239             The get_session_id() method returns the session_id in the request.
240              
241             * Signature: $session_id = $request->get_session_id();
242             * Param: void
243             * Return: $session_id string
244             * Throws:
245             * Since: 0.01
246              
247             Sample Usage:
248              
249             $session_id = $request->get_session_id();
250              
251             =cut
252              
253             sub get_session_id {
254 0 0   0 1   &App::sub_entry if ($App::trace);
255 0           my $self = shift;
256 0 0         &App::sub_exit("default") if ($App::trace);
257 0           "default";
258             }
259              
260             1;
261