Deep Dive Into HTTP

There is medium for sharing and receiving data through internet

and That is HTTP

What is HTTP?

HTTP is simple rules or protocal that follows by the client and server to exchange information in internet (world wide web). it is medium through which we receive and send data

It was developed in the early 1990s by Tim Berners-Lee at CERN and is the foundation of data communication for the World Wide Web.

There are client and server and they communicate through http .

it is protocol to send and receive data or information .

HTTP is the dominant and most common protocol for client-server communication.

the client send some http requests to server and server responds back with some HTTP responses like html, css , javascript images etc

HTTP is stateless what does it mean ?

each HTTP request from a client to a server is treated as a completely independent transaction. The server does not retain any memory or knowledge of previous requests from the same client.

what are the benefits for HTTP to be stateless ?

To be stateless , every requests are treated as independent transactions means different requests to the server.

  1. simplicity : It helps to design simple server . the server does not need to handle and keep tracks of record of every clients requests . think if http is stateful then the server need to keep track of each and every clients request which might make server slow to respond

  2. salability : it absolutely helps to make server scalable because the server can handle many request from many clients . because every request are treated independently there is no need to keep to store previous sessions of data of requests of client

  3. Reliability : if server crashes , there is no lose of data because it is stateless protocol . client make new connection to new server

There comes questions if it is stateless then how it keeps our login data ?

There are many ways to keep data on top of http

some of them are :

  1. cookies : small piece of data that stored in client browsers which are sent on each subsequent http requests.

  2. sessions : server side storage of user specific data which are identified by unique session id (mainly in form of cookies

  3. URL Parameters: directly send through query parameters in url

Request-Response Model

The client send some type of data which is sent through Request Headers :

It includes :

  1. Information about client : User-agent (browsers), Referer

  2. Content Negotiation : It tells server about content type client can understand and prefers like Accept:application/json

  3. Authentication and Authorization : Headers provides credentials like Authorization :Bearer sometoken

  4. Request Modifiers and conditions :like Cache-Control

  5. Connection Management :Connection:keep-alive or close , Host :www.exmple.com

  6. Cookies

  7. Content Information for (put and Post )

Response Headers :

  1. Server

  2. Content-Type

  3. cookies

  4. Date

  5. Location

  6. Security

  7. status code

These are information send by client in request header and server respond back in Response Header

0
Subscribe to my newsletter

Read articles from Dipesh Chaudhary directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Dipesh Chaudhary
Dipesh Chaudhary