— 2 min read
HTTP stands for Hyper Text Transfer Protocol. Lets break it down word by word
So basically HTTP is a set of rules to transfer hyper text between web server and client.
HTTP is an application layer protocol. The application layer is the one with which users can interact. HTTP specs only define the structure of the data to be transferred and how it is actually transferred is taken care of by lower-level protocols.
HTTP uses TCP/UDP to transfer data between server and client. TCP and UDP are transport layer protocols that are responsible for transferring between devices (We will see how data is actually transferred in my next post). HTTP clients and servers communicate using requests and responses.
HTTP is a stateless protocol. It means each request is independent of another request. In other words, if a user makes multiple request servers, then it does not know that there are 4 requests made by the user, at least not according to HTTP protocol. It can be tracked by other means such as sessions, cookies, etc..,
A HTTP request consists of
Request line consists of HTTP Version and request type.
Common request types are
These are useful if server/client wants to send additional information.
For ex: User Agent, Time etc.., can be sent in headers
These are data to be transferred along with request. GET request do not have body.
Example for request is
1GET / HTTP/22Host: www.google.com3User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.04Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.85Accept-Language: en-US,en;q=0.56Accept-Encoding: gzip, deflate, br
A HTTP response consists of
This contains HTTP status code that indicates the status of the request. You can see the list of status codes here
This consists of additional information about the response. For ex: Content length, Content type, etc.,
This contains the response body. This can be HTML page or XML or JSON etc..,
Example for HTTP response
1HTTP/2 200 OK2date: Sat, 29 May 2021 16:30:20 GMT3content-type: text/html; charset=UTF-84content-length: 3570656<!doctype html><html>.......</html>