HTTP::Status

This module provides methods to determine the type of a response code. It also exports a list of mnemonics that can be used by the programmer to refer to a status code.

The following methods are used on response objects:

is_info

Returns true when the response code is 100-199.

is_success

Returns true when the response code is 200-299.

is_redirect

Returns true when the response code is 300-399.

is_client_error

Returns true when the response code is 400-499.

is_server_error

Returns true when the response code is 500-599.

is_error

Returns true when the response code is 400-599. When an error occurs, you might want to use error_as_HTML to generate an HTML explanation of the error.

HTTP::Status exports the following constant functions to use as mnemonic substitutes for status codes. For example, you could do something like:

if ($rc = RC_OK) {....}

Here are the mnemonics, followed by the status codes they represent:

RC_CONTINUE (100) RC_SWITCHING_PROTOCOLS (101) RC_OK (200) RC_CREATED (201) RC_ACCEPTED (202) RC_NON_AUTHORITATIVE_INFORMATION (203) RC_NO_CONTENT (204) RC_RESET_CONTENT (205) RC_PARTIAL_CONTENT (206) RC_MULTIPLE_CHOICES (300) RC_MOVED_PERMANENTLY (301) RC_MOVED_TEMPORARILY (302) RC_SEE_OTHER (303) RC_NOT_MODIFIED (304) RC_USE_PROXY (305) RC_BAD_REQUEST (400) RC_UNAUTHORIZED (401) RC_PAYMENT_REQUIRED (402) RC_FORBIDDEN (403) RC_NOT_FOUND (404) RC_METHOD_NOT_ALLOWED (405) RC_NOT_ACCEPTABLE (406) RC_PROXY_AUTHENTICATION_REQUIRED (407) RC_REQUEST_TIMEOUT (408) RC_CONFLICT (409) RC_GONE ...

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.