Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Request.pm |
Statements | Executed 827 statements in 7.88ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
88 | 32 | 16 | 2.15ms | 4.95ms | param | Foswiki::Request::
1 | 1 | 1 | 1.15ms | 11.3ms | BEGIN@37 | Foswiki::Request::
17 | 5 | 4 | 621µs | 1.18ms | header | Foswiki::Request::
3 | 3 | 2 | 303µs | 1.20ms | url | Foswiki::Request::
6 | 3 | 3 | 142µs | 419µs | queryString | Foswiki::Request::
1 | 1 | 1 | 88µs | 438µs | cookie | Foswiki::Request::
6 | 4 | 4 | 71µs | 71µs | pathInfo | Foswiki::Request::
5 | 5 | 3 | 69µs | 69µs | action | Foswiki::Request::
2 | 2 | 2 | 55µs | 314µs | userAgent | Foswiki::Request::
1 | 1 | 1 | 42µs | 42µs | new | Foswiki::Request::
2 | 2 | 2 | 38µs | 38µs | delete | Foswiki::Request::
4 | 3 | 3 | 30µs | 30µs | method | Foswiki::Request::
2 | 1 | 1 | 29µs | 38µs | protocol | Foswiki::Request::
3 | 3 | 3 | 28µs | 28µs | remoteAddress | Foswiki::Request::
4 | 3 | 3 | 25µs | 25µs | secure | Foswiki::Request::
1 | 1 | 1 | 24µs | 32µs | BEGIN@29 | Foswiki::Request::
1 | 1 | 1 | 19µs | 80µs | BEGIN@38 | Foswiki::Request::
1 | 1 | 1 | 16µs | 51µs | BEGIN@35 | Foswiki::Request::
1 | 1 | 1 | 15µs | 34µs | BEGIN@30 | Foswiki::Request::
2 | 2 | 2 | 15µs | 15µs | uri | Foswiki::Request::
3 | 1 | 1 | 14µs | 14µs | CORE:subst (opcode) | Foswiki::Request::
1 | 1 | 1 | 9µs | 9µs | uploads | Foswiki::Request::
1 | 1 | 1 | 9µs | 9µs | BEGIN@32 | Foswiki::Request::
1 | 1 | 1 | 9µs | 9µs | BEGIN@36 | Foswiki::Request::
1 | 1 | 1 | 7µs | 7µs | cookies | Foswiki::Request::
1 | 1 | 1 | 7µs | 7µs | serverPort | Foswiki::Request::
1 | 1 | 1 | 7µs | 7µs | remoteUser | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | base_action | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | bodyParam | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | deleteAll | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | http | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | https | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | load | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | queryParam | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | referer | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | save | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | tmpFileName | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | upload | Foswiki::Request::
0 | 0 | 0 | 0s | 0s | uploadInfo | Foswiki::Request::
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 | |||||
7 | Class to encapsulate request data. | ||||
8 | |||||
9 | Fields: | ||||
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 | |||||
28 | package Foswiki::Request; | ||||
29 | 2 | 45µs | 2 | 40µ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 # spent 32µs making 1 call to Foswiki::Request::BEGIN@29
# spent 8µs making 1 call to strict::import |
30 | 2 | 42µs | 2 | 53µ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 # spent 34µs making 1 call to Foswiki::Request::BEGIN@30
# spent 19µs making 1 call to warnings::import |
31 | |||||
32 | 2 | 56µs | 1 | 9µ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 # spent 9µs making 1 call to Foswiki::Request::BEGIN@32 |
33 | 1 | 10µs | our @ISA = ('CGI'); | ||
34 | |||||
35 | 2 | 42µs | 2 | 87µ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 # spent 51µs making 1 call to Foswiki::Request::BEGIN@35
# spent 36µs making 1 call to Assert::import |
36 | 2 | 36µs | 1 | 9µ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 # spent 9µs making 1 call to Foswiki::Request::BEGIN@36 |
37 | 2 | 178µs | 1 | 11.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 # spent 11.3ms making 1 call to Foswiki::Request::BEGIN@37 |
38 | 2 | 3.56ms | 2 | 142µ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 # 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 | |||||
44 | Constructs 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 | ||||
54 | 7 | 47µ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 | |||||
97 | Gets/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 | ||||
102 | 17 | 78µ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 | |||||
121 | Get the first action ever set in this request object. This remains | ||||
122 | unchanged even if a request cache is unwrapped on to of this request. | ||||
123 | The idea is that callers can always find out the action that initiated | ||||
124 | the HTTP request. This is required for (for example) checking access | ||||
125 | controls. | ||||
126 | |||||
127 | =cut | ||||
128 | |||||
129 | sub 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 | |||||
140 | Sets/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 | ||||
145 | 4 | 40µs | return @_ == 1 ? $_[0]->{method} : ( $_[0]->{method} = $_[1] ); | ||
146 | } | ||||
147 | |||||
148 | =begin TML | ||||
149 | |||||
150 | ---++ ObjectMethod pathInfo( [ $path ] ) -> $path | ||||
151 | |||||
152 | Sets/Gets request path info. | ||||
153 | |||||
154 | Called without parameters returns current pathInfo. | ||||
155 | |||||
156 | There is a =path_info()= alias for compatibility with CGI. | ||||
157 | |||||
158 | =cut | ||||
159 | |||||
160 | 1 | 3µ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 | ||||
163 | 6 | 84µs | return @_ == 1 ? $_[0]->{path_info} : ( $_[0]->{path_info} = $_[1] ); | ||
164 | } | ||||
165 | |||||
166 | =begin TML | ||||
167 | |||||
168 | ---++ ObjectMethod protocol() -> $protocol | ||||
169 | |||||
170 | Returns '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 | ||||
176 | 2 | 23µs | 2 | 9µ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 | |||||
183 | Gets/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 | ||||
188 | 2 | 21µs | return @_ == 1 ? $_[0]->{uri} : ( $_[0]->{uri} = $_[1] ); | ||
189 | } | ||||
190 | |||||
191 | =begin TML | ||||
192 | |||||
193 | ---++ ObjectMethod queryString() -> $query_string | ||||
194 | |||||
195 | Returns query_string part of request uri, if any. | ||||
196 | |||||
197 | =query_string()= alias provided for compatibility with CGI. | ||||
198 | |||||
199 | =cut | ||||
200 | |||||
201 | 1 | 2µ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 | ||||
204 | 24 | 134µs | my $this = shift; | ||
205 | my @params; | ||||
206 | 6 | 277µ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 | |||||
224 | Returns 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 | |||||
233 | Reasonably 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 | ||||
239 | 54 | 305µs | my ( $this, @p ) = @_; | ||
240 | |||||
241 | 3 | 365µ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 ); | ||||
250 | 3 | 49µ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 | } | ||||
265 | 3 | 14µs | $name =~ s(//+)(/)g; # spent 14µs making 3 calls to Foswiki::Request::CORE:subst, avg 5µs/call | ||
266 | if ($full) { | ||||
267 | 4 | 244µ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 | ||
268 | 2 | 38µ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; | ||||
280 | 3 | 185µ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 | |||||
290 | Gets/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 | ||||
295 | 4 | 39µs | return @_ == 1 ? $_[0]->{secure} : ( $_[0]->{secure} = $_[1] ); | ||
296 | } | ||||
297 | |||||
298 | =begin TML | ||||
299 | |||||
300 | ---++ ObjectMethod remoteAddress( [$ip] ) -> $ip | ||||
301 | |||||
302 | Gets/Sets client IP address. | ||||
303 | |||||
304 | =remote_addr()= alias for compatibility with CGI. | ||||
305 | |||||
306 | =cut | ||||
307 | |||||
308 | 1 | 2µ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 | ||||
311 | 3 | 89µs | return @_ == 1 | ||
312 | ? $_[0]->{remote_address} | ||||
313 | : ( $_[0]->{remote_address} = $_[1] ); | ||||
314 | } | ||||
315 | |||||
316 | =begin TML | ||||
317 | |||||
318 | ---++ ObjectMethod remoteUser( [$userName] ) -> $userName | ||||
319 | |||||
320 | Gets/Sets remote user's name. | ||||
321 | |||||
322 | =remote_user()= alias for compatibility with CGI. | ||||
323 | |||||
324 | =cut | ||||
325 | |||||
326 | 1 | 2µ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 | ||||
329 | 1 | 10µs | return @_ == 1 ? $_[0]->{remote_user} : ( $_[0]->{remote_user} = $_[1] ); | ||
330 | } | ||||
331 | |||||
332 | =begin TML | ||||
333 | |||||
334 | ---++ ObjectMethod serverPort( [$userName] ) -> $userName | ||||
335 | |||||
336 | Gets/Sets server user's name. | ||||
337 | |||||
338 | =server_port()= alias for compatibility with CGI. | ||||
339 | |||||
340 | =cut | ||||
341 | |||||
342 | 1 | 2µ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 | ||||
345 | 1 | 10µ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 | |||||
356 | This methos is used by engines, during its prepare phase. Should not be used | ||||
357 | anywhere else. Since bodyParam must exist and it has different semantics from | ||||
358 | param method, this one exists for symmetry, and could be modified in the | ||||
359 | future, so it could be possible to get query and body parameters independently. | ||||
360 | |||||
361 | =cut | ||||
362 | |||||
363 | sub 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 | |||||
377 | Adds parameters passed within request body to the object. Should be called | ||||
378 | only by engines. Otherwise use param() method. | ||||
379 | |||||
380 | =cut | ||||
381 | |||||
382 | sub 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 | |||||
403 | Resonably 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 | ||||
408 | 512 | 2.20ms | my ( $this, @p ) = @_; | ||
409 | |||||
410 | 88 | 2.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 | ||||
443 | 9 | 82µs | eval { require CGI::Cookie; 1 } or throw Error::Simple($@); | ||
444 | my ( $this, @p ) = @_; | ||||
445 | 1 | 47µ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; | ||||
450 | 1 | 2µs | 1 | 294µs | return () unless $this->{cookies}{$name}; # spent 294µs making 1 call to CGI::Cookie::as_string |
451 | 1 | 8µ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 | |||||
465 | ObjectMethod cookies( \%cookies ) -> $hashref | ||||
466 | |||||
467 | Gets/Sets cookies hashref. Keys are cookie names | ||||
468 | and 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 | ||||
473 | 1 | 10µs | return @_ == 1 ? $_[0]->{cookies} : ( $_[0]->{cookies} = $_[1] ); | ||
474 | } | ||||
475 | |||||
476 | =begin TML | ||||
477 | |||||
478 | ---++ ObjectMethod delete( @paramNames ) | ||||
479 | |||||
480 | Deletes parameters from request. | ||||
481 | |||||
482 | =Delete()= alias provided for compatibility with CGI | ||||
483 | |||||
484 | =cut | ||||
485 | |||||
486 | 1 | 2µ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 | ||||
489 | 8 | 41µ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 | |||||
505 | Deletes all parameter name and value(s). | ||||
506 | |||||
507 | =delete_all()= alias provided for compatibility with CGI. | ||||
508 | |||||
509 | =cut | ||||
510 | |||||
511 | 1 | 2µs | *delete_all = \&deleteAll; | ||
512 | |||||
513 | sub 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 | |||||
526 | Gets/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 | ||||
536 | response write method. CGI scripts obtain headers from %ENV | ||||
537 | or =http= method. %ENV is not available and must be replaced | ||||
538 | by calls to this and other methods of this class. =http= is | ||||
539 | provided for compatibility, but is deprecated. Use this one | ||||
540 | instead. | ||||
541 | |||||
542 | Calls to CGI =header= method must be replaced by calls to | ||||
543 | Foswiki::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 | ||||
548 | 145 | 603µs | my ( $this, @p ) = @_; | ||
549 | 17 | 559µ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 | |||||
573 | Saves object state to filehandle. Object may be loaded latter | ||||
574 | passing $fh to new constructor or by calling load(). | ||||
575 | |||||
576 | =cut | ||||
577 | |||||
578 | sub 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 | |||||
596 | Loads object state from filehandle, probably created with | ||||
597 | a previous save(). | ||||
598 | |||||
599 | =cut | ||||
600 | |||||
601 | sub 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 | |||||
628 | Called with file name parameter returns an open filehandle | ||||
629 | to uploaded file. | ||||
630 | |||||
631 | =cut | ||||
632 | |||||
633 | sub 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 | |||||
643 | Returns a hashref to information about uploaded | ||||
644 | files as sent by browser. | ||||
645 | |||||
646 | =cut | ||||
647 | |||||
648 | sub uploadInfo { | ||||
649 | return $_[0]->{uploads}{ $_[1] }->uploadInfo; | ||||
650 | } | ||||
651 | |||||
652 | =begin TML | ||||
653 | |||||
654 | ---++ ObjectMethod tmpFileName( $fname ) -> $tmpFileName | ||||
655 | |||||
656 | Returns 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 | |||||
662 | sub 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 | |||||
673 | Gets/Sets request uploads field. Keys are uploaded file names, | ||||
674 | as 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 | ||||
679 | 1 | 12µ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 | |||||
691 | Called without parameters returns a list of all available header filed names. | ||||
692 | |||||
693 | Given a field name returns value associated. | ||||
694 | |||||
695 | http('HTTP_USER_AGENT'); http('User-Agent') and http('User_Agent') | ||||
696 | are equivalent. | ||||
697 | |||||
698 | Please, use =header()= instead. Present only for compatibility with CGI. | ||||
699 | |||||
700 | =cut | ||||
701 | |||||
702 | sub 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 | |||||
715 | Similar to =http()= method above. Called with no parameters returns | ||||
716 | secure flag. | ||||
717 | |||||
718 | Please, use =header()= and =secure()= instead. | ||||
719 | Present only for compatibility with CGI. | ||||
720 | |||||
721 | =cut | ||||
722 | |||||
723 | sub 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 | |||||
732 | Convenience method to get User-Agent string. | ||||
733 | |||||
734 | =user_agent()= alias provided for compatibility with CGI. | ||||
735 | |||||
736 | =cut | ||||
737 | |||||
738 | 1 | 2µs | *user_agent = \&userAgent; | ||
739 | |||||
740 | 2 | 47µs | 2 | 259µ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 # spent 259µs making 2 calls to Foswiki::Request::header, avg 129µs/call |
741 | |||||
742 | =begin TML | ||||
743 | |||||
744 | ---++ ObjectMethod referer() | ||||
745 | |||||
746 | Convenience method to get Referer uri. | ||||
747 | |||||
748 | =cut | ||||
749 | |||||
750 | sub referer { shift->header('Referer') } | ||||
751 | |||||
752 | 1 | 14µs | 1; | ||
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 |