Internet | HTTP Status Codes

Busra Ceval
Code Tricks
Published in
4 min readNov 8, 2022

Welcome back, guys! In this lecture, we will learn about HTTP status codes.

So far, the verbs required for a software developer to be related to the basics of HTTP and for CRUD operations have been explained in brief details and methods.

The client can initiate requests to the server with URLs and verbs. In return, the server responds to that request. The server response entails a status code and message payloads. The status code is important. It tells the client how to interpret the server’s response.

There are several classes of status codes.

  • 200 response codes indicate the request was successfully processed to some extend
  • 400 response codes indicate the request has failed due to a client-side error
  • 500 response codes indicate the request has failed due to a server-side error.

These 3 are the most common types.

There are also 100 and 300 which are rare.

  • 100 status code is purely provisional and entails informational messages
  • 300 status codes indicate redirection and require the client to take additional action.

Let’s look at each code that the first status type has.

Internet | HTTP Status Codes — 2xx:

Successful

  • The most common in 2xx codes is the status code 200. It’s the code that we might want to get every time we are sending a request to a server. For the Get request, the server sends the resource in the message body.

There are less frequently used status codes in this group.

  • Status code 202 Accepted. Indicates the request was accepted by the server but may not include the resource in the response. This is useful for async processing on the server side where the server may choose to send information for monitoring.
  • Status code 204 No Content. Indicates response doesn’t include a message body.
  • Status code 205 Reset Content. Indicates to the client to reset its document view
  • Status code 206 Partial Content. Indicates that the response only contains partial content.

Additional headers indicate the exact range and content expiration information.

Internet | HTTP Status Codes — 4xx: Client

Errors

Unlike 200 codes, most of the 400 errors are pretty common, they are a huge part of software development either on the front end or the back end.

These codes are used when the server thinks that the client is at fault. The client can be at fault for various reasons.

  • The most known of the client errors is 404 not found. 404 Not Found status code indicates that the resource is invalid and does not exist on the server
  • 400 Bad Request status code indicates the request was malformed
  • 401 Unauthorized status code indicates that the request requires authentication but it was requested with the required authentication. The client can repeat the request with the Authorization header. If that was included then the credentials were wrong.
  • 403 Forbidden status code indicates that the server has denied access to the resource
  • 405 Method not allowed status code means that an invalid HTTP verb was used in the request
  • And 409. 409 Conflict Status Code means that the server could not complete the request by the client and is trying to modify a resource that is newer than the client’s timestamp. These conflicts happen mostly for PUT requests during collaborative edits on a resource
  • There is also the status code 418 I’m a teacup. The 418 code itself was an April Fools Joke from 1998 and is not meant to be implemented or supported. But Google implemented it anyway.

Google has a new easter egg, mostly designed for server geeks and SEO geeks, at google.com/teapot. The page itself serves up a 418 response code, which is a server status code, named “I’m a teapot. The requested entity body is short and stout. Tip me over and pour me out.” You can check that out for fun haha!

Next up are the server error codes.

Internet | HTTP Status Codes — 5xx: Server

Errors

Server error codes indicate a server failure while processing the request.

  • 500 Internal Server Error is prob the most common in this class. Indicates some known or unknown error in the server while trying to service the request.
  • 501 Not Implemented status code indicates the server does not yet support the requested functionality. The server does not yet support the requested functionality.
  • And 503. 503 Service Unavailable status code is returned if an internal system on the server has failed or the server is overloaded. Typically the server won't even respond and the request will timeout.

Good job on making it through all the status codes guys! See you at the next lecture!

--

--