Overview
The HTTP Status Helper provides constants and utility functions for working with HTTP status codes. It includes status code constants, validation helpers, and human-readable status messages.Status Code Constants
TheHTTP_STATUS object provides constants for common HTTP status codes:
2xx Success
3xx Redirection
4xx Client Errors
5xx Server Errors
Functions
isSuccess
Check if a status code indicates success (2xx).status- HTTP status code to check
true if status is in the 2xx range
Example:
isRedirect
Check if a status code indicates redirection (3xx).status- HTTP status code to check
true if status is in the 3xx range
Example:
isClientError
Check if a status code indicates a client error (4xx).status- HTTP status code to check
true if status is in the 4xx range
Example:
isServerError
Check if a status code indicates a server error (5xx).status- HTTP status code to check
true if status is in the 5xx range
Example:
isError
Check if a status code indicates any error (4xx or 5xx).status- HTTP status code to check
true if status is in the 4xx or 5xx range
Example:
getStatusMessage
Get a human-readable message for a status code.status- HTTP status code
getStatusCategory
Get the category name for a status code.status- HTTP status code
isRetryable
Check if a status code indicates a retryable error.status- HTTP status code to check
true if the request should be retried
Retryable Status Codes:
- 408 (Request Timeout)
- 429 (Too Many Requests)
- 500 (Internal Server Error)
- 502 (Bad Gateway)
- 503 (Service Unavailable)
- 504 (Gateway Timeout)
isCacheable
Check if a status code indicates the response is cacheable.status- HTTP status code to check
true if the response can be cached
Cacheable Status Codes:
- 200 (OK)
- 203 (Non-Authoritative Information)
- 204 (No Content)
- 206 (Partial Content)
- 300 (Multiple Choices)
- 301 (Moved Permanently)
- 404 (Not Found)
- 405 (Method Not Allowed)
- 410 (Gone)
- 414 (URI Too Long)
- 501 (Not Implemented)