Let’s understand HTTP properly !

Nishra Nasar
6 min readApr 1, 2021

What is HTTP ?

HTTP stands for Hyper Text Transfer Protocol. HTTP is responsible for the communication between the web servers and clients. HTTP is stateless, which means each command runs independent over other commands.

What is HTTPS ?

HTTPS stands for Hyper Text Transfer Protocol Secure. Data sent through the HTTPS is encrypted. It is because of websites SSL (Secure Socket Layer) or TSL (Transport Security Layer). When sending sensitive information such as credit card numbers, national identity numbers need to be sent in encrypted format via a HTTPS.

Versions of HTTP

There were several releases of HTTP time to time. Currently HTTP/2 also been used in the industry. When consider the high level differences of this HTTP/2 when compared with HTTP/1.x HTTP/2 is multiplexed. HTTP/2 can handle multiple request and multiple response simultaneously as shown in the following figure.

HTTP/1.x vs HTTP/2

HTTP Request Methods / HTTP Verbs

HTTP Request and Response

HTTP methods also known as the HTTP verbs. There are 9 HTTP request methods according to Mozilla MDN web docs. These 9 HTTP verbs can be describe as following.

1. GET

With the help of GET method, users will be able to retrieve data from the server

2. HEAD

HEAD is requesting a response identical to a GET Request.

3. POST

POST request is used to submit, data to the server.

4. PUT

PUT request updates all the current representations of target data on the server.

5. DELETE

DELETE request allows to delete a target data from the server.

6. CONNECT

The CONNECT method establishes a tunnel to the server identified by the target resource.

7. OPTIONS

The OPTIONS method is used to describe the communication options for the target resource.

8. TRACE

The TRACE method performs a message loop-back test along the path to the target resource.

9. PATCH

The PATCH method is used to apply partial modifications to a resource.

HTTP Headers

There are 3 types of HTTP Headers as General Headers, Response Headers and Request Headers. The following image shows how it looks in a typical HTTP request when inspect it via browser dev tools.

Types of Headers

a). General Headers

There are few data carried on the General Section of the Headers as Following.

Typical General Header
  • Request URL is the URL we request data from the server.
  • Request Method can be any HTTP method like GET, POST, PUT, DELETE
  • Status Code shows the status of the request whether its successful or not. If it fails there are specific code for each type of error such as following.
Few HTTP Status Codes
  • Referrer Policy contains details on where the request coming from. For an example if you are at example.com and click a link from there to domain.tld, the Referrer header would specify example.com as the “referring” URL.
Types of Referrer Policies

b). Response Headers

Response headers are used to give a more detailed context of the response. Response Headers can carry number of data as following.

Sample Response Header

Out of the above some of the response header data can be explain bit more as following.

  • Server contains the type of serve the website is hosted. It can be apace or engine X or something else. Most of the time the server type is hidden to prevent from hacking.
  • Content Type is reparenting the response content type. Response can be HTML, CSS , JSON. Based on the response format, the content type can be vary. Ex : HTML (text/html), CSS (text/css), JSON (application/json)
Few content Type Examples (Reference : Common MIME types — HTTP | MDN (mozilla.org))
  • Content Length indicates the size of the response header in decimal number of octets.
  • Date contains the date and time the http response generated
  • Age contains the difference between *proxy’s current date and Date mentioned above (the date and time the http response generated). If the age is 0, it is probably fetched from the original server.

*Proxy server is a server application or appliance that acts as an intermediary for requests from clients seeking resources from servers that provide those resources.

Proxy Server

c). Request Headers

A request header is an HTTP header that can be used in an HTTP request to provide information about the request context, so that the server can tailor the response. A request header can contain the following details.

Typical Request Header

Out of the above some of the request header data can be explain bit more as following.

  • Cookies If the website has a cookie which already set previously and need to send back again to the server, the relevant cookie data is mentioned here
  • Accept — xxx There are bunch of data in the format of ‘accept’. Some of them are accept-encoding, accept-language and so on. These are data related to displaying data in the client side.
  • Authorization, https authorization is used to send user data in the format of a token to identify users in a protect web page. Authorization will not display unless the web page is using session to authenticate users
  • User Agent is a long string which contains the user’s OS details, user’s browser details, etc.

HTTP Response Status Codes

1xx : Informational

Status code which contains the format 1xx contains the status such as request received or the request is processing

2xx : Success

Status code which contains the format 2xx contains the status such as request is successfully received or understood or accepted.

3xx : Redirect

Status code which contains the format 3xx contains the status such as further action must be taken or redirect

4xx : Client Error

Status code which contains the format 4xx contains the status such as request does not have what it needs or authentication errors

5xx : Server Error

Status code which contains the format 5xx contains the status such as server failed to fulfil an apparent valid request.

Some of the common status codes can be displayed as following.

Common HTTP Status Codes

Hope this article helped you to have a better understanding on HTTP !

Wish you good luck on performing well on your project with a better understanding on HTTP !

Follow me for the upcoming articles….

If you like this article, let us know with your claps!

--

--