HTTP status codes are standard codes used by web servers to inform the client (such as a browser) about the results of their requests. These codes are defined in the HTTP specifications and are used to identify the status of the requested resource and provide information on what actions need to be taken to complete the request.
History and Purpose
HTTP status codes were introduced in the HTTP specification to provide a standardized way of communication between web servers and clients. These codes help automate error handling, direct further client actions, and provide diagnostic information. They distinguish between successful and unsuccessful requests, redirections, and indicate specific problems.
Structure and Ranges of Status Codes
HTTP status codes are three-digit numbers. The first digit defines the class of the status, indicating the general type of response. There are five classes of statuses:
- 1xx: Informational Responses
- These codes indicate that the request has been received and the process is continuing.
- 2xx: Successful Responses
- These codes indicate that the request was successfully received, understood, and accepted.
- 3xx: Redirection
- These codes indicate that further action needs to be taken by the client to complete the request.
- 4xx: Client Errors
- These codes indicate errors caused by incorrect requests from the client.
- 5xx: Server Errors
- These codes indicate errors caused by failures on the server side.
Detailed Description of Status Codes
1xx: Informational Responses
- 100 Continue: The server has received the initial part of the request, and the client should continue.
- 101 Switching Protocols: The server agrees to switch protocols as requested by the client.
- 102 Processing: The server has accepted the request, but processing is not complete.
2xx: Successful Responses
- 200 OK: The request was successfully processed, and the server returned the requested resource.
- 201 Created: The request was successfully fulfilled, and a new resource was created.
- 202 Accepted: The request has been accepted for processing, but the processing is not complete.
- 203 Non-Authoritative Information: The request was successfully processed, but the information comes from a different source.
- 204 No Content: The request was successfully processed, but there is no content to send in the response.
- 205 Reset Content: The request was successfully processed, and the client should reset the view.
- 206 Partial Content: The server is returning part of the content in response to a range request.
3xx: Redirection
- 300 Multiple Choices: The request can be fulfilled in multiple ways.
- 301 Moved Permanently: The requested resource has been permanently moved to a new URL.
- 302 Found: The requested resource is temporarily available at a different URL.
- 303 See Other: The resource should be retrieved using a GET request to a different URL.
- 304 Not Modified: The requested resource has not been modified since the last request.
- 305 Use Proxy: The requested resource must be accessed through a proxy.
- 307 Temporary Redirect: The requested resource is temporarily available at a different URL.
- 308 Permanent Redirect: The requested resource has been permanently moved to a new URL.
4xx: Client Errors
- 400 Bad Request: The server cannot process the request due to a client error.
- 401 Unauthorized: Authentication is required to access the resource.
- 402 Payment Required: The code is reserved for future use.
- 403 Forbidden: The server refuses to fulfill the request.
- 404 Not Found: The requested resource could not be found.
- 405 Method Not Allowed: The request method is not allowed for the requested resource.
- 406 Not Acceptable: The requested resource cannot be provided in the acceptable format.
- 407 Proxy Authentication Required: Proxy authentication is required.
- 408 Request Timeout: The request timed out.
- 409 Conflict: The request cannot be processed due to a conflict with the current state of the resource.
- 410 Gone: The requested resource is no longer available and will not be available again.
- 411 Length Required: The request must specify the length of the content.
- 412 Precondition Failed: The precondition in the request headers is false.
- 413 Payload Too Large: The request entity is larger than the server is willing or able to process.
- 414 URI Too Long: The request URI is too long.
- 415 Unsupported Media Type: The request entity has a media type which the server or resource does not support.
- 416 Range Not Satisfiable: The client has asked for a portion of the file, but the server cannot supply that portion.
- 417 Expectation Failed: The server cannot meet the requirements of the Expect request-header field.
- 418 I’m a teapot: A humorous code introduced in RFC 2324.
5xx: Server Errors
- 500 Internal Server Error: A generic error message when the server encounters an unexpected condition.
- 501 Not Implemented: The server does not support the functionality required to fulfill the request.
- 502 Bad Gateway: The server received an invalid response from an inbound server.
- 503 Service Unavailable: The server is currently unavailable.
- 504 Gateway Timeout: The server did not receive a timely response from an upstream server.
- 505 HTTP Version Not Supported: The HTTP version used in the request is not supported by the server.
- 506 Variant Also Negotiates: Transparent content negotiation for the request results in a circular reference.
- 507 Insufficient Storage: The server is unable to store the representation needed to complete the request.
- 508 Loop Detected: The server detected an infinite loop while processing a request.
- 510 Not Extended: Further extensions to the request are required for the server to fulfill it.
- 511 Network Authentication Required: Authentication is required to gain network access.
Conclusion
HTTP status codes play a crucial role in the functioning of web applications and services. They provide standardized communication between servers and clients, helping to manage data flow and handle errors. Understanding these codes is essential for developers and administrators as it allows for effective problem-solving and optimization of web resources.
Leave a Reply