HTTP Request-Response Cycle

HTTP Request-Response Cycle

The HTTP Request-Response cycle flows between client and server.

What is HTTP-Request?

It is a request from the client to the server requesting to access the desired information. The client can make the request by using computer hardware and software(for example web browsers like Chrome, Firefox, etc…). The client makes a request to the server by doing actions in the address bar of the browser and hitting the enter button. While making requests the client also sends a bunch of other information related to the request along with the URL. These information mostly contains in the “Header”.

The Header includes a bunch of request methods,content-type, etc… There are many request methods but out of those methods, these are the most commonly used ones- GET, POST, PUT, and DELETE.

GET request:- This request method means the client is requesting information. Typing facebook.com and pressing enter would be an example of GET request.

POST request:- This request method is used to make submission of information to the server. Posting something or uploading images on Facebook would be an example of POST request.

PUT request:- This request is used to update existing information available on the server. Editing posts on Facebook, editing your tweet would be an example of PUT request.

DELETE request:- This request is used to remove that specific information from the server. Deleting a post or tweet would be an example of a DELETE request.

What is HTTP-Response?

HTTP-Response is a response sent by the server to the client. It contains HTTP status code, requested information from the client, if the request was successful, and header. Requested Information can be a HTML file, JSON file, XML file etc…

An HTTP response would also contain a header with the information related to the response, similar to an HTTP request header.

HTTP Status Code:- It indicates whether a specific HTTP request has been successfully completed. There are dozens of status codes. These codes are divided into classes grouped by the first digit of the number. They are -

1xx (Informational Responses):- It means the request was received by the server and the process is continuing.

2xx(Successful Response):- These status codes are returned when the server succeeds in processing the request.

3xx(Redirection Messages):- These status codes are returned when the server is found the requested information somewhere else.

4xx(Client-Side Error):- These status codes are received by the client when the server received an incorrect request from the client-side.

5xx(Server Side Error):- These status codes are returned when something wrong happens on the server.