1HTTP::Status(3) User Contributed Perl Documentation HTTP::Status(3)
2
3
4
6 HTTP::Status - HTTP Status code processing
7
9 version 6.37
10
12 use HTTP::Status qw(:constants :is status_message);
13
14 if ($rc != HTTP_OK) {
15 print status_message($rc), "\n";
16 }
17
18 if (is_success($rc)) { ... }
19 if (is_error($rc)) { ... }
20 if (is_redirect($rc)) { ... }
21
23 HTTP::Status is a library of routines for defining and classifying HTTP
24 status codes for libwww-perl. Status codes are used to encode the
25 overall outcome of an HTTP response message. Codes correspond to those
26 defined in RFC 2616 and RFC 2518.
27
29 The following constant functions can be used as mnemonic status code
30 names. None of these are exported by default. Use the ":constants"
31 tag to import them all.
32
33 HTTP_CONTINUE (100)
34 HTTP_SWITCHING_PROTOCOLS (101)
35 HTTP_PROCESSING (102)
36 HTTP_EARLY_HINTS (103)
37
38 HTTP_OK (200)
39 HTTP_CREATED (201)
40 HTTP_ACCEPTED (202)
41 HTTP_NON_AUTHORITATIVE_INFORMATION (203)
42 HTTP_NO_CONTENT (204)
43 HTTP_RESET_CONTENT (205)
44 HTTP_PARTIAL_CONTENT (206)
45 HTTP_MULTI_STATUS (207)
46 HTTP_ALREADY_REPORTED (208)
47
48 HTTP_IM_USED (226)
49
50 HTTP_MULTIPLE_CHOICES (300)
51 HTTP_MOVED_PERMANENTLY (301)
52 HTTP_FOUND (302)
53 HTTP_SEE_OTHER (303)
54 HTTP_NOT_MODIFIED (304)
55 HTTP_USE_PROXY (305)
56 HTTP_TEMPORARY_REDIRECT (307)
57 HTTP_PERMANENT_REDIRECT (308)
58
59 HTTP_BAD_REQUEST (400)
60 HTTP_UNAUTHORIZED (401)
61 HTTP_PAYMENT_REQUIRED (402)
62 HTTP_FORBIDDEN (403)
63 HTTP_NOT_FOUND (404)
64 HTTP_METHOD_NOT_ALLOWED (405)
65 HTTP_NOT_ACCEPTABLE (406)
66 HTTP_PROXY_AUTHENTICATION_REQUIRED (407)
67 HTTP_REQUEST_TIMEOUT (408)
68 HTTP_CONFLICT (409)
69 HTTP_GONE (410)
70 HTTP_LENGTH_REQUIRED (411)
71 HTTP_PRECONDITION_FAILED (412)
72 HTTP_PAYLOAD_TOO_LARGE (413)
73 HTTP_URI_TOO_LONG (414)
74 HTTP_UNSUPPORTED_MEDIA_TYPE (415)
75 HTTP_RANGE_NOT_SATISFIABLE (416)
76 HTTP_EXPECTATION_FAILED (417)
77 HTTP_MISDIRECTED REQUEST (421)
78 HTTP_UNPROCESSABLE_ENTITY (422)
79 HTTP_LOCKED (423)
80 HTTP_FAILED_DEPENDENCY (424)
81 HTTP_TOO_EARLY (425)
82 HTTP_UPGRADE_REQUIRED (426)
83 HTTP_PRECONDITION_REQUIRED (428)
84 HTTP_TOO_MANY_REQUESTS (429)
85 HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE (431)
86 HTTP_UNAVAILABLE_FOR_LEGAL_REASONS (451)
87
88 HTTP_INTERNAL_SERVER_ERROR (500)
89 HTTP_NOT_IMPLEMENTED (501)
90 HTTP_BAD_GATEWAY (502)
91 HTTP_SERVICE_UNAVAILABLE (503)
92 HTTP_GATEWAY_TIMEOUT (504)
93 HTTP_HTTP_VERSION_NOT_SUPPORTED (505)
94 HTTP_VARIANT_ALSO_NEGOTIATES (506)
95 HTTP_INSUFFICIENT_STORAGE (507)
96 HTTP_LOOP_DETECTED (508)
97 HTTP_NOT_EXTENDED (510)
98 HTTP_NETWORK_AUTHENTICATION_REQUIRED (511)
99
101 The following additional functions are provided. Most of them are
102 exported by default. The ":is" import tag can be used to import all
103 the classification functions.
104
105 status_message( $code )
106 The status_message() function will translate status codes to human
107 readable strings. The string is the same as found in the constant
108 names above. If the $code is not registered in the list of IANA
109 HTTP Status Codes <https://www.iana.org/assignments/http-status-
110 codes/http-status-codes.xhtml> then "undef" is returned.
111
112 is_info( $code )
113 Return TRUE if $code is an Informational status code (1xx). This
114 class of status code indicates a provisional response which can't
115 have any content.
116
117 is_success( $code )
118 Return TRUE if $code is a Successful status code (2xx).
119
120 is_redirect( $code )
121 Return TRUE if $code is a Redirection status code (3xx). This class
122 of status code indicates that further action needs to be taken by
123 the user agent in order to fulfill the request.
124
125 is_error( $code )
126 Return TRUE if $code is an Error status code (4xx or 5xx). The
127 function returns TRUE for both client and server error status
128 codes.
129
130 is_client_error( $code )
131 Return TRUE if $code is a Client Error status code (4xx). This
132 class of status code is intended for cases in which the client
133 seems to have erred.
134
135 This function is not exported by default.
136
137 is_server_error( $code )
138 Return TRUE if $code is a Server Error status code (5xx). This
139 class of status codes is intended for cases in which the server is
140 aware that it has erred or is incapable of performing the request.
141
142 This function is not exported by default.
143
144 is_cacheable_by_default( $code )
145 Return TRUE if $code indicates that a response is cacheable by
146 default, and it can be reused by a cache with heuristic expiration.
147 All other status codes are not cacheable by default. See RFC 7231 -
148 HTTP/1.1 Semantics and Content, Section 6.1. Overview of Status
149 Codes <https://tools.ietf.org/html/rfc7231#section-6.1>.
150
151 This function is not exported by default.
152
154 IANA HTTP Status Codes <https://www.iana.org/assignments/http-status-
155 codes/http-status-codes.xhtml>
156
158 For legacy reasons all the "HTTP_" constants are exported by default
159 with the prefix "RC_". It's recommended to use explicit imports and
160 the ":constants" tag instead of relying on this.
161
163 Gisle Aas <gisle@activestate.com>
164
166 This software is copyright (c) 1994 by Gisle Aas.
167
168 This is free software; you can redistribute it and/or modify it under
169 the same terms as the Perl 5 programming language system itself.
170
171
172
173perl v5.36.0 2022-08-17 HTTP::Status(3)