1HTTP::Status(3) User Contributed Perl Documentation HTTP::Status(3)
2
3
4
6 HTTP::Status - HTTP Status code processing
7
9 version 6.18
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_REQUEST_ENTITY_TOO_LARGE (413)
73 HTTP_REQUEST_URI_TOO_LARGE (414)
74 HTTP_UNSUPPORTED_MEDIA_TYPE (415)
75 HTTP_REQUEST_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_UPGRADE_REQUIRED (426)
82 HTTP_PRECONDITION_REQUIRED (428)
83 HTTP_TOO_MANY_REQUESTS (429)
84 HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE (431)
85 HTTP_UNAVAILABLE_FOR_LEGAL_REASONS (451)
86
87 HTTP_INTERNAL_SERVER_ERROR (500)
88 HTTP_NOT_IMPLEMENTED (501)
89 HTTP_BAD_GATEWAY (502)
90 HTTP_SERVICE_UNAVAILABLE (503)
91 HTTP_GATEWAY_TIMEOUT (504)
92 HTTP_HTTP_VERSION_NOT_SUPPORTED (505)
93 HTTP_VARIANT_ALSO_NEGOTIATES (506)
94 HTTP_INSUFFICIENT_STORAGE (507)
95 HTTP_LOOP_DETECTED (508)
96 HTTP_NOT_EXTENDED (510)
97 HTTP_NETWORK_AUTHENTICATION_REQUIRED (511)
98
100 The following additional functions are provided. Most of them are
101 exported by default. The ":is" import tag can be used to import all
102 the classification functions.
103
104 status_message( $code )
105 The status_message() function will translate status codes to human
106 readable strings. The string is the same as found in the constant
107 names above. If the $code is not registered in the list of IANA
108 HTTP Status Codes <https://www.iana.org/assignments/http-status-
109 codes/http-status-codes.xhtml> then "undef" is returned.
110
111 is_info( $code )
112 Return TRUE if $code is an Informational status code (1xx). This
113 class of status code indicates a provisional response which can't
114 have any content.
115
116 is_success( $code )
117 Return TRUE if $code is a Successful status code (2xx).
118
119 is_redirect( $code )
120 Return TRUE if $code is a Redirection status code (3xx). This class
121 of status code indicates that further action needs to be taken by
122 the user agent in order to fulfill the request.
123
124 is_error( $code )
125 Return TRUE if $code is an Error status code (4xx or 5xx). The
126 function returns TRUE for both client and server error status
127 codes.
128
129 is_client_error( $code )
130 Return TRUE if $code is a Client Error status code (4xx). This
131 class of status code is intended for cases in which the client
132 seems to have erred.
133
134 This function is not exported by default.
135
136 is_server_error( $code )
137 Return TRUE if $code is a Server Error status code (5xx). This
138 class of status codes is intended for cases in which the server is
139 aware that it has erred or is incapable of performing the request.
140
141 This function is not exported by default.
142
143 is_cacheable_by_default( $code )
144 Return TRUE if $code indicates that a response is cacheable by
145 default, and it can be reused by a cache with heuristic expiration.
146 All other status codes are not cacheable by default. See RFC 7231 -
147 HTTP/1.1 Semantics and Content, Section 6.1. Overview of Status
148 Codes <https://tools.ietf.org/html/rfc7231#section-6.1>.
149
150 This function is not exported by default.
151
153 IANA HTTP Status Codes <https://www.iana.org/assignments/http-status-
154 codes/http-status-codes.xhtml>
155
157 For legacy reasons all the "HTTP_" constants are exported by default
158 with the prefix "RC_". It's recommended to use explicit imports and
159 the ":constants" tag instead of relying on this.
160
162 Gisle Aas <gisle@activestate.com>
163
165 This software is copyright (c) 1994-2017 by Gisle Aas.
166
167 This is free software; you can redistribute it and/or modify it under
168 the same terms as the Perl 5 programming language system itself.
169
170
171
172perl v5.26.3 2018-06-05 HTTP::Status(3)