Introduction HTTP response status codes are critical indicators sent by servers in response to client requests in web communications. These codes inform the client about the success, failure, or required actions in response to the request.
A common status code, for example, is 404, typically displayed as “Page not found” when a requested resource is not available on the server.
For instance, receiving a 200 (OK) response code after a GET request signifies a successful operation. Conversely, a 404 (Not Found) indicates that the server could not locate the requested resource.
Categories of Responses Response codes are systematically categorized into five distinct ranges, each representing a different type of server response:
Informational Responses (100 - 199)
- These provide feedback about the initial part of the request.
- 100 Continue: Implies that the initial part of the request has been received and the client should continue with the request.
- 101 Switching Protocols: Informs the client that the server is switching protocols as requested by the client (like switching from HTTP to WebSocket).
Successful Responses (200 - 299)
- These indicate that the client’s request was successfully received, understood, and accepted.
- 200 OK: Standard response for successful HTTP requests.
- 204 No Content: Indicates that the server successfully processed the request, but is not returning any content.
Redirection Messages (300 - 399)
- These codes tell the client that additional actions are needed to complete the request, often involving URL redirection.
- 301 Moved Permanently: This tells the client that the resource has permanently moved to a new URL.
- 307 Temporary Redirect: Indicates that the resource requested has been temporarily moved to another URL, and the client should use the original method to access the new URL.
Client Error Responses (400 - 499)
- These are issued when the request contains bad syntax or cannot be fulfilled due to client-side errors.
- 400 Bad Request: General error when the server cannot process the request due to a client error.
- 401 Unauthorized: Indicates that the request lacks valid authentication credentials.
- 403 Forbidden: Indicates that the server understood the request but refuses to authorize it.
- 404 Not Found: Indicates that the requested resource could not be found.
Server Error Responses (500 - 599)
- These indicate issues on the server side, preventing the fulfillment of the request.
- 500 Internal Server Error: A generic message indicating an unexpected condition was encountered on the server.
- 504 Gateway Timeout: The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server.
By understanding these categories and their specific examples, users and developers can better diagnose and address issues related to HTTP requests. It’s crucial to have a grasp of these response codes to effectively manage web communications and server interactions.
Lesson Task
Memorise the HTTP response codes categories. Try and remember at least one example for each category.
Go through the list of status codes on the MDN: HTTP Status Codes page. You do not have to memorise these, but it’s good to get some indication of how these codes would look.