ACE YOUR PROGRAMMING LIFE WITH HTTP STATUS CODES.

  • IMPORTANT TERMS EXPLAINED.

  • MEANING OF HTTP.

  • HTTP CODES WITH EXAMPLES.

Before embarking on the quest to learn what HTTP responses were, I only knew of error 404 and status code 200. I became fascinated to learn and inform my audience about these status codes and their meanings when a mentor told me about his experience troubleshooting error 500 for a couple of hours or days before he could understand why the page was displaying such error.

After going through this piece you should be well informed of various response codes and why it shows up on your page.

Alright, fasten your belt, and let's begin the adventure. Before diving too deep let's explain some terms:

What is a server? A server is a computer/device that provides functionalities to other computers on the network. Servers are usually put on 24/7 for continuous accessibility to other devices. Types of servers include; a web server, file server, print server e.t.c.

What is a client? A client is your computer browser used in interacting with the websites. It fetches information from the server and displays it on the web pages.

URL: This means Uniform Resource Locator, URL allows the browser to locate a particular page on the internet,

HTTP(HyperText Transfer Protocol). This determines how a client communicates with the server. HTTP responses usually come with a head and body. The protocol here means a convention e.g saying hi to someone instinctively generates a hello response from the receiver. When accessing a web page, every HTTP request that is sent returns a response code which is usually 3-digits starting with the group it belongs to.

HTTP status codes are responses a server sends back to the client when a request is made. These are grouped into five categories:

INFORMATIONAL RESPONSES:

These are codes between 100 - 199. It means the server has received the request sent by the browser/client and it's been processed.

SUCCESSFUL RESPONSE:

These range from 200-299. This means client request is received, understood, and accepted. The requested page is usually served immediately.

REDIRECT RESPONSE:

This is within 300 - 399. These indicate that additional information is required or the page has been redirected.

CLIENT ERROR:

These fall between 400 - 499. Codes within this range signify that there is a problem with the request sent, it could either be a typographical error in the URL, or a breakage in the URL, or the page doesn't exist.

SERVER ERROR:

This is between 500 - 599. This error code shows that the server could not process the information sent, this may result from a faulty server or a problem with the data stored on the server.

IMPORTANT STATUS CODES AND MEANINGS.

- INFORMATIONAL RESPONSES:

100 - CONTINUE:

The client can proceed with the request, or ignore the response if the request has been completed.

101 - SWITCHING PROTOCOL:

This is received when there is a change in the protocol of an already established client/server connection. i.e switching from HTTP 1.1. to HTTP 2.0.

102 - PROCESSING:

This means that the server has received the request and it's been processed but not yet available.

- SUCCESSFUL RESPONSE

200 - OK:

This means that "all is well", the request is successful. For example, visiting a website to get a piece of information and the information is being served to you.

201 - CREATED:

This is received when a POST request is made. For example, submitting a form which may be followed by a thank you page, signifying that the request is well received and thus a new page is generated.

204 - NO CONTENT:

This code is received when the server doesn't have suitable content for a particular request.

- REDIRECT RESPONSE

300 - MULTIPLE CHOICE:

This response code signifies that there is more than one content and thus the user-agent needs to choose a suitable response.

301 - MOVED PERMANENTLY

This response shows that the requested link has been changed and redirects the user to a new URL. This is contained in the response message.

304 - NOT MODIFIED:

This means the content has not been modified. For example, when a site is visited and the request gets cached and the same request is made again, this status code is received.

- CLIENT ERROR

400 - BAD REQUEST:

This is received when the server is unable to process the request made by the client, this may be due to a faulty browser, incorrect syntax.

401 - UNAUTHORIZED:

This error occurs when a user is trying to access a protected resource without providing authentication credentials.

403 -FORBIDDEN:

403 response code is different from all other ones in that it doesn't occur due to client error or lack of credentials to access a particular page, the server may just choose to deny access to a piece of information and this produces a 403 error code.

404 - NOT FOUND

This is received when the requested resource isn't available on the server, or the URL isn't recognized by the server. This may also be sent to the client if the resource is encrypted from an unauthorized user.

406 - NOT ACCEPTABLE:

The error is returned after the server processed the request but couldn't find suitable content for the criteria sent.

451 - UNAVAILABLE FOR LEGAL REASONS:

This signifies that the requested resource is unavailable by the law. For example, web pages that are restricted by the government.

- SERVER ERROR

500 - INTERNAL SERVER ERROR:

This arises when the server cannot process a request for an unknown reason. For example, the case of my mentor where a plugin he installed on his development environment overwrote all the content of the pages at the point of deployment. Error 500 could also arise due to modifications in an API.

501 - NOT IMPLEMENTED:

This indicates that the server does not recognize and cannot process the request sent. This may be due to an unsupported request method.

502 - BAD GATEWAY:

This error is received when the server receives an error from the backend server that is responsible for loading the HTTP response.

503 - SERVICE UNAVAILABLE:

This error indicates that the server has received more traffic than it can handle and hence experience downtime or it is currently under maintenance.

504 - GATEWAY TIMEOUT:

This error signifies that the server acting as a gateway to the backend server couldn't get the response within the expected time frame.

With all these said, you must have been equipped with what HTTP status codes are, their meanings and why it shows up.

Please share your comments and feedback, more resources will as well be appreciated. Thank you!!!