Profile of /usr/local/lib/perl5/site_perl/5.10.1/HTTP/Status.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:19 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/HTTP/Status.pm
Statements Executed | 323
Statement Execution Time | 2.80ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
41 | 1 | 1 | 160µs | 160µs | HTTP::Status::::is_successHTTP::Status::is_success
41 | 1 | 2 | 101µs | 101µs | HTTP::Status::::HTTP_MOVED_PERMANENTLYHTTP::Status::HTTP_MOVED_PERMANENTLY (xsub)
41 | 1 | 2 | 68µs | 68µs | HTTP::Status::::HTTP_PROXY_AUTHENTICATION_REQUIREDHTTP::Status::HTTP_PROXY_AUTHENTICATION_REQUIRED (xsub)
41 | 1 | 2 | 61µs | 61µs | HTTP::Status::::HTTP_FOUNDHTTP::Status::HTTP_FOUND (xsub)
41 | 1 | 2 | 61µs | 61µs | HTTP::Status::::HTTP_TEMPORARY_REDIRECTHTTP::Status::HTTP_TEMPORARY_REDIRECT (xsub)
41 | 1 | 2 | 59µs | 59µs | HTTP::Status::::HTTP_UNAUTHORIZEDHTTP::Status::HTTP_UNAUTHORIZED (xsub)
41 | 1 | 2 | 55µs | 55µs | HTTP::Status::::HTTP_SEE_OTHERHTTP::Status::HTTP_SEE_OTHER (xsub)
166 | 1 | 2 | 31µs | 31µs | HTTP::Status::::CORE:matchHTTP::Status::CORE:match (opcode)
1 | 1 | 1 | 14µs | 16µs | HTTP::Status::::BEGIN@3HTTP::Status::BEGIN@3
1 | 1 | 1 | 7µs | 65µs | HTTP::Status::::BEGIN@6HTTP::Status::BEGIN@6
0 | 0 | 0 | 0s | 0s | HTTP::Status::::is_client_errorHTTP::Status::is_client_error
0 | 0 | 0 | 0s | 0s | HTTP::Status::::is_errorHTTP::Status::is_error
0 | 0 | 0 | 0s | 0s | HTTP::Status::::is_infoHTTP::Status::is_info
0 | 0 | 0 | 0s | 0s | HTTP::Status::::is_redirectHTTP::Status::is_redirect
0 | 0 | 0 | 0s | 0s | HTTP::Status::::is_server_errorHTTP::Status::is_server_error
0 | 0 | 0 | 0s | 0s | HTTP::Status::::status_messageHTTP::Status::status_message

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package HTTP::Status;
2 |  |  |  |  |
3 | 3 | 28µs | 2 | 19µs | # spent 16µs (14+3) within HTTP::Status::BEGIN@3 which was called # once (14µs+3µs) by HTTP::Response::BEGIN@8 at line 3 use strict; # spent 16µs making 1 call to HTTP::Status::BEGIN@3 # spent 2µs making 1 call to strict::import
4 | 1 | 48µs |  |  | require 5.002; # because we use prototypes
5 |  |  |  |  |
6 | 3 | 390µs | 2 | 123µs | # spent 65µs (7+58) within HTTP::Status::BEGIN@6 which was called # once (7µs+58µs) by HTTP::Response::BEGIN@8 at line 6 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION); # spent 65µs making 1 call to HTTP::Status::BEGIN@6 # spent 58µs making 1 call to vars::import
7 |  |  |  |  |
8 | 1 | 300ns |  |  | require Exporter;
9 | 1 | 6µs |  |  | @ISA = qw(Exporter);
10 | 1 | 1µs |  |  | @EXPORT = qw(is_info is_success is_redirect is_error status_message);
11 | 1 | 500ns |  |  | @EXPORT_OK = qw(is_client_error is_server_error);
12 | 1 | 300ns |  |  | $VERSION = "5.817";
13 |  |  |  |  |
14 |  |  |  |  | # Note also addition of mnemonics to @EXPORT below
15 |  |  |  |  |
16 |  |  |  |  | # Unmarked codes are from RFC 2616
17 |  |  |  |  | # See also: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
18 |  |  |  |  |
19 | 1 | 36µs |  |  | my %StatusCode = (
20 |  |  |  |  | 100 => 'Continue',
21 |  |  |  |  | 101 => 'Switching Protocols',
22 |  |  |  |  | 102 => 'Processing', # RFC 2518 (WebDAV)
23 |  |  |  |  | 200 => 'OK',
24 |  |  |  |  | 201 => 'Created',
25 |  |  |  |  | 202 => 'Accepted',
26 |  |  |  |  | 203 => 'Non-Authoritative Information',
27 |  |  |  |  | 204 => 'No Content',
28 |  |  |  |  | 205 => 'Reset Content',
29 |  |  |  |  | 206 => 'Partial Content',
30 |  |  |  |  | 207 => 'Multi-Status', # RFC 2518 (WebDAV)
31 |  |  |  |  | 300 => 'Multiple Choices',
32 |  |  |  |  | 301 => 'Moved Permanently',
33 |  |  |  |  | 302 => 'Found',
34 |  |  |  |  | 303 => 'See Other',
35 |  |  |  |  | 304 => 'Not Modified',
36 |  |  |  |  | 305 => 'Use Proxy',
37 |  |  |  |  | 307 => 'Temporary Redirect',
38 |  |  |  |  | 400 => 'Bad Request',
39 |  |  |  |  | 401 => 'Unauthorized',
40 |  |  |  |  | 402 => 'Payment Required',
41 |  |  |  |  | 403 => 'Forbidden',
42 |  |  |  |  | 404 => 'Not Found',
43 |  |  |  |  | 405 => 'Method Not Allowed',
44 |  |  |  |  | 406 => 'Not Acceptable',
45 |  |  |  |  | 407 => 'Proxy Authentication Required',
46 |  |  |  |  | 408 => 'Request Timeout',
47 |  |  |  |  | 409 => 'Conflict',
48 |  |  |  |  | 410 => 'Gone',
49 |  |  |  |  | 411 => 'Length Required',
50 |  |  |  |  | 412 => 'Precondition Failed',
51 |  |  |  |  | 413 => 'Request Entity Too Large',
52 |  |  |  |  | 414 => 'Request-URI Too Large',
53 |  |  |  |  | 415 => 'Unsupported Media Type',
54 |  |  |  |  | 416 => 'Request Range Not Satisfiable',
55 |  |  |  |  | 417 => 'Expectation Failed',
56 |  |  |  |  | 422 => 'Unprocessable Entity', # RFC 2518 (WebDAV)
57 |  |  |  |  | 423 => 'Locked', # RFC 2518 (WebDAV)
58 |  |  |  |  | 424 => 'Failed Dependency', # RFC 2518 (WebDAV)
59 |  |  |  |  | 425 => 'No code', # WebDAV Advanced Collections
60 |  |  |  |  | 426 => 'Upgrade Required', # RFC 2817
61 |  |  |  |  | 449 => 'Retry with', # unofficial Microsoft
62 |  |  |  |  | 500 => 'Internal Server Error',
63 |  |  |  |  | 501 => 'Not Implemented',
64 |  |  |  |  | 502 => 'Bad Gateway',
65 |  |  |  |  | 503 => 'Service Unavailable',
66 |  |  |  |  | 504 => 'Gateway Timeout',
67 |  |  |  |  | 505 => 'HTTP Version Not Supported',
68 |  |  |  |  | 506 => 'Variant Also Negotiates', # RFC 2295
69 |  |  |  |  | 507 => 'Insufficient Storage', # RFC 2518 (WebDAV)
70 |  |  |  |  | 509 => 'Bandwidth Limit Exceeded', # unofficial
71 |  |  |  |  | 510 => 'Not Extended', # RFC 2774
72 |  |  |  |  | );
73 |  |  |  |  |
74 | 1 | 300ns |  |  | my $mnemonicCode = '';
75 | 1 | 200ns |  |  | my ($code, $message);
76 | 1 | 2µs |  |  | while (($code, $message) = each %StatusCode) {
77 |  |  |  |  | # create mnemonic subroutines
78 | 52 | 11µs |  |  | $message =~ tr/a-z \-/A-Z__/;
79 | 52 | 28µs |  |  | $mnemonicCode .= "sub HTTP_$message () { $code }\n";
80 | 52 | 22µs |  |  | $mnemonicCode .= "*RC_$message = \\&HTTP_$message;\n"; # legacy
81 | 52 | 16µs |  |  | $mnemonicCode .= "push(\@EXPORT_OK, 'HTTP_$message');\n";
82 | 52 | 36µs |  |  | $mnemonicCode .= "push(\@EXPORT, 'RC_$message');\n";
83 |  |  |  |  | }
84 | 1 | 1.70ms |  |  | eval $mnemonicCode; # only one eval for speed
85 | 1 | 100ns |  |  | die if $@;
86 |  |  |  |  |
87 |  |  |  |  | # backwards compatibility
88 | 1 | 700ns |  |  | *RC_MOVED_TEMPORARILY = \&RC_FOUND; # 302 was renamed in the standard
89 | 1 | 400ns |  |  | push(@EXPORT, "RC_MOVED_TEMPORARILY");
90 |  |  |  |  |
91 | 1 | 206µs | 166 | 31µs | %EXPORT_TAGS = ( # spent 31µs making 166 calls to HTTP::Status::CORE:match, avg 189ns/call
92 |  |  |  |  | constants => [grep /^HTTP_/, @EXPORT_OK],
93 |  |  |  |  | is => [grep /^is_/, @EXPORT, @EXPORT_OK],
94 |  |  |  |  | );
95 |  |  |  |  |
96 |  |  |  |  |
97 |  |  |  |  | sub status_message ($) { $StatusCode{$_[0]}; }
98 |  |  |  |  |
99 |  |  |  |  | sub is_info ($) { $_[0] >= 100 && $_[0] < 200; }
100 | 41 | 210µs |  |  | # spent 160µs within HTTP::Status::is_success which was called 41 times, avg 4µs/call: # 41 times (160µs+0s) by HTTP::Response::is_success at line 215 of HTTP/Response.pm, avg 4µs/call sub is_success ($) { $_[0] >= 200 && $_[0] < 300; }
101 |  |  |  |  | sub is_redirect ($) { $_[0] >= 300 && $_[0] < 400; }
102 |  |  |  |  | sub is_error ($) { $_[0] >= 400 && $_[0] < 600; }
103 |  |  |  |  | sub is_client_error ($) { $_[0] >= 400 && $_[0] < 500; }
104 |  |  |  |  | sub is_server_error ($) { $_[0] >= 500 && $_[0] < 600; }
105 |  |  |  |  |
106 | 1 | 52µs |  |  | 1;
107 |  |  |  |  |
108 |  |  |  |  |
109 |  |  |  |  | __END__
110 |  |  |  |  |
111 |  |  |  |  | =head1 NAME
112 |  |  |  |  |
113 |  |  |  |  | HTTP::Status - HTTP Status code processing
114 |  |  |  |  |
115 |  |  |  |  | =head1 SYNOPSIS
116 |  |  |  |  |
117 |  |  |  |  | use HTTP::Status qw(:constants :is status_message);
118 |  |  |  |  |
119 |  |  |  |  | if ($rc != HTTP_OK) {
120 |  |  |  |  | print status_message($rc), "\n";
121 |  |  |  |  | }
122 |  |  |  |  |
123 |  |  |  |  | if (is_success($rc)) { ... }
124 |  |  |  |  | if (is_error($rc)) { ... }
125 |  |  |  |  | if (is_redirect($rc)) { ... }
126 |  |  |  |  |
127 |  |  |  |  | =head1 DESCRIPTION
128 |  |  |  |  |
129 |  |  |  |  | I<HTTP::Status> is a library of routines for defining and
130 |  |  |  |  | classifying HTTP status codes for libwww-perl. Status codes are
131 |  |  |  |  | used to encode the overall outcome of a HTTP response message. Codes
132 |  |  |  |  | correspond to those defined in RFC 2616 and RFC 2518.
133 |  |  |  |  |
134 |  |  |  |  | =head1 CONSTANTS
135 |  |  |  |  |
136 |  |  |  |  | The following constant functions can be used as mnemonic status code
137 |  |  |  |  | names. None of these are exported by default. Use the C<:constants>
138 |  |  |  |  | tag to import them all.
139 |  |  |  |  |
140 |  |  |  |  | HTTP_CONTINUE (100)
141 |  |  |  |  | HTTP_SWITCHING_PROTOCOLS (101)
142 |  |  |  |  | HTTP_PROCESSING (102)
143 |  |  |  |  |
144 |  |  |  |  | HTTP_OK (200)
145 |  |  |  |  | HTTP_CREATED (201)
146 |  |  |  |  | HTTP_ACCEPTED (202)
147 |  |  |  |  | HTTP_NON_AUTHORITATIVE_INFORMATION (203)
148 |  |  |  |  | HTTP_NO_CONTENT (204)
149 |  |  |  |  | HTTP_RESET_CONTENT (205)
150 |  |  |  |  | HTTP_PARTIAL_CONTENT (206)
151 |  |  |  |  | HTTP_MULTI_STATUS (207)
152 |  |  |  |  |
153 |  |  |  |  | HTTP_MULTIPLE_CHOICES (300)
154 |  |  |  |  | HTTP_MOVED_PERMANENTLY (301)
155 |  |  |  |  | HTTP_FOUND (302)
156 |  |  |  |  | HTTP_SEE_OTHER (303)
157 |  |  |  |  | HTTP_NOT_MODIFIED (304)
158 |  |  |  |  | HTTP_USE_PROXY (305)
159 |  |  |  |  | HTTP_TEMPORARY_REDIRECT (307)
160 |  |  |  |  |
161 |  |  |  |  | HTTP_BAD_REQUEST (400)
162 |  |  |  |  | HTTP_UNAUTHORIZED (401)
163 |  |  |  |  | HTTP_PAYMENT_REQUIRED (402)
164 |  |  |  |  | HTTP_FORBIDDEN (403)
165 |  |  |  |  | HTTP_NOT_FOUND (404)
166 |  |  |  |  | HTTP_METHOD_NOT_ALLOWED (405)
167 |  |  |  |  | HTTP_NOT_ACCEPTABLE (406)
168 |  |  |  |  | HTTP_PROXY_AUTHENTICATION_REQUIRED (407)
169 |  |  |  |  | HTTP_REQUEST_TIMEOUT (408)
170 |  |  |  |  | HTTP_CONFLICT (409)
171 |  |  |  |  | HTTP_GONE (410)
172 |  |  |  |  | HTTP_LENGTH_REQUIRED (411)
173 |  |  |  |  | HTTP_PRECONDITION_FAILED (412)
174 |  |  |  |  | HTTP_REQUEST_ENTITY_TOO_LARGE (413)
175 |  |  |  |  | HTTP_REQUEST_URI_TOO_LARGE (414)
176 |  |  |  |  | HTTP_UNSUPPORTED_MEDIA_TYPE (415)
177 |  |  |  |  | HTTP_REQUEST_RANGE_NOT_SATISFIABLE (416)
178 |  |  |  |  | HTTP_EXPECTATION_FAILED (417)
179 |  |  |  |  | HTTP_UNPROCESSABLE_ENTITY (422)
180 |  |  |  |  | HTTP_LOCKED (423)
181 |  |  |  |  | HTTP_FAILED_DEPENDENCY (424)
182 |  |  |  |  | HTTP_NO_CODE (425)
183 |  |  |  |  | HTTP_UPGRADE_REQUIRED (426)
184 |  |  |  |  | HTTP_RETRY_WITH (449)
185 |  |  |  |  |
186 |  |  |  |  | HTTP_INTERNAL_SERVER_ERROR (500)
187 |  |  |  |  | HTTP_NOT_IMPLEMENTED (501)
188 |  |  |  |  | HTTP_BAD_GATEWAY (502)
189 |  |  |  |  | HTTP_SERVICE_UNAVAILABLE (503)
190 |  |  |  |  | HTTP_GATEWAY_TIMEOUT (504)
191 |  |  |  |  | HTTP_HTTP_VERSION_NOT_SUPPORTED (505)
192 |  |  |  |  | HTTP_VARIANT_ALSO_NEGOTIATES (506)
193 |  |  |  |  | HTTP_INSUFFICIENT_STORAGE (507)
194 |  |  |  |  | HTTP_BANDWIDTH_LIMIT_EXCEEDED (509)
195 |  |  |  |  | HTTP_NOT_EXTENDED (510)
196 |  |  |  |  |
197 |  |  |  |  | =head1 FUNCTIONS
198 |  |  |  |  |
199 |  |  |  |  | The following additional functions are provided. Most of them are
200 |  |  |  |  | exported by default. The C<:is> import tag can be used to import all
201 |  |  |  |  | the classification functions.
202 |  |  |  |  |
203 |  |  |  |  | =over 4
204 |  |  |  |  |
205 |  |  |  |  | =item status_message( $code )
206 |  |  |  |  |
207 |  |  |  |  | The status_message() function will translate status codes to human
208 |  |  |  |  | readable strings. The string is the same as found in the constant
209 |  |  |  |  | names above. If the $code is unknown, then C<undef> is returned.
210 |  |  |  |  |
211 |  |  |  |  | =item is_info( $code )
212 |  |  |  |  |
213 |  |  |  |  | Return TRUE if C<$code> is an I<Informational> status code (1xx). This
214 |  |  |  |  | class of status code indicates a provisional response which can't have
215 |  |  |  |  | any content.
216 |  |  |  |  |
217 |  |  |  |  | =item is_success( $code )
218 |  |  |  |  |
219 |  |  |  |  | Return TRUE if C<$code> is a I<Successful> status code (2xx).
220 |  |  |  |  |
221 |  |  |  |  | =item is_redirect( $code )
222 |  |  |  |  |
223 |  |  |  |  | Return TRUE if C<$code> is a I<Redirection> status code (3xx). This class of
224 |  |  |  |  | status code indicates that further action needs to be taken by the
225 |  |  |  |  | user agent in order to fulfill the request.
226 |  |  |  |  |
227 |  |  |  |  | =item is_error( $code )
228 |  |  |  |  |
229 |  |  |  |  | Return TRUE if C<$code> is an I<Error> status code (4xx or 5xx). The function
230 |  |  |  |  | return TRUE for both client error or a server error status codes.
231 |  |  |  |  |
232 |  |  |  |  | =item is_client_error( $code )
233 |  |  |  |  |
234 |  |  |  |  | Return TRUE if C<$code> is an I<Client Error> status code (4xx). This class
235 |  |  |  |  | of status code is intended for cases in which the client seems to have
236 |  |  |  |  | erred.
237 |  |  |  |  |
238 |  |  |  |  | This function is B<not> exported by default.
239 |  |  |  |  |
240 |  |  |  |  | =item is_server_error( $code )
241 |  |  |  |  |
242 |  |  |  |  | Return TRUE if C<$code> is an I<Server Error> status code (5xx). This class
243 |  |  |  |  | of status codes is intended for cases in which the server is aware
244 |  |  |  |  | that it has erred or is incapable of performing the request.
245 |  |  |  |  |
246 |  |  |  |  | This function is B<not> exported by default.
247 |  |  |  |  |
248 |  |  |  |  | =back
249 |  |  |  |  |
250 |  |  |  |  | =head1 BUGS
251 |  |  |  |  |
252 |  |  |  |  | For legacy reasons all the C<HTTP_> constants are exported by default
253 |  |  |  |  | with the prefix C<RC_>. It's recommended to use explict imports and
254 |  |  |  |  | the C<:constants> tag instead of relying on this.
|  |  |  |  | # spent 31µs within HTTP::Status::CORE:match which was called 166 times, avg 189ns/call: # 166 times (31µs+0s) by HTTP::Response::BEGIN@8 at line 91 of HTTP/Status.pm, avg 189ns/call sub HTTP::Status::CORE:match; # xsub
|  |  |  |  | # spent 61µs within HTTP::Status::HTTP_FOUND which was called 41 times, avg 1µs/call: # 41 times (61µs+0s) by LWP::UserAgent::request at line 276 of LWP/UserAgent.pm, avg 1µs/call sub HTTP::Status::HTTP_FOUND; # xsub
|  |  |  |  | # spent 101µs within HTTP::Status::HTTP_MOVED_PERMANENTLY which was called 41 times, avg 2µs/call: # 41 times (101µs+0s) by LWP::UserAgent::request at line 276 of LWP/UserAgent.pm, avg 2µs/call sub HTTP::Status::HTTP_MOVED_PERMANENTLY; # xsub
|  |  |  |  | # spent 68µs within HTTP::Status::HTTP_PROXY_AUTHENTICATION_REQUIRED which was called 41 times, avg 2µs/call: # 41 times (68µs+0s) by LWP::UserAgent::request at line 276 of LWP/UserAgent.pm, avg 2µs/call sub HTTP::Status::HTTP_PROXY_AUTHENTICATION_REQUIRED; # xsub
|  |  |  |  | # spent 55µs within HTTP::Status::HTTP_SEE_OTHER which was called 41 times, avg 1µs/call: # 41 times (55µs+0s) by LWP::UserAgent::request at line 276 of LWP/UserAgent.pm, avg 1µs/call sub HTTP::Status::HTTP_SEE_OTHER; # xsub
|  |  |  |  | # spent 61µs within HTTP::Status::HTTP_TEMPORARY_REDIRECT which was called 41 times, avg 1µs/call: # 41 times (61µs+0s) by LWP::UserAgent::request at line 276 of LWP/UserAgent.pm, avg 1µs/call sub HTTP::Status::HTTP_TEMPORARY_REDIRECT; # xsub
|  |  |  |  | # spent 59µs within HTTP::Status::HTTP_UNAUTHORIZED which was called 41 times, avg 1µs/call: # 41 times (59µs+0s) by LWP::UserAgent::request at line 276 of LWP/UserAgent.pm, avg 1µs/call sub HTTP::Status::HTTP_UNAUTHORIZED; # xsub