← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:26:32 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Request.pm
StatementsExecuted 827 statements in 7.88ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
8832162.15ms4.95msFoswiki::Request::::paramFoswiki::Request::param
1111.15ms11.3msFoswiki::Request::::BEGIN@37Foswiki::Request::BEGIN@37
1754621µs1.18msFoswiki::Request::::headerFoswiki::Request::header
332303µs1.20msFoswiki::Request::::urlFoswiki::Request::url
633142µs419µsFoswiki::Request::::queryStringFoswiki::Request::queryString
11188µs438µsFoswiki::Request::::cookieFoswiki::Request::cookie
64471µs71µsFoswiki::Request::::pathInfoFoswiki::Request::pathInfo
55369µs69µsFoswiki::Request::::actionFoswiki::Request::action
22255µs314µsFoswiki::Request::::userAgentFoswiki::Request::userAgent
11142µs42µsFoswiki::Request::::newFoswiki::Request::new
22238µs38µsFoswiki::Request::::deleteFoswiki::Request::delete
43330µs30µsFoswiki::Request::::methodFoswiki::Request::method
21129µs38µsFoswiki::Request::::protocolFoswiki::Request::protocol
33328µs28µsFoswiki::Request::::remoteAddressFoswiki::Request::remoteAddress
43325µs25µsFoswiki::Request::::secureFoswiki::Request::secure
11124µs32µsFoswiki::Request::::BEGIN@29Foswiki::Request::BEGIN@29
11119µs80µsFoswiki::Request::::BEGIN@38Foswiki::Request::BEGIN@38
11116µs51µsFoswiki::Request::::BEGIN@35Foswiki::Request::BEGIN@35
11115µs34µsFoswiki::Request::::BEGIN@30Foswiki::Request::BEGIN@30
22215µs15µsFoswiki::Request::::uriFoswiki::Request::uri
31114µs14µsFoswiki::Request::::CORE:substFoswiki::Request::CORE:subst (opcode)
1119µs9µsFoswiki::Request::::uploadsFoswiki::Request::uploads
1119µs9µsFoswiki::Request::::BEGIN@32Foswiki::Request::BEGIN@32
1119µs9µsFoswiki::Request::::BEGIN@36Foswiki::Request::BEGIN@36
1117µs7µsFoswiki::Request::::cookiesFoswiki::Request::cookies
1117µs7µsFoswiki::Request::::serverPortFoswiki::Request::serverPort
1117µs7µsFoswiki::Request::::remoteUserFoswiki::Request::remoteUser
0000s0sFoswiki::Request::::base_actionFoswiki::Request::base_action
0000s0sFoswiki::Request::::bodyParamFoswiki::Request::bodyParam
0000s0sFoswiki::Request::::deleteAllFoswiki::Request::deleteAll
0000s0sFoswiki::Request::::httpFoswiki::Request::http
0000s0sFoswiki::Request::::httpsFoswiki::Request::https
0000s0sFoswiki::Request::::loadFoswiki::Request::load
0000s0sFoswiki::Request::::queryParamFoswiki::Request::queryParam
0000s0sFoswiki::Request::::refererFoswiki::Request::referer
0000s0sFoswiki::Request::::saveFoswiki::Request::save
0000s0sFoswiki::Request::::tmpFileNameFoswiki::Request::tmpFileName
0000s0sFoswiki::Request::::uploadFoswiki::Request::upload
0000s0sFoswiki::Request::::uploadInfoFoswiki::Request::uploadInfo
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2
3=begin TML
4
5---+!! package Foswiki::Request
6
7Class to encapsulate request data.
8
9Fields:
10 * =action= action requested (view, edit, save, ...)
11 * =cookies= hashref whose keys are cookie names and values
12 are CGI::Cookie objects
13 * =headers= hashref whose keys are header name
14 * =method= request method (GET, HEAD, POST)
15 * =param= hashref of parameters, both query and body ones
16 * =param_list= arrayref with parameter names in received order
17 * =path_info= path_info of request (eg. /WebName/TopciName)
18 * =remote_address= Client's IP address
19 * =remote_user= Remote HTTP authenticated user
20 * =secure= Boolean value about use of encryption
21 * =server_port= Port that the webserver listens on
22 * =uploads= hashref whose keys are parameter name of uploaded
23 files
24 * =uri= the request uri
25
26=cut
27
28package Foswiki::Request;
29245µs240µs
# spent 32µs (24+8) within Foswiki::Request::BEGIN@29 which was called: # once (24µs+8µs) by Foswiki::Engine::CGI::BEGIN@22 at line 29
use strict;
# spent 32µs making 1 call to Foswiki::Request::BEGIN@29 # spent 8µs making 1 call to strict::import
30242µs253µs
# spent 34µs (15+19) within Foswiki::Request::BEGIN@30 which was called: # once (15µs+19µs) by Foswiki::Engine::CGI::BEGIN@22 at line 30
use warnings;
# spent 34µs making 1 call to Foswiki::Request::BEGIN@30 # spent 19µs making 1 call to warnings::import
31
32256µs19µs
# spent 9µs within Foswiki::Request::BEGIN@32 which was called: # once (9µs+0s) by Foswiki::Engine::CGI::BEGIN@22 at line 32
use CGI ();
# spent 9µs making 1 call to Foswiki::Request::BEGIN@32
33110µsour @ISA = ('CGI');
34
35242µs287µs
# spent 51µs (16+36) within Foswiki::Request::BEGIN@35 which was called: # once (16µs+36µs) by Foswiki::Engine::CGI::BEGIN@22 at line 35
use Assert;
# spent 51µs making 1 call to Foswiki::Request::BEGIN@35 # spent 36µs making 1 call to Assert::import
36236µs19µs
# spent 9µs within Foswiki::Request::BEGIN@36 which was called: # once (9µs+0s) by Foswiki::Engine::CGI::BEGIN@22 at line 36
use Error ();
# spent 9µs making 1 call to Foswiki::Request::BEGIN@36
372178µs111.3ms
# spent 11.3ms (1.15+10.1) within Foswiki::Request::BEGIN@37 which was called: # once (1.15ms+10.1ms) by Foswiki::Engine::CGI::BEGIN@22 at line 37
use IO::File ();
# spent 11.3ms making 1 call to Foswiki::Request::BEGIN@37
3823.56ms2142µs
# spent 80µs (19+61) within Foswiki::Request::BEGIN@38 which was called: # once (19µs+61µs) by Foswiki::Engine::CGI::BEGIN@22 at line 38
use CGI::Util qw(rearrange);
# spent 80µs making 1 call to Foswiki::Request::BEGIN@38 # spent 61µs making 1 call to Exporter::import
39
40=begin TML
41
42---++ ClassMethod new([$initializer])
43
44Constructs a Foswiki::Request object.
45 * =$initializer= - may be a filehandle or hashref.
46 * If it's a filehandle, it'll be used to reload the Foswiki::Request
47 object. See =save= method. Note: Restore only parameters
48 * It can be a hashref whose keys are parameter names. Values may be
49 arrayref's to multivalued parameters. Same note as above.
50
51=cut
52
53
# spent 42µs within Foswiki::Request::new which was called: # once (42µs+0s) by Foswiki::Engine::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine.pm:102] at line 93 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine.pm
sub new {
54747µs my ( $proto, $initializer ) = @_;
55
56 my $this;
57
58 my $class = ref($proto) || $proto;
59
60 $this = {
61 action => '',
62 cookies => {},
63 headers => {},
64 method => undef,
65 param => {},
66 param_list => [],
67 path_info => '',
68 remote_address => '',
69 remote_user => undef,
70 secure => 0,
71 server_port => undef,
72 uploads => {},
73 uri => '',
74 };
75
76 bless $this, $class;
77
78 if ( ref($initializer) eq 'HASH' ) {
79 while ( my ( $key, $value ) = each %$initializer ) {
80 $this->param(
81 -name => $key,
82 -value => ref($value) eq 'ARRAY' ? [@$value] : [$value]
83 );
84 }
85 }
86 elsif ( ref($initializer) && UNIVERSAL::isa( $initializer, 'GLOB' ) ) {
87 $this->load($initializer);
88 }
89 return $this;
90}
91
92=begin TML
93
94---++ ObjectMethod action([$action]) -> $action
95
96
97Gets/Sets action requested (view, edit, save, ...)
98
99=cut
100
101
# spent 69µs within Foswiki::Request::action which was called 5 times, avg 14µs/call: # once (18µs+0s) by Foswiki::writeCompletePage at line 745 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm # once (17µs+0s) by Foswiki::Engine::CGI::preparePath at line 139 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine/CGI.pm # once (16µs+0s) by Foswiki::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki.pm:265] at line 265 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm # once (10µs+0s) by Foswiki::generateHTTPHeaders at line 996 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm # once (8µs+0s) by Foswiki::UI::handleRequest at line 179 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI.pm
sub action {
1021778µs my ( $this, $action ) = @_;
103 if ( defined $action ) {
104
105 # Record the very first action set in this request. It will be required
106 # later if a redirect cache overlays this request.
107 $this->{base_action} = $action unless defined $this->{base_action};
108 $ENV{FOSWIKI_ACTION} = $this->{action} = $action;
109 return $action;
110 }
111 else {
112 return $this->{action};
113 }
114
115}
116
117=begin TML
118
119---++ ObjectMethod base_action() -> $action
120
121Get the first action ever set in this request object. This remains
122unchanged even if a request cache is unwrapped on to of this request.
123The idea is that callers can always find out the action that initiated
124the HTTP request. This is required for (for example) checking access
125controls.
126
127=cut
128
129sub base_action {
130 my $this = shift;
131 return defined $this->{base_action}
132 ? $this->{base_action}
133 : $this->action();
134}
135
136=begin TML
137
138---++ ObjectMethod method( [ $method ] ) -> $method
139
140Sets/Gets request method (GET, HEAD, POST).
141
142=cut
143
144
# spent 30µs within Foswiki::Request::method which was called 4 times, avg 8µs/call: # 2 times (14µs+0s) by Foswiki::Engine::finalizeHeaders at line 353 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine.pm, avg 7µs/call # once (10µs+0s) by Foswiki::Engine::CGI::prepareConnection at line 50 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine/CGI.pm # once (6µs+0s) by Foswiki::UI::handleRequest at line 251 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI.pm
sub method {
145440µs return @_ == 1 ? $_[0]->{method} : ( $_[0]->{method} = $_[1] );
146}
147
148=begin TML
149
150---++ ObjectMethod pathInfo( [ $path ] ) -> $path
151
152Sets/Gets request path info.
153
154Called without parameters returns current pathInfo.
155
156There is a =path_info()= alias for compatibility with CGI.
157
158=cut
159
16013µs*path_info = \&pathInfo;
161
162
# spent 71µs within Foswiki::Request::pathInfo which was called 6 times, avg 12µs/call: # 3 times (49µs+0s) by Foswiki::Request::url at line 250, avg 16µs/call # once (8µs+0s) by Foswiki::new at line 1790 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm # once (8µs+0s) by Foswiki::Engine::CGI::preparePath at line 140 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine/CGI.pm # once (7µs+0s) by Foswiki::UI::handleRequest at line 224 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI.pm
sub pathInfo {
163684µs return @_ == 1 ? $_[0]->{path_info} : ( $_[0]->{path_info} = $_[1] );
164}
165
166=begin TML
167
168---++ ObjectMethod protocol() -> $protocol
169
170Returns 'https' if secure connection. 'http' otherwise.
171
172=cut
173
174# SMELL : review this
175
# spent 38µs (29+9) within Foswiki::Request::protocol which was called 2 times, avg 19µs/call: # 2 times (29µs+9µs) by Foswiki::Request::url at line 268, avg 19µs/call
sub protocol {
176223µs29µs return $_[0]->secure ? 'https' : 'http';
# spent 9µs making 2 calls to Foswiki::Request::secure, avg 5µs/call
177}
178
179=begin TML
180
181---++ ObjectMethod uri( [$uri] ) -> $uri
182
183Gets/Sets request uri.
184
185=cut
186
187
# spent 15µs within Foswiki::Request::uri which was called 2 times, avg 7µs/call: # once (8µs+0s) by Foswiki::Engine::CGI::preparePath at line 141 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine/CGI.pm # once (7µs+0s) by Foswiki::generateHTTPHeaders at line 997 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm
sub uri {
188221µs return @_ == 1 ? $_[0]->{uri} : ( $_[0]->{uri} = $_[1] );
189}
190
191=begin TML
192
193---++ ObjectMethod queryString() -> $query_string
194
195Returns query_string part of request uri, if any.
196
197=query_string()= alias provided for compatibility with CGI.
198
199=cut
200
20112µs*query_string = \&queryString;
202
203
# spent 419µs (142+277) within Foswiki::Request::queryString which was called 6 times, avg 70µs/call: # 3 times (60µs+125µs) by Foswiki::Request::url at line 280, avg 62µs/call # 2 times (67µs+117µs) by Foswiki::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki.pm:242] at line 242 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm, avg 92µs/call # once (15µs+35µs) by Foswiki::Plugins::TablePlugin::Core::handler at line 1845 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm
sub queryString {
20424134µs my $this = shift;
205 my @params;
2066277µs foreach my $name ( $this->param ) {
# spent 277µs making 6 calls to Foswiki::Request::param, avg 46µs/call
207 my $key = Foswiki::urlEncode($name);
208 push @params,
209 map { $key . "=" . Foswiki::urlEncode( defined $_ ? $_ : '' ) }
210 $this->param($name);
211 }
212 return join( ';', @params );
213}
214
215=begin TML
216
217---++ ObjectMethod url( [-full => 1,
218 -base => 1,
219 -absolute => 1,
220 -relative => 1,
221 -path => 1,
222 -query => 1] ) -> $url
223
224Returns many url info.
225 * If called without parameters or with -full => 1 returns full url, e.g.
226 http://mysite.net/view
227 * If called with -base => 1 returns base url, e.g. http://twiki.org
228 * -absolute => 1 returns absolute action path, e.g. /cgi-bin/view
229 * -relative => 1 returns relative action path, e.g. view
230 * -path => 1, -query => 1 also includes path info and query string
231 respectively
232
233Reasonably compatible with CGI corresponding method. Doesn't support
234-rewrite. See Item5914.
235
236=cut
237
238
# spent 1.20ms (303µs+896µs) within Foswiki::Request::url which was called 3 times, avg 399µs/call: # once (120µs+425µs) by Foswiki::writeCompletePage at line 778 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm # once (105µs+226µs) by Foswiki::new at line 1706 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm # once (78µs+244µs) by Foswiki::Plugins::TablePlugin::Core::handler at line 1844 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm
sub url {
23954305µs my ( $this, @p ) = @_;
240
2413365µs my ( $relative, $absolute, $full, $base, $path_info, $query ) = rearrange(
# spent 365µs making 3 calls to CGI::Util::rearrange, avg 122µs/call
242 [
243 qw(RELATIVE ABSOLUTE FULL BASE), [qw(PATH PATH_INFO)],
244 [qw(QUERY_STRING QUERY)],
245 ],
246 @p
247 );
248 my $url;
249 $full++ if $base || !( $relative || $absolute );
250349µs my $path = $this->pathInfo;
# spent 49µs making 3 calls to Foswiki::Request::pathInfo, avg 16µs/call
251 my $name;
252
253 ## See Foswiki.spec for the difference between ScriptUrlPath and ScriptUrlPaths
254 if ( defined $Foswiki::cfg{ScriptUrlPaths}{ $this->{action} } ) {
255
256 # When this is set, it is the complete script path including prefix/suffix.
257 $name = $Foswiki::cfg{ScriptUrlPaths}{ $this->{action} };
258 }
259 else {
260 $name = $Foswiki::cfg{ScriptUrlPath} . '/' . $this->{action};
261
262 # Don't add suffix if no script is used.
263 $name .= $Foswiki::cfg{ScriptSuffix} if $name;
264 }
265314µs $name =~ s(//+)(/)g;
# spent 14µs making 3 calls to Foswiki::Request::CORE:subst, avg 5µs/call
266 if ($full) {
2674244µs my $vh = $this->header('X-Forwarded-Host') || $this->header('Host');
# spent 244µs making 4 calls to Foswiki::Request::header, avg 61µs/call
268238µs $url =
# spent 38µs making 2 calls to Foswiki::Request::protocol, avg 19µs/call
269 $vh ? $this->protocol . '://' . $vh : $Foswiki::cfg{DefaultUrlHost};
270 return $url if $base;
271 $url .= $name;
272 }
273 elsif ($relative) {
274 ($url) = $name =~ m{([^/]+)$};
275 }
276 elsif ($absolute) {
277 $url = $name;
278 }
279 $url .= $path if $path_info && defined $path;
2803185µs my $queryString = $this->queryString();
# spent 185µs making 3 calls to Foswiki::Request::queryString, avg 62µs/call
281 $url .= '?' . $queryString if $query && $queryString;
282 $url = '' unless defined $url;
283 return $url;
284}
285
286=begin TML
287
288---++ ObjectMethod secure( [$secure] ) -> $secure
289
290Gets/Sets connection's secure flag.
291
292=cut
293
294
# spent 25µs within Foswiki::Request::secure which was called 4 times, avg 6µs/call: # 2 times (9µs+0s) by Foswiki::Request::protocol at line 176, avg 5µs/call # once (9µs+0s) by Foswiki::writeCompletePage at line 762 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm # once (6µs+0s) by Foswiki::LoginManager::_addSessionCookieToResponse at line 813 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/LoginManager.pm
sub secure {
295439µs return @_ == 1 ? $_[0]->{secure} : ( $_[0]->{secure} = $_[1] );
296}
297
298=begin TML
299
300---++ ObjectMethod remoteAddress( [$ip] ) -> $ip
301
302Gets/Sets client IP address.
303
304=remote_addr()= alias for compatibility with CGI.
305
306=cut
307
30812µs*remote_addr = \&remoteAddress;
309
310
# spent 28µs within Foswiki::Request::remoteAddress which was called 3 times, avg 9µs/call: # once (13µs+0s) by Foswiki::logEvent at line 2192 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm # once (8µs+0s) by Foswiki::Engine::CGI::prepareConnection at line 49 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine/CGI.pm # once (7µs+0s) by Foswiki::LoginManager::Session::load at line 33 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/LoginManager/Session.pm
sub remoteAddress {
311389µs return @_ == 1
312 ? $_[0]->{remote_address}
313 : ( $_[0]->{remote_address} = $_[1] );
314}
315
316=begin TML
317
318---++ ObjectMethod remoteUser( [$userName] ) -> $userName
319
320Gets/Sets remote user's name.
321
322=remote_user()= alias for compatibility with CGI.
323
324=cut
325
32612µs*remote_user = \&remoteUser;
327
328
# spent 7µs within Foswiki::Request::remoteUser which was called: # once (7µs+0s) by Foswiki::Engine::CGI::prepareHeaders at line 75 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine/CGI.pm
sub remoteUser {
329110µs return @_ == 1 ? $_[0]->{remote_user} : ( $_[0]->{remote_user} = $_[1] );
330}
331
332=begin TML
333
334---++ ObjectMethod serverPort( [$userName] ) -> $userName
335
336Gets/Sets server user's name.
337
338=server_port()= alias for compatibility with CGI.
339
340=cut
341
34212µs*server_port = \&serverPort;
343
344
# spent 7µs within Foswiki::Request::serverPort which was called: # once (7µs+0s) by Foswiki::Engine::CGI::prepareConnection at line 59 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine/CGI.pm
sub serverPort {
345110µs return @_ == 1 ? $_[0]->{server_port} : ( $_[0]->{server_port} = $_[1] );
346}
347
348=begin TML
349
350---++ ObjectMethod queryParam( [-name => $name, -value => $value |
351 -name => $name, -values => [ $v1, $v2, ... ] |
352 $name, $v1, $v2, ... |
353 name, [ $v1, $v2, ... ]
354 ] ) -> @paramNames | @values | $firstValue
355
356This methos is used by engines, during its prepare phase. Should not be used
357anywhere else. Since bodyParam must exist and it has different semantics from
358param method, this one exists for symmetry, and could be modified in the
359future, so it could be possible to get query and body parameters independently.
360
361=cut
362
363sub queryParam {
364 my $this = shift;
365 return if $this->method && $this->method eq 'POST';
366 return $this->param(@_);
367}
368
369=begin TML
370
371---++ ObjectMethod bodyParam( [-name => $name, -value => $value |
372 -name => $name, -values => [ $v1, $v2, ... ] |
373 $name, $v1, $v2, ... |
374 name, [ $v1, $v2, ... ]
375 ] ) -> @paramNames | @values | $firstValue
376
377Adds parameters passed within request body to the object. Should be called
378only by engines. Otherwise use param() method.
379
380=cut
381
382sub bodyParam {
383 my $this = shift;
384 return $this->param(@_);
385}
386
387=begin TML
388
389---++ ObjectMethod param( [-name => $name, -value => $value |
390 -name => $name, -values => [ $v1, $v2, ... ] |
391 $name, $v1, $v2, ... |
392 name, [ $v1, $v2, ... ]
393 ] ) -> @paramNames | @values | $firstValue
394
395 * Called without parameters returns all parameter names
396 * Called only with parameter name or with -name => 'name'
397 * In list context returns all associated values (maybe empty list)
398 * In scalar context returns first value (maybe undef)
399 * Called with name and list of values or with
400 -name => 'name', -value => 'value' or -name => 'name', -values => [ ... ]
401 sets parameter value
402
403Resonably compatible with CGI.
404
405=cut
406
407
# spent 4.95ms (2.15+2.80) within Foswiki::Request::param which was called 88 times, avg 56µs/call: # 15 times (353µs+432µs) by Foswiki::If::OP_dollar::evaluate at line 35 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/OP_dollar.pm, avg 52µs/call # 10 times (253µs+341µs) by Foswiki::If::OP_defined::evaluate at line 37 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/OP_defined.pm, avg 59µs/call # 7 times (193µs+276µs) by Foswiki::getSkin at line 1345 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm, avg 67µs/call # 7 times (143µs+202µs) by Foswiki::FORMFIELD at line 20 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/FORMFIELD.pm, avg 49µs/call # 7 times (133µs+179µs) by Foswiki::getSkin at line 1366 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm, avg 45µs/call # 6 times (149µs+207µs) by Foswiki::REVINFO at line 17 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/REVINFO.pm, avg 59µs/call # 6 times (133µs+144µs) by Foswiki::Request::queryString at line 206, avg 46µs/call # 3 times (83µs+99µs) by Foswiki::Plugins::WysiwygPlugin::beforeCommonTagsHandler at line 266 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/WysiwygPlugin.pm, avg 61µs/call # 2 times (56µs+79µs) by Foswiki::URLPARAM at line 47 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/URLPARAM.pm, avg 68µs/call # 2 times (43µs+59µs) by Foswiki::Plugins::SubscribePlugin::_SUBSCRIBE at line 34 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/SubscribePlugin.pm, avg 51µs/call # 2 times (40µs+55µs) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 274 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm, avg 47µs/call # once (44µs+64µs) by Foswiki::Plugins::load at line 130 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins.pm # once (47µs+56µs) by Foswiki::UI::View::view at line 155 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm # once (41µs+58µs) by Foswiki::Search::searchWeb at line 334 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Search.pm # once (38µs+43µs) by Foswiki::UI::View::view at line 255 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm # once (37µs+38µs) by Foswiki::UI::View::view at line 90 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm # once (29µs+34µs) by Foswiki::UI::handleRequest at line 216 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI.pm # once (26µs+37µs) by Foswiki::Plugins::WysiwygPlugin::modifyHeaderHandler at line 278 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/WysiwygPlugin.pm # once (26µs+37µs) by Foswiki::LoginManager::makeLoginManager at line 83 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/LoginManager.pm # once (28µs+34µs) by Foswiki::UI::View::view at line 237 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm # once (25µs+35µs) by Foswiki::Plugins::TablePlugin::Core::handler at line 1840 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm # once (24µs+34µs) by Foswiki::UI::View::view at line 218 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm # once (25µs+30µs) by Foswiki::LoginManager::loadSession at line 405 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/LoginManager.pm # once (25µs+28µs) by Foswiki::new at line 1758 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm # once (21µs+30µs) by Foswiki::REVARG at line 12 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/REVARG.pm # once (21µs+27µs) by Foswiki::UI::View::view at line 101 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm # once (20µs+26µs) by Foswiki::Plugins::TablePlugin::Core::handler at line 1853 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm # once (19µs+25µs) by Foswiki::UI::View::view at line 91 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm # once (19µs+24µs) by Foswiki::Plugins::TablePlugin::Core::handler at line 1863 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm # once (19µs+25µs) by Foswiki::Plugins::TablePlugin::Core::handler at line 1859 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm # once (19µs+25µs) by Foswiki::Plugins::TablePlugin::Core::handler at line 1841 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm # once (18µs+23µs) by Foswiki::Plugins::TablePlugin::Core::handler at line 1842 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm
sub param {
4085122.20ms my ( $this, @p ) = @_;
409
410882.80ms my ( $key, @value ) = rearrange( [ 'NAME', [qw(VALUE VALUES)] ], @p );
# spent 2.80ms making 88 calls to CGI::Util::rearrange, avg 32µs/call
411
412 return @{ $this->{param_list} } unless defined $key;
413 if ( defined $value[0] ) {
414 push @{ $this->{param_list} }, $key
415 unless exists $this->{param}{$key};
416 $this->{param}{$key} = ref $value[0] eq 'ARRAY' ? $value[0] : [@value];
417 }
418 if ( defined $this->{param}{$key} ) {
419 return wantarray
420 ? @{ $this->{param}{$key} }
421 : $this->{param}{$key}->[0];
422 }
423 else {
424 return wantarray ? () : undef;
425 }
426}
427
428=begin TML
429
430---++ ObjectMethod cookie($name [, $value, $path, $secure, $expires]) -> $value
431
432 * If called without parameters returns a list of cookie names.
433 * If called only with =$name= parameter returns value of cookie
434 with that name or undef if it doesn't exist.
435 * If called with defined $value and other parameters returns a
436 CGI::Cookie object created with those parameters. Doesn't
437 store this new created cookie within request object. This way
438 for compatibility with CGI.
439
440=cut
441
442
# spent 438µs (88+350) within Foswiki::Request::cookie which was called: # once (88µs+350µs) by CGI::Session::load at line 733 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session.pm
sub cookie {
443982µs eval { require CGI::Cookie; 1 } or throw Error::Simple($@);
444 my ( $this, @p ) = @_;
445147µs my ( $name, $value, $path, $secure, $expires ) =
# spent 47µs making 1 call to CGI::Util::rearrange
446 rearrange( [ 'NAME', [qw(VALUE VALUES)], 'PATH', 'SECURE', 'EXPIRES' ],
447 @p );
448 unless ( defined $value ) {
449 return keys %{ $this->{cookies} } unless $name;
45012µs1294µs return () unless $this->{cookies}{$name};
# spent 294µs making 1 call to CGI::Cookie::as_string
45118µs return $this->{cookies}{$name}->value if defined $name && $name ne '';
# spent 8µs making 1 call to CGI::Cookie::value
452 }
453 return unless defined $name && $name ne '';
454 return new CGI::Cookie(
455 -name => $name,
456 -value => $value,
457 -path => $path || '/',
458 -secure => $secure || $this->secure,
459 -expires => $expires || abs( $Foswiki::cfg{Sessions}{ExpireAfter} )
460 );
461}
462
463=begin TML
464
465ObjectMethod cookies( \%cookies ) -> $hashref
466
467Gets/Sets cookies hashref. Keys are cookie names
468and values CGI::Cookie objects.
469
470=cut
471
472
# spent 7µs within Foswiki::Request::cookies which was called: # once (7µs+0s) by Foswiki::Engine::prepareCookies at line 238 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine.pm
sub cookies {
473110µs return @_ == 1 ? $_[0]->{cookies} : ( $_[0]->{cookies} = $_[1] );
474}
475
476=begin TML
477
478---++ ObjectMethod delete( @paramNames )
479
480Deletes parameters from request.
481
482=Delete()= alias provided for compatibility with CGI
483
484=cut
485
48612µs*Delete = \&delete;
487
488
# spent 38µs within Foswiki::Request::delete which was called 2 times, avg 19µs/call: # once (26µs+0s) by Foswiki::Plugins::TablePlugin::Core::handler at line 1843 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm # once (12µs+0s) by Foswiki::LoginManager::loadSession at line 452 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/LoginManager.pm
sub delete {
489841µs my $this = shift;
490 foreach my $p (@_) {
491 next unless exists $this->{param}{$p};
492 if ( my $upload = $this->{uploads}{ $this->param($p) } ) {
493 $upload->finish;
494 CORE::delete $this->{uploads}{ $this->param($p) };
495 }
496 CORE::delete $this->{param}{$p};
497 @{ $this->{param_list} } = grep { $_ ne $p } @{ $this->{param_list} };
498 }
499}
500
501=begin TML
502
503---++ ObjectMethod deleteAll()
504
505Deletes all parameter name and value(s).
506
507=delete_all()= alias provided for compatibility with CGI.
508
509=cut
510
51112µs*delete_all = \&deleteAll;
512
513sub deleteAll {
514 my $this = shift;
515 $this->delete( $this->param() );
516}
517
518=begin TML
519
520---++ ObjectMethod header([-name => $name, -value => $value |
521 -name => $name, -values => [ $v1, $v2, ... ] |
522 $name, $v1, $v2, ... |
523 name, [ $v1, $v2, ... ]
524 ] ) -> @paramNames | @values | $firstValue
525
526Gets/Sets a header field:
527 * Called without parameters returns all header field names
528 * Called only with header field name or with -name => 'name'
529 * In list context returns all associated values (maybe empty list)
530 * In scalar context returns the first value (maybe undef)
531 * Called with name and list of values or with
532 -name => 'name', -value => 'value' or -name => 'name', -values => [ ... ]
533 sets header field value
534
535*Not compatible with CGI*, since CGI correspondent is a
536response write method. CGI scripts obtain headers from %ENV
537or =http= method. %ENV is not available and must be replaced
538by calls to this and other methods of this class. =http= is
539provided for compatibility, but is deprecated. Use this one
540instead.
541
542Calls to CGI =header= method must be replaced by calls to
543Foswiki::Response =header= method.
544
545=cut
546
547
# spent 1.18ms (621µs+559µs) within Foswiki::Request::header which was called 17 times, avg 69µs/call: # 8 times (274µs+235µs) by Foswiki::Engine::CGI::prepareHeaders at line 73 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine/CGI.pm, avg 64µs/call # 4 times (134µs+110µs) by Foswiki::Request::url at line 267, avg 61µs/call # 2 times (127µs+131µs) by Foswiki::Request::userAgent at line 740, avg 129µs/call # 2 times (59µs+57µs) by Foswiki::Engine::prepareCookies at line 238 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine.pm, avg 58µs/call # once (26µs+26µs) by Foswiki::LoginManager::loadSession at line 292 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/LoginManager.pm
sub header {
548145603µs my ( $this, @p ) = @_;
54917559µs my ( $key, @value ) = rearrange( [ 'NAME', [qw(VALUE VALUES)] ], @p );
# spent 559µs making 17 calls to CGI::Util::rearrange, avg 33µs/call
550
551 return keys %{ $this->{headers} } unless $key;
552 $key =~ tr/_/-/;
553 $key = lc($key);
554
555 if ( defined $value[0] ) {
556 $this->{headers}{$key} =
557 ref $value[0] eq 'ARRAY' ? $value[0] : [@value];
558 }
559 if ( defined $this->{headers}{$key} ) {
560 return wantarray
561 ? @{ $this->{headers}{$key} }
562 : $this->{headers}{$key}->[0];
563 }
564 else {
565 return wantarray ? () : undef;
566 }
567}
568
569=begin TML
570
571---++ ObjectMethod save( $fh )
572
573Saves object state to filehandle. Object may be loaded latter
574passing $fh to new constructor or by calling load().
575
576=cut
577
578sub save {
579 my ( $this, $fh ) = @_;
580 local ( $\, $, ) = ( '', '' );
581 foreach my $name ( $this->param ) {
582 my $key = Foswiki::urlEncode($name);
583 foreach my $value ( $this->param($name) ) {
584 $value = '' unless defined $value;
585 print $fh Foswiki::urlEncode($key), '=',
586 Foswiki::urlEncode($value), "\n";
587 }
588 }
589 print $fh "=\n";
590}
591
592=begin TML
593
594---++ ObjectMethod load( $fh )
595
596Loads object state from filehandle, probably created with
597a previous save().
598
599=cut
600
601sub load {
602 my ( $this, $file ) = @_;
603 my %param = ();
604 my @plist = ();
605 local $/ = "\n";
606 while (<$file>) {
607 chomp;
608 last if /^=/;
609 my ( $key, $value ) =
610 map { defined $_ ? Foswiki::urlDecode($_) : $_ } split /=/;
611 if ( exists $param{$key} ) {
612 push @{ $param{$key} }, $value;
613 }
614 else {
615 push @plist, $key;
616 $param{$key} = [$value];
617 }
618 }
619 foreach my $key (@plist) {
620 $this->param( -name => $key, -value => $param{$key} );
621 }
622}
623
624=begin TML
625
626---++ ObjectMethod upload( $name ) -> $handle
627
628Called with file name parameter returns an open filehandle
629to uploaded file.
630
631=cut
632
633sub upload {
634 my ( $this, $name ) = @_;
635 my $upload = $this->{uploads}{ $this->param($name) };
636 return defined $upload ? $upload->handle : undef;
637}
638
639=begin TML
640
641---++ ObjectMethod uploadInfo( $fname ) -> $headers
642
643Returns a hashref to information about uploaded
644files as sent by browser.
645
646=cut
647
648sub uploadInfo {
649 return $_[0]->{uploads}{ $_[1] }->uploadInfo;
650}
651
652=begin TML
653
654---++ ObjectMethod tmpFileName( $fname ) -> $tmpFileName
655
656Returns the name of temporarly created file to store uploaded $fname.
657
658$fname may be obtained by calling =param()= with form field name.
659
660=cut
661
662sub tmpFileName {
663 my ( $this, $fname ) = @_;
664 return $this->{uploads}{$fname}
665 ? $this->{uploads}{$fname}->tmpFileName
666 : undef;
667}
668
669=begin TML
670
671---++ ObjectMethod uploads( [ \%uploads ] ) -> $hashref
672
673Gets/Sets request uploads field. Keys are uploaded file names,
674as sent by browser, and values are Foswiki::Request::Upload objects.
675
676=cut
677
678
# spent 9µs within Foswiki::Request::uploads which was called: # once (9µs+0s) by Foswiki::Engine::CGI::finalizeUploads at line 187 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Engine/CGI.pm
sub uploads {
679112µs return @_ == 1 ? $_[0]->{uploads} : ( $_[0]->{uploads} = $_[1] );
680}
681
682# ======== possible accessors =======
683# auth_type
684# content_length
685# content_type
686
687=begin TML
688
689---++ ObjectMethod http( [$header] ) -> $value DEPRECATED
690
691Called without parameters returns a list of all available header filed names.
692
693Given a field name returns value associated.
694
695http('HTTP_USER_AGENT'); http('User-Agent') and http('User_Agent')
696are equivalent.
697
698Please, use =header()= instead. Present only for compatibility with CGI.
699
700=cut
701
702sub http {
703 my ( $this, $p ) = @_;
704 if ( defined $p ) {
705 $p =~ s/^https?[_-]//i;
706 return $this->header($p);
707 }
708 return $this->header();
709}
710
711=begin TML
712
713---++ ObjectMethod https( [$name] ) -> $value || $secure DEPRECATED
714
715Similar to =http()= method above. Called with no parameters returns
716secure flag.
717
718Please, use =header()= and =secure()= instead.
719Present only for compatibility with CGI.
720
721=cut
722
723sub https {
724 my ( $this, $p ) = @_;
725 return !defined $p || $p =~ /^https$/i ? $this->secure : $this->http($p);
726}
727
728=begin TML
729
730---++ ObjectMethod userAgent() -> $userAgent;
731
732Convenience method to get User-Agent string.
733
734=user_agent()= alias provided for compatibility with CGI.
735
736=cut
737
73812µs*user_agent = \&userAgent;
739
740247µs2259µs
# spent 314µs (55+259) within Foswiki::Request::userAgent which was called 2 times, avg 157µs/call: # once (38µs+187µs) by Foswiki::Plugins::TinyMCEPlugin::initPlugin at line 46 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TinyMCEPlugin.pm # once (18µs+72µs) by Foswiki::logEvent at line 2176 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm
sub userAgent { shift->header('User-Agent') }
# spent 259µs making 2 calls to Foswiki::Request::header, avg 129µs/call
741
742=begin TML
743
744---++ ObjectMethod referer()
745
746Convenience method to get Referer uri.
747
748=cut
749
750sub referer { shift->header('Referer') }
751
752114µs1;
753__END__
 
# spent 14µs within Foswiki::Request::CORE:subst which was called 3 times, avg 5µs/call: # 3 times (14µs+0s) by Foswiki::Request::url at line 265, avg 5µs/call
sub Foswiki::Request::CORE:subst; # opcode