HTTP – Hypertext Transfer Protocol: Everything You Need To Know

 

Do you know, today 4.66 Billion people use the internet on daily basis for listening to their favorite songs during a workout, binge-watching Netflix, studying online & what not. But are you aware, how data is exchanged on the web? Well, in this article, we have explained about Hypertext Transfer Protocol (HTTP) which is the bedrock of the World Wide Web(WWW) & used to download web pages, its usage, attributes, working, examples, messages & security.

But first of all, let’s see what does HTTP stands for & what is its usage?

HTTP Full Form

HTTP full form is Hypertext Transfer Protocol.

HTTPS Full Form

HTTPS full form is Hypertext Transfer Protocol Secure.

What is the definition of HTTP?

HTTP, which stands for Hypertext Transfer Protocol, is the most widely used application layer client-server protocol, which inculcates a set of rules for web browsers(client) and web servers to communicate with each other on the World Wide Web.

introduction-hypertext transfer protocol

If we break the term to exactly understand what is the meaning of Hypertext Transfer Protocol:

  1. Hypertext – While browsing, you might have observed web links to other pages, which are different from the normal text of the webpage. Such text, which is not linear text but makes a connection & takes you to another web page, is called hypertext.
  2. Transfer Protocol – We use the term “transfer” because this protocol or set of rules are used for the exchange of hypertext documents between client & server on WWW. But now, due to extensibility, HTTP can be used to transfer images, videos, ads, etc. as well.

Attributes of HTTP

  1. HTTP is connectionless: The transport protocol used by HTTP for making a connection is TCP & hence for communication between client & server, a TCP connection should be made. But this connection is made only for a particular request/response. E.g. client makes a request to the server & waits fr the response. Once it gets the response, they disconnect. So if any new request is to be made, they will make a new connection & hence we say HTTP is connectionless.
  2. HTTP does not have any state – As a result of the above-discussed attribute i.e., being connectionless, both the parties, client & server, do not remember each other. So if 2 requests are made to the same web page, there will be no retention of information from the previous request.
  3. HTTP is not session less – You might be wondering that the above characteristic can create a problem for the users while making requests to the same web page, e.g., you had added some items in your cart & with HTTP being stateless, next time when you visit the same web page, the items will be lost. But such is not the case & thanks to HTTP header extensibility. Extensibility allows creating sessions using the same context by adding cookies.
  4. HTTP is independent of Media – Any type of content can be exchanged between client & server provided both should be able to handle the same. Also, the content type needs to be specified in the MIME header.
  5. HTTP possesses extensibility – As per HTTP/1.0, with the use of HTTP headers, experimenting with this protocol is easy as it can be experimented with by adding new functionalities as long as there is an agreement between both client & server.

Architecture of HTTP

The basic architecture of HTTP involves a Client, mostly a web browser sending requests to a webserver to fetch HTML documents, videos, images, etc. This request is received by the server, which handles it & sends the response back accordingly. In between client & server, there are other entities known as Proxies performing the function of gateways.

client-server-chain-Hypertext Transfer Protocol

Client

This is the entity that always proceeds a request to the browser for loading the web page & other sub-resources within that. All these resources are then combined to make a complete document that is presented to the user.

Server

The server is a group of software instances on the opposite side of the client & provides the HTML documents & other resources as requested by the client.

Proxies

Proxies are a group of application layer entities in between server & client which relay the messages & perform other functions like caching, loading, authentication, etc.
There are 2 types of Proxies –

  1. Transparent Proxies – They do not change the request between client & server
  2. Non Transparent Proxies – These entities change the requests before they reach the server.

HTTP Architecture

HTTP Requests & Responses

HTTP Messages

The communication between browsers & servers takes place in the form of HTTP messages & these messages are of 2 types :

  1. HTTP Request
  2. HTTP Response

Request Response

Let’s explore more to see what is the function of these two types of messages:

HTTP Request

http_request-hypertext transfer protocol

The messages which are sent by the client or browser to the server are known as HTTP requests. Their main purpose is to ask the server to load the web pages. The format of HTTP requests include:

1. Hypertext Transfer Protocol Version Type

The request includes the version type of Hypertext Transfer Protocol, namely,

  • HTTP/0.9
  • HTTP/1.0
  • HTTP/1.1
  • HTTP/2.0
  • HTTP/3.0

2. URL

Uniform Resource Locator is the address used by HTTP to specify any information on the web. The path to the resource is added to the HTTP request in the form of a URL.

URL-hypertext transfer protocol

3. Hypertext Transfer Protocol Method

The method is used to indicate what action is the client wants to be performed when it sends any request to the client. Mainly, the requests made by the browser are of 2 types:

  • Requesting the server to fetch some information like loading a website. In such cases, the methods used is ‘GET.’
  • Sending a request to submit some information to the server e.g., submitting forms. Such cases use the method ‘POST.’

4. Request Headers

This is some key: value text which is used to send additional information to the server used in every HTTP request, for instance, Operating system, which browser is being used, etc.

5. Request Body

When the HTTP request is used to submit some information to the browser, that information is encapsulated inside this Request Body, e.g., The data that you filled in the form to be submitted.

HTTP Response

http_response-hypertext transfer protocol

When the client/browser sends a request to the browser, the answer to that request which is sent by the server is called Response.
The format of response includes the following:

1. Status Code

This code is used to indicate the status of the request being processed by the server. There are various status codes as follows:

  1. 1xx (Informational) – This status is received as a response to indicate a request from the client has been received at the server & required action is in process.
  2. 2xx (Success) – This status indicates that after receiving this request from the client, the server has understood this request & accepted it.
  3. 3xx (Redirection) – This status means that to fulfill the request, actions need to be taken, whether by the client or automatically< in order to fulfill the request.
  4. 4xx (Client Error) – This code means that the request could not be completed due to some error on the client-side, usually syntax error.
  5. 5xx (Server Error) – This status indicates that the request was valid, but still server couldn’t fulfill it.

2. Response Headers

Just like we discussed headers in request messages, response bodies too have their headers which include some core information about the data being sent to the browser or client e.g., format of the data or language being used to write the data.

response-headers

3. Response Body

When a web server gets a request, it responses back generally with a body & the web browser converts it into a web page.

Working of Hypertext Transfer Protocol

fetching_a_page-hypertext transfer protocol

Whenever a user types a web address with HTTP in front, i.e. HTTP:// in front of a URL, it directs the browser to create an HTTP connection with the server. The browser then sends an HTTP request to the server over this established connection. Once the server receives the request, it sends the response back. If it is a success, the response will be in the form of the web page requested by the user; otherwise the status code will indicate the error for not loading the same.

HTTP Example

We will understand the Hypertext Transfer flow with an example:

diagram-of-http-communication

1. Type URL with HTTP

When we type a URL, you might have noticed; we type HTTP in front of its path.

E.g. https://newsxday.com

Now, this is how you indicate to the browser that it needs to make a Hypertext Protocol connection with the server & fetch the web page in that URL. Hence this is the first step to direct the web browser to make a connection. This can also be done by clicking on a hyperlink in one of the already opened webpages like the one I have mentioned in the example.

2. Mapping of domains to IP

Whatever URLs we write in our bar are actually the domain names, but they need to be mapped to the IP of the domain computer. This mapping is done by Domain Name System.

E.g., The IP address for https://newsxday.com is 172.67.152.62

3. Sending HTTP Request

After the browser has identified the IP address from the domain name, it sends the request to the server. The request format could be:

GET /newsx.html HTTP/2.0

Here in this request, GET is the HTTP method that requests to fetch a web page with the path mentioned in the second part i.e.,/newsx.html. The third part HTTP/2.0, is the version of the Hypertext Transfer Protocol.

4. Response Is Sent By The Server

As the host computer with the IP address requested receives the request, it sends the response back to the Browser. The format of a successful response looks like this:

  • The start of the response is with version & status code
HTTP/2.0 200 OK

Here the status code is 200, which belongs to the 2xx(Success) category, which means that the request is understood & accepted. There could be some other common status codes also like 404(file not found), which falls under the 4xx(Client Error) category & usually occurs when a user types wrong web address URLs.

  • Response headers

Content-Type: image/png; Content-Length: 120

As we already discussed that the response headers give information about the data being sent by the server; this example depicts information about the content type, which is an image. Common on the web are “image/png” for images, “text/html” for HTML documents, “video/mpeg” for videos. The second part tells about the size of the content in bytes. In this example, it is 120 bytes.

  • Response Body
<!DOCTYPE html>
<html>
  <head>
    <title>Hypertext Transfer Protocol</title>
  </head>
  <body>
    <h1>Hypertext Transfer Protocol</h1>
    <p>This article explains the usage of Hypertext Transfer Protocol</p>
  </body>
</html>

Now the above example is for the response body which is the actual content requested by the user/browser. These are mostly HTML documents, images, videos, or scripts.

How Secure is Hypertext Transfer Protocol?

Hypertext Transfer Protocol is not a secure protocol since the information exchanges between client & server is not encrypted & can easily be read by anyone during an HTTP connection is established. Hence all the private information like that of your debit cards or passwords can easily be hacked over an HTTP connection.

Difference Between HTTP & HTTPS

To identify the differences, let us first see what is HTTPS

Hypertext Transfer Protocol Secure (HTTPS) – Definition

HTTPS is the secured version of HTTP, which is used to exchange data between client & server but in a much secured way. It encrypts & decrypts both requests from the browser & responses from the clients.

For more details, check HTTPS

Difference

While the purpose served is the same by both HTTP & HTTPS, but if we see from security point of view, HTTP should be used for establishing a safe connection to share your passwords, credit card details as part of a request to the server.

Conclusion

Hypertext Transfer Protocol (HTTP) is a simple, stateless, connectionless & extensible protocol to use for loading web pages on the internet. But the only drawback is it lacks security due to which most web pages are migrating to or making their websites over HTTPS in the first place.

FAQ

Leave a Comment