HTTP status codes

HTTP status codes

Arina Ladesova, https://t.me/toQAit

HI, everyone! Recently, I created a short guide on the most commonly used HTTP status codes for myself and my students. Let's take a look at what I have here.

HTTP status codes are numerical values returned by the server in response to client requests. They inform the client about what happened with the request and what actions to take next. Developers, in turn, specify what text errors to display to the user in case a particular code is returned.

In HTTP, there are five groups of status codes, each consisting of multiple codes. Here is a breakdown of each group:

1xx (Informational)

These codes inform the client that the request has been received and is being processed. They do not indicate successful completion of the request, but simply inform that the server has received and is processing the request. Examples include:

  • 100 Continue - This intermediate response indicates that the request has been successfully received and the client can continue to send requests or ignore this response if the request has been completed.
  • 102 Processing - This code indicates that the server has received the request and is processing it, but processing has not yet been completed. For example, it happens if the transaction took longer than average. It implies displaying to the user some sort of indicator that everything is moving so that they do not leave the page or refresh it.

2xx (Successful)

These codes inform the client that the request has been successfully processed by the server. Examples include:

  • 200 OK - the request has been successfully processed.
@girlie_mac
  • 202 Accepted - the request has been successfully accepted but not processed.
@girlie_mac
  • 201 Created - the request has been successfully processed and the entity has been created on the server.
  • 204 No Content - the request has been successfully processed but the response does not contain content. For example, it is typical for a Delete request.
@girlie_mac


3xx (Redirection)

These codes inform the client that the requested URL cannot be executed, but can be executed on another URL. Examples include:

  • 300 Multiple Choices - this response code is sent when the request has more than one possible response. The User-agent or user must choose one of the responses. There is no standardized way to choose one of the received responses.
@girlie_mac
  • 301 Moved Permanently - the requested resource has been moved to another URL.
  • 302 Found - This response code means that the requested resource has been temporarily changed. New changes to the URI may be available in the future. Thus, this URI should be used by the client in future requests.
  • 304 Not Modified - Used for caching. This response code means that the requested resource has not been changed. Thus, the client can continue to use the cached version of the response. For example, once a month the application checks whether the terms of service for the user have changed and whether they need to accept the new version or continue to live with the old one.
@girlie_mac


4xx (Client Errors)

These codes inform the client that the request contains an error and cannot be processed by the server. Examples include:

  • 400 Bad Request - the server cannot process the request due to an error in the request. For example, the user entered a phone number in the wrong format.
@girlie_mac
  • 401 Unauthorized - authentication is required to obtain the requested response. The status is similar to status 403, but in this case, authentication is possible.
  • 403 Forbidden - the client does not have access rights to the content, so the server refuses to provide the proper response. For example, viewing a particular file on Google Drive requires viewing rights.
  • 404 Not Found - the requested resource was not found on the server.
@girlie_mac
  • 405 Method Not Allowed - when an HTTP method is requested that is not allowed for an authenticated user. Rarely seen in the interface, but often seen in API testing. For example, if you call Post instead of Put on the same URL.

5xx (Server Errors)

These codes inform the client that the request cannot be executed due to an error on the server. Examples include:

  • 500 Internal Server Error - an internal server error has occurred. The server has encountered a situation it does not know how to handle. Such an error often occurs again during API testing. For example, the client has phone number format validation. The user simply cannot enter an incorrect number. But you can do it through the API. The server is not ready for such a disgrace. And you are getting 500 error. But here you should refer it to development - because in good faith there should still be an error code 400 Bad Request.
@girlie_mac
  • 501 Not Implemented - The request method is not supported by the server and cannot be processed. Again, usually a story about API testing.
  • 502 Bad Gateway - The server acting as a gateway or proxy server received an invalid response from the next server in the chain.
  • 503 Service Unavailable - the server is not ready to process the request. Often the reasons are server shutdown or overload. Note that along with this response, a user-friendly page should be sent to the user.

PS:

There is a wonderful article in English on this topic - with super cool and funny pictures.

Also, take a look here. Here is a full list of all status codes with a description of what and when is necessary.


Report Page