Easy Breakdown of HTTP Status Codes

Easy Breakdown of HTTP Status Codes

Hello fellow developers,

Have you ever wondered what errors like 400 Bad Request or 404 Page Not Found mean while surfing? Let's simplify and understand these error codes.

If you're curious to learn more about these common codes, then you're on the right page.These error codes are nothing but these are known as HTTP Response Status Codes used in modern web.

Let's dive into these HTTP Response Status Codes.


Why do these HTTP Response Status Codes exist?

Basically, these HTTP Status codes are used to indicate where the HTTP request is successfull or failed.

Analogy:

Let's take an example: You want to book a train ticket from Mumbai to Delhi. You open the IRCTC app and book the ticket. Now, you want to know if your ticket has been booked. This is where status codes come in. Based on different conditions, HTTP status codes change. In this case, if the ticket is booked, it will show a 200 OK response, meaning your ticket has been successfully booked.


Following are the Response status code:

ResponseStatus codes
Informational Response( 100 - 199 )
Successfll Response( 200 - 299 )
Redirection messages( 300 - 399 )
Client error responses( 400 - 499 )
Server error responses( 500 - 599 )

Informational Response ( 100- 199 ) :-

  1. 100 Continue

    The HTTP 100 Continue informational response code indicates that the initial part of the request has been received. The server is ready to accept another request. The client can either proceed with the request or discard it.

    Analogy:

    Suppose you want to go to the office and call a taxi. The taxi driver accepts your request and tells you to get in. Then, he asks for your destination. This is like HTTP 100 Continue, where the server accepts the initial request and is ready for more information.

  2. 100 Switching Protocol

    The HTTP 100 Switching Protocol is used when you want to switch or upgrade to another protocol for better performance.

    Analogy:

    Suppose you're in a taxi heading to your office. Suddenly, you get a call from home and decide to change your destination to your home. You inform the taxi driver, and he agrees to switch to the new destination.

    This is like HTTP 101, where the client requests to switch protocols (destination), and the server (taxi driver) agrees to the change.

Successfull Responses ( 200 - 299 )

  1. 200 OK

    The result of “success” depends on these HTTP Codes

    • GET: The resource has been fetched and transmitted in the message body.

    • HEAD: Representation headers are included in the response without any message body.

    • PUT or POST: The resource describing the result of the action is transmitted in the message body.

Analogy:

You go to a toy shop to buy a car. You ask the shopkeeper to show you some cars. The shopkeeper starts showing you the cars.

You (the client) ask the shopkeeper (the server) to fetch the cars. The shopkeeper shows the cars (200 OK).

  1. 201 Created

    The HTTP 201 Created code indicates that the requested resource has been successfully created.

    Analogy:

    Imagine you and your friends go to a restaurant. You call the waiter and place an order. The waiter says, "Okay," and your order is created.

    You (the client) call the waiter (the server) and order something. The waiter responds, "Okay, your order is created" (201 Created).

  2. 202 Accepted

    The “HTTP 202 Accepted” code indicates that the request is accepted, but the request is not completed yet.

    Analogy:

    Imagine you and your friends go to a hotel. You call the waiter and place an order. The waiter says, "Okay," and your order is created. After some time, you call the waiter again, and the waiter replies, "Your order is accepted, but it hasn't been completed yet."

Redirection messages ( 300 - 399 )

  1. 300 Multiple Request

    The HTTP “300 Multiple Request“ indicates that th request has more than one possible responses.

    Analogy:

    Imagine you and your friend walk into a hotel restaurant, and the waiter brings you a menu with multiple options for meals within your budget. The waiter then says, “These are all great choices, but you need to pick one.” Until you decide, the waiter won’t proceed with serving you.

  2. 301 Moved Permanently

    The HTTP “301 Moved Permanently“ code indicates that the requested resource has been moved to some other location.

    Analogy:

    You go to a shop, but the shopkeeper says, “We’ve permanently moved to a new location.” From now on, you always go to the new address.

  3. 302 Found

    The HTTP "302 Found" code means that the requested resource has been temporarily moved to a different location.

    Analogy:

    You go to a shop, but the shopkeeper says, “We’ve temporarily moved to a new location” due to some construction work.

Client Error Response ( 400 - 499 )

  1. 400 Bad Request

    The HTTP “400 Bad Request“ code indicates the server cannot process the request due to something.

    Analogy:

    You send a messy form to an office. They return it, saying, "We can't understand this."

  2. 401 Unauthorized

    The HTTP "401 Unauthorized" code means that you cannot view the requested resource because you are not authorized.

    Analogy:

    Imagine you went to hospital and it wasn’t clean. You asked the nurse, to talk to owner of hospital.Nurse replied,”You’re not allowed to talk to owner”.

  3. 404 Page Not Found

    The HTTP "404 Page Not Found" code indicates that the requested page can't be viewed because it isn't available or is a dead link.

    Analogy:

    Imagine you're in a hospital canteen, and you try to order a cheeseburger that's not on the menu.

Server Error Response( 500 - 599 )

  1. 500 Internal Server Error

    The HTTP “500 Internal Server Error” server error response status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

    Analogy:

    Imagine you're in a new restaurant and you order your favorite food, but the cook makes a mistake, and the food is burnt and overcooked.

  2. 501 Not Implemented

    The HTTP “501 Not Implemented“ code indicates that the server does not support some resources to fullfil your request.

    Analogy:

    You ask a waiter for a dish they don’t know how to make. The waiter replies, "Sorry, we don’t serve that here."

502 Bad Gateway

The HTTP “502 Bad Gateway server error response status code indicates that a server was acting as a gateway.

Analogy:

You call a friend, but their phone provider has issues connecting your call. You get a message saying, "Connection failed."


Conclusion

Understanding HTTP Status Codes is crucial when building applications or working with APIs. This guide helps you easily grasp what each status code means, serving as a quick reference whenever you're stuck. I hope this was helpful and added value to your learning. Stay tuned for more simple and informative content!