← Index
NYTProf Performance Profile   « block view • line view • sub view »
For ddd2.pl
  Run on Tue May 25 16:52:24 2010
Reported on Tue May 25 16:57:00 2010

File /project/perl/lib/HTTP/Status.pm
Statements Executed 1081
Statement Execution Time 19.9ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
461117.27ms7.27msHTTP::Status::::is_successHTTP::Status::is_success
461116.74ms6.74msHTTP::Status::::status_messageHTTP::Status::status_message
461123.17ms3.17msHTTP::Status::::RC_MOVED_PERMANENTLYHTTP::Status::RC_MOVED_PERMANENTLY (xsub)
461122.79ms2.79msHTTP::Status::::RC_FOUNDHTTP::Status::RC_FOUND (xsub)
461122.75ms2.75msHTTP::Status::::RC_PROXY_AUTHENTICATION_REQUIREDHTTP::Status::RC_PROXY_AUTHENTICATION_REQUIRED (xsub)
461122.72ms2.72msHTTP::Status::::RC_SEE_OTHERHTTP::Status::RC_SEE_OTHER (xsub)
461122.66ms2.66msHTTP::Status::::RC_TEMPORARY_REDIRECTHTTP::Status::RC_TEMPORARY_REDIRECT (xsub)
461122.64ms2.64msHTTP::Status::::RC_UNAUTHORIZEDHTTP::Status::RC_UNAUTHORIZED (xsub)
11221µs21µsHTTP::Status::::CORE:matchHTTP::Status::CORE:match (opcode)
0000s0sHTTP::Status::::BEGINHTTP::Status::BEGIN
0000s0sHTTP::Status::::is_client_errorHTTP::Status::is_client_error
0000s0sHTTP::Status::::is_errorHTTP::Status::is_error
0000s0sHTTP::Status::::is_infoHTTP::Status::is_info
0000s0sHTTP::Status::::is_redirectHTTP::Status::is_redirect
0000s0sHTTP::Status::::is_server_errorHTTP::Status::is_server_error
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package HTTP::Status;
2
3# $Id: Status.pm,v 1.28 2003/10/23 18:56:01 uid39246 Exp $
4
53117µs126µsuse strict;
# spent 26µs making 1 call to strict::import
615µsrequire 5.002; # becase we use prototypes
7
831.08ms1397µsuse vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
# spent 397µs making 1 call to vars::import
9
10126µsrequire Exporter;
11111µs@ISA = qw(Exporter);
1219µs@EXPORT = qw(is_info is_success is_redirect is_error status_message);
1317µs@EXPORT_OK = qw(is_client_error is_server_error);
14160µs121µs$VERSION = sprintf("%d.%02d", q$Revision: 1.28 $ =~ /(\d+)\.(\d+)/);
# spent 21µs making 1 call to HTTP::Status::CORE:match
15
16# Note also addition of mnemonics to @EXPORT below
17
18179µsmy %StatusCode = (
19 100 => 'Continue',
20 101 => 'Switching Protocols',
21 102 => 'Processing', # WebDAV
22 200 => 'OK',
23 201 => 'Created',
24 202 => 'Accepted',
25 203 => 'Non-Authoritative Information',
26 204 => 'No Content',
27 205 => 'Reset Content',
28 206 => 'Partial Content',
29 207 => 'Multi-Status', # WebDAV
30 300 => 'Multiple Choices',
31 301 => 'Moved Permanently',
32 302 => 'Found',
33 303 => 'See Other',
34 304 => 'Not Modified',
35 305 => 'Use Proxy',
36 307 => 'Temporary Redirect',
37 400 => 'Bad Request',
38 401 => 'Unauthorized',
39 402 => 'Payment Required',
40 403 => 'Forbidden',
41 404 => 'Not Found',
42 405 => 'Method Not Allowed',
43 406 => 'Not Acceptable',
44 407 => 'Proxy Authentication Required',
45 408 => 'Request Timeout',
46 409 => 'Conflict',
47 410 => 'Gone',
48 411 => 'Length Required',
49 412 => 'Precondition Failed',
50 413 => 'Request Entity Too Large',
51 414 => 'Request-URI Too Large',
52 415 => 'Unsupported Media Type',
53 416 => 'Request Range Not Satisfiable',
54 417 => 'Expectation Failed',
55 422 => 'Unprocessable Entity', # WebDAV
56 423 => 'Locked', # WebDAV
57 424 => 'Failed Dependency', # WebDAV
58 500 => 'Internal Server Error',
59 501 => 'Not Implemented',
60 502 => 'Bad Gateway',
61 503 => 'Service Unavailable',
62 504 => 'Gateway Timeout',
63 505 => 'HTTP Version Not Supported',
64 507 => 'Insufficient Storage', # WebDAV
65);
66
6715µsmy $mnemonicCode = '';
6815µsmy ($code, $message);
69114µswhile (($code, $message) = each %StatusCode) {
70 # create mnemonic subroutines
7146224µs $message =~ tr/a-z \-/A-Z__/;
7246263µs $mnemonicCode .= "sub RC_$message () { $code }\t";
73 # make them exportable
7446533µs $mnemonicCode .= "push(\@EXPORT, 'RC_$message');\n";
75}
76# warn $mnemonicCode; # for development
7711.82mseval $mnemonicCode; # only one eval for speed
7815µsdie if $@;
79
80# backwards compatibility
81111µs*RC_MOVED_TEMPORARILY = \&RC_FOUND; # 302 was renamed in the standard
8217µspush(@EXPORT, "RC_MOVED_TEMPORARILY");
83
84
854617.22ms
# spent 6.74ms within HTTP::Status::status_message which was called 461 times, avg 15µs/call: # 461 times (6.74ms+0s) by LWP::UserAgent::request at line 287 of LWP/UserAgent.pm, avg 15µs/call
sub status_message ($) { $StatusCode{$_[0]}; }
86
87sub is_info ($) { $_[0] >= 100 && $_[0] < 200; }
884618.39ms
# spent 7.27ms within HTTP::Status::is_success which was called 461 times, avg 16µs/call: # 461 times (7.27ms+0s) by HTTP::Response::is_success at line 117 of HTTP/Response.pm, avg 16µs/call
sub is_success ($) { $_[0] >= 200 && $_[0] < 300; }
89sub is_redirect ($) { $_[0] >= 300 && $_[0] < 400; }
90sub is_error ($) { $_[0] >= 400 && $_[0] < 600; }
91sub is_client_error ($) { $_[0] >= 400 && $_[0] < 500; }
92sub is_server_error ($) { $_[0] >= 500 && $_[0] < 600; }
93
94156µs1;
95
96
97__END__
98
99=head1 NAME
100
101HTTP::Status - HTTP Status code processing
102
103=head1 SYNOPSIS
104
105 use HTTP::Status;
106
107 if ($rc != RC_OK) {
108 print status_message($rc), "\n";
109 }
110
111 if (is_success($rc)) { ... }
112 if (is_error($rc)) { ... }
113 if (is_redirect($rc)) { ... }
114
115=head1 DESCRIPTION
116
117I<HTTP::Status> is a library of routines for defining and
118classifying HTTP status codes for libwww-perl. Status codes are
119used to encode the overall outcome of a HTTP response message. Codes
120correspond to those defined in RFC 2616 and RFC 2518.
121
122=head1 CONSTANTS
123
124The following constant functions can be used as mnemonic status code
125names:
126
127 RC_CONTINUE (100)
128 RC_SWITCHING_PROTOCOLS (101)
129 RC_PROCESSING (102)
130
131 RC_OK (200)
132 RC_CREATED (201)
133 RC_ACCEPTED (202)
134 RC_NON_AUTHORITATIVE_INFORMATION (203)
135 RC_NO_CONTENT (204)
136 RC_RESET_CONTENT (205)
137 RC_PARTIAL_CONTENT (206)
138 RC_MULTI_STATUS (207)
139
140 RC_MULTIPLE_CHOICES (300)
141 RC_MOVED_PERMANENTLY (301)
142 RC_FOUND (302)
143 RC_SEE_OTHER (303)
144 RC_NOT_MODIFIED (304)
145 RC_USE_PROXY (305)
146 RC_TEMPORARY_REDIRECT (307)
147
148 RC_BAD_REQUEST (400)
149 RC_UNAUTHORIZED (401)
150 RC_PAYMENT_REQUIRED (402)
151 RC_FORBIDDEN (403)
152 RC_NOT_FOUND (404)
153 RC_METHOD_NOT_ALLOWED (405)
154 RC_NOT_ACCEPTABLE (406)
155 RC_PROXY_AUTHENTICATION_REQUIRED (407)
156 RC_REQUEST_TIMEOUT (408)
157 RC_CONFLICT (409)
158 RC_GONE (410)
159 RC_LENGTH_REQUIRED (411)
160 RC_PRECONDITION_FAILED (412)
161 RC_REQUEST_ENTITY_TOO_LARGE (413)
162 RC_REQUEST_URI_TOO_LARGE (414)
163 RC_UNSUPPORTED_MEDIA_TYPE (415)
164 RC_REQUEST_RANGE_NOT_SATISFIABLE (416)
165 RC_EXPECTATION_FAILED (417)
166 RC_UNPROCESSABLE_ENTITY (422)
167 RC_LOCKED (423)
168 RC_FAILED_DEPENDENCY (424)
169
170 RC_INTERNAL_SERVER_ERROR (500)
171 RC_NOT_IMPLEMENTED (501)
172 RC_BAD_GATEWAY (502)
173 RC_SERVICE_UNAVAILABLE (503)
174 RC_GATEWAY_TIMEOUT (504)
175 RC_HTTP_VERSION_NOT_SUPPORTED (505)
176 RC_INSUFFICIENT_STORAGE (507)
177
178=head1 FUNCTIONS
179
180The following additional functions are provided. Most of them are
181exported by default.
182
183=over 4
184
185=item status_message( $code )
186
187The status_message() function will translate status codes to human
188readable strings. The string is the same as found in the constant
189names above. If the $code is unknown, then C<undef> is returned.
190
191=item is_info( $code )
192
193Return TRUE if C<$code> is an I<Informational> status code. This
194class of status code indicates a provisional response which can't have
195any content.
196
197=item is_success( $code )
198
199Return TRUE if C<$code> is a I<Successful> status code.
200
201=item is_redirect( $code )
202
203Return TRUE if C<$code> is a I<Redirection> status code. This class of
204status code indicates that further action needs to be taken by the
205user agent in order to fulfill the request.
206
207=item is_error( $code )
208
209Return TRUE if C<$code> is an I<Error> status code. The function
210return TRUE for both client error or a server error status codes.
211
212=item is_client_error( $code )
213
214Return TRUE if C<$code> is an I<Client Error> status code. This class
215of status code is intended for cases in which the client seems to have
216erred.
217
218This function is B<not> exported by default.
219
220=item is_server_error( $code )
221
222Return TRUE if C<$code> is an I<Server Error> status code. This class
223of status codes is intended for cases in which the server is aware
224that it has erred or is incapable of performing the request.
225
226This function is B<not> exported by default.
227
228=back
229
230=head1 BUGS
231
232Wished @EXPORT_OK had been used instead of @EXPORT in the beginning.
233Now too much is exported by default.
234
# spent 21µs within HTTP::Status::CORE:match which was called # once (21µs+0s) by HTTP::Response::BEGIN at line 14 of HTTP/Status.pm
sub HTTP::Status::CORE:match; # xsub
# spent 2.79ms within HTTP::Status::RC_FOUND which was called 461 times, avg 6µs/call: # 461 times (2.79ms+0s) by LWP::UserAgent::request at line 291 of LWP/UserAgent.pm, avg 6µs/call
sub HTTP::Status::RC_FOUND; # xsub
# spent 3.17ms within HTTP::Status::RC_MOVED_PERMANENTLY which was called 461 times, avg 7µs/call: # 461 times (3.17ms+0s) by LWP::UserAgent::request at line 291 of LWP/UserAgent.pm, avg 7µs/call
sub HTTP::Status::RC_MOVED_PERMANENTLY; # xsub
# spent 2.75ms within HTTP::Status::RC_PROXY_AUTHENTICATION_REQUIRED which was called 461 times, avg 6µs/call: # 461 times (2.75ms+0s) by LWP::UserAgent::request at line 291 of LWP/UserAgent.pm, avg 6µs/call
sub HTTP::Status::RC_PROXY_AUTHENTICATION_REQUIRED; # xsub
# spent 2.72ms within HTTP::Status::RC_SEE_OTHER which was called 461 times, avg 6µs/call: # 461 times (2.72ms+0s) by LWP::UserAgent::request at line 291 of LWP/UserAgent.pm, avg 6µs/call
sub HTTP::Status::RC_SEE_OTHER; # xsub
# spent 2.66ms within HTTP::Status::RC_TEMPORARY_REDIRECT which was called 461 times, avg 6µs/call: # 461 times (2.66ms+0s) by LWP::UserAgent::request at line 291 of LWP/UserAgent.pm, avg 6µs/call
sub HTTP::Status::RC_TEMPORARY_REDIRECT; # xsub
# spent 2.64ms within HTTP::Status::RC_UNAUTHORIZED which was called 461 times, avg 6µs/call: # 461 times (2.64ms+0s) by LWP::UserAgent::request at line 291 of LWP/UserAgent.pm, avg 6µs/call
sub HTTP::Status::RC_UNAUTHORIZED; # xsub