What classes of HTTP codes exist?
Classes of HTTP codes are groups of HTTP status codes defined by the code's first digit that show the general result of processing the request.
There are 5 classes of HTTP codes in total.
1xx, Informational
The request has been accepted, processing is still continuing.
Rarely used, mostly for service purposes.
Examples:
100 Continue- it is fine to continue sending the request
An ordinary user almost never sees these.
2xx, Success
The request was completed successfully.
The most important and most frequently used codes.
Examples:
200 OK- everything went fine201 Created- the resource was created204 No Content- success, but with no response body
If you see 2xx, everything is fine.
3xx, Redirection
The client needs to take an additional action, usually go to another address.
Examples:
301 Moved Permanently- the resource has moved permanently302 Found- a temporary redirect304 Not Modified- the cache can be used
Often used by browsers automatically.
4xx, Client error
An error in the client's request: a wrong URL, no permissions, bad data.
The most familiar codes.
Examples:
400 Bad Request- an invalid request401 Unauthorized- authorization is required403 Forbidden- access is denied404 Not Found- the resource was not found
Important for an interview: 4xx is not the server's problem, it's a problem with the request.
5xx, Server error
The server received a correct request but could not process it.
Examples:
500 Internal Server Error- an internal server error502 Bad Gateway- an error while working with another server503 Service Unavailable- the service is temporarily unavailable
This is already a problem on the server's side.
A short table to remember
| Class | Meaning |
|---|---|
| 1xx | Information |
| 2xx | Success |
| 3xx | Redirection |
| 4xx | Client error |
| 5xx | Server error |
Short answer for an interview
Remember this wording:
There are 5 classes of HTTP codes: 1xx are informational, 2xx are successful, 3xx are redirections, 4xx are client errors, and 5xx are server errors.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.