HTTP Status Code.

HTTP status codes are three-digit numeric codes that the server sends in response to a client's request made to the server. These codes provide information about the status of the requested resource or the success of the requested operation. When a client, such as a web browser, makes a request to a server, the server responds with an HTTP status code along with additional information in the HTTP headers and, optionally, a response body.

Each HTTP status code falls into one of the five classes, indicating the general category of the response:

1xx: Information.

HTTP 1xx status codes are informational responses indicating that the server has received the request and is continuing to process it. These codes are part of the initial phase of the Hypertext Transfer Protocol (HTTP) communication between a client and a server. 

Here are some common HTTP 1xx status codes:
Status Code Meaning
100 Continue The server has received the initial part of the request, and the client can proceed with sending the remainder of the request.
101 Switching Protocols The server acknowledges the request and indicates that it is changing the protocol being used on the connection. This is often seen in the context of switching to WebSocket communication.
102 Processing This status code indicates that the server has received and is processing the request, but no response is available yet.
103 Early Hints The server sends a preliminary response before the final headers, with the intention of providing hints for the client to start preloading resources.

2xx: Success.

HTTP success status codes (2xx) indicate that the server has successfully received, understood, and accepted the client's request. These status codes inform the client that the requested operation or resource has been completed or fulfilled successfully. Success status codes typically fall within the range of 200 to 299. 

Here are some commonly used success status codes and their meanings:
Status Code Meaning
200 OK The request was successful, and the server has returned the requested data.
201 Created The request has been successfully fulfilled, resulting in the creation of a new resource.
202 Accepted The request has been accepted for processing, but the processing is not yet complete. This is often used for asynchronous operations.
204 No Content The server successfully processed the request, but there is no additional content to send in the response. It is commonly used for actions that do not return a response body.
205 Reset Content Similar to 204 No Content, but instructs the client to reset the document view.
206 Partial Content The server is delivering only part of the resource in the response. This is often used in scenarios where the client requests a specific range of data.

3xx: Redirection.

HTTP redirection status codes (3xx) indicate that further action is needed to fulfill the client's request. These codes instruct the client to take additional steps, such as redirecting to a different URL or making a new request to a different resource. 

Here are common HTTP redirection status codes and their functions:
Status Code Meaning
300 Multiple Choices The requested resource corresponds to multiple possibilities, and the server cannot choose which one to follow. The client should select from the alternatives provided.
301 Moved Permanently The requested resource has been permanently moved to a new location. The client should update its bookmarks or links.
302 Found The requested resource temporarily resides under a different URL. The client should use the new URL for the current request, but future requests can still use the original URL.
303 See Other Similar to 302 Found, but the client should always use the new URL for subsequent requests (typically for POST requests).
304 Not Modified Indicates that the client's cached copy of the resource is still valid, and the server has not modified it. The client can use its cached version.
307 Temporary Redirect Similar to 302 Found, indicating a temporary redirect. The client should use the new URL for the current request, but future requests can still use the original URL.
308 Permanent Redirect Similar to 301 Moved Permanently, indicating a permanent redirect. The client should update its bookmarks or links.

4xx: Client Error Status Code.

HTTP client error status codes (4xx) indicate that the client seems to have made an error in the request, and the server cannot or will not process the request. These codes provide information about issues on the client side, such as malformed requests or insufficient permissions. 

Here are common HTTP client error status codes along with their functions:
Status Code Meaning
400 Bad Request The server cannot understand the request due to malformed syntax or other client-side errors.
401 Unauthorized The request lacks proper authentication credentials, and the client needs to provide valid credentials for the server to process the request.
402 Payment Required Reserved for future use. Originally intended for digital payment scenarios.
403 Forbidden The server understood the request, but it refuses to authorize it. The client lacks proper permissions to access the resource.
404 Not Found The server cannot find the requested resource. This is a common response for URLs that do not correspond to any available resource.
405 Method Not Allowed The method specified in the request (e.g., GET, POST) is not allowed for the requested resource.
406 Not Acceptable The server cannot produce a response matching the list of acceptable values defined in the request's headers.
407 Proxy Authentication Required Similar to 401 Unauthorized, but indicates that the client must first authenticate itself with the proxy.
408 Request Timeout The client did not produce a request within the server's specified timeout period.
409 Conflict Indicates that the request could not be completed due to a conflict with the current state of the target resource.
410 Gone The requested resource is no longer available at the server, and no forwarding address is known.
411 Length Required The server requires the client to specify the length of the request content, but the client has not done so.
412 Precondition Failed The server does not meet one of the preconditions specified in the request headers.
413 Payload Too Large The request is larger than the server is willing or able to process.
414 URI Too Long The URI (Uniform Resource Identifier) provided in the request is too long for the server to process.
415 Unsupported Media Type The server does not support the media type specified in the request.
416 Range Not Satisfiable The client has asked for a portion of the file (byte serving), but the server cannot provide that portion.
417 Expectation Failed The server cannot meet the requirements specified in the Expect request header.
418 I'm a teapot This code was defined in the April Fools' Day RFC 2324 as an April Fools' joke and is not expected to be implemented.
421 Misdirected Request The request was directed at a server that is not able to produce a response. This can happen when the connection is reused on a different request.
422 Unprocessable Entity The server understands the content type of the request entity, and the syntax of the request entity is correct, but it was unable to process the contained instructions.
423 Locked The resource that is being accessed is locked.
424 Failed Dependency The request failed because it depended on another request, and that request failed.
426 Upgrade Required The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.
428 Precondition Required The origin server requires the request to be conditional.
429 Too Many Requests The user has sent too many requests in a given amount of time.
431 Request Header Fields Too Large The server is unwilling to process the request because either an individual header field, or all the header fields collectively, are too large.
451 Unavailable For Legal Reasons The server is denying access to the resource as a consequence of a legal demand.

5xx: Server Error.

HTTP server error status codes (5xx) indicate that the server failed to fulfill a valid request from the client. These codes inform the client that the server encountered an error while processing the request, and the error is not due to any fault on the client's side. 

Here are common HTTP server error status codes along with their functions:
Status Code Meaning
500 Internal Server Error A generic error message indicating that an unexpected condition prevented the server from fulfilling the request.
501 Not Implemented The server does not support the functionality required to fulfill the request. This is typically a server-side issue.
502 Bad Gateway The server, while acting as a gateway or proxy, received an invalid response from an upstream server it accessed in attempting to fulfill the request.
503 Service Unavailable The server is not ready to handle the request. Common causes include the server being temporarily overloaded or undergoing maintenance.
504 Gateway Timeout The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server or some other auxiliary server it needed to access to complete the request.
505 HTTP Version Not Supported The server does not support the HTTP protocol version that was used in the request.
506 Variant Also Negotiates The server has an internal configuration error that prevents it from fulfilling the request.
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 The client needs to authenticate to gain network access. This is similar to 401 Unauthorized but indicates that the client must authenticate itself to get permission.

Conclusion.

Understanding HTTP status codes is crucial for developers and network administrators to diagnose and troubleshoot issues during web communication. The status codes convey valuable information about the outcome of a request, enabling efficient handling of responses in web applications.

⚡ Please share your valuable feedback and suggestion in the comment section below or you can send us an email on our offical email id ✉ algolesson@gmail.com. You can also support our work by buying a cup of coffee ☕ for us.

Similar Posts

No comments:

Post a Comment


CLOSE ADS
CLOSE ADS