Understanding HTTP
- Ekansh
- Mar 30, 2018
- 4 min read

What is HTTP?
Hypertext Transfer Protocol (HTTP) is a method for encoding and transporting information between a client (such as a web browser) and a web server.
HTTP is the primary protocol for transmission of information across the Internet. Information is exchanged between clients and servers in the form of Hypertext documents, from which HTTP gets its name.
HTTP is an application layer protocol and relies on an underlying network-level protocol such as Transmission Control Protocol (TCP) to function.
By default HTTP protocol uses port 80, but other ports can also be used.
Below are the fundamental features that make the HTTP a simple and powerful protocol used for communication:
HTTP is stateless: The client and server are aware of each other during a current request only. Afterwards, both of them forget each other. Due to the stateless nature of protocol, neither the client nor the server can retain the information about different request across the web pages.
HTTP is media independent: It refers to any type of media content can be sent by HTTP as long as both the server and the client can handle the data content.
HTTP is connectionless: It is a connectionless approach in which HTTP client i.e., a browser initiates the HTTP request and after the request is sent the client disconnects from server and waits for the response.
HTTP/1.0 uses a new connection for each request/response exchange
HTTP/1.1 connection may be used for one or more request/response exchanges.
HTTP/2 replaces HTTP /1.x ,and consists of following features:
Is a binary protocol: Makes the framing much easier and also, it makes it much easier to separate the actual protocol parts from the framing.
Multiplexed streams: Multiplexing the streams means that packages from many streams are mixed over the same connection. Two (or more) individual data are made into a single one and then split up again on the other side.
Priorities and dependencies: Each stream also has a priority, which is used to tell the peer which streams to consider most important, priorities can be changed dynamically in run-time.
Header Compression: Reducing the over head.
Server Push: Also known as cache push.It gives servers the capability to push responses to client servers proactively.
Flow control: For every stream both ends have to tell the peer that it has more room to fit incoming data in, and the other end is only allowed to send that much data until the window is extended.Only DATA frames are flow controlled.
HTTP Methods HTTP works through various methods, following are the methods.
GET: Used to retrive information from the requested URL.
POST: Used to send data to the server, for example, customer information, file upload, etc. using HTML forms.
HEAD: Asks for only the header part of whatever a GET would return, same as GET method but with no body.
PUT: Used to upload a file at a requested URL.
DELETE: Used to deleted a file at a requested URL.
TRACE: Asks for the loopback of the request message, for testing or troubleshooting.
OPTIONS: Asks for a list of the HTTP methods to which the thing at the request URL can respond.
GET Vs POST
Below is the difference between GET and POST Method:

(Source: https://www.w3schools.com/tags/ref_httpmethods.asp)
When a client sends a request to a server, below is how a request looks like: GET / HTTP/1.1 Host: www.google.co.in User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:59.0) Gecko/20100101 Firefox/59.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Cookie: value Connection: Keep-Alive Upgrade-Insecure-Requests: 1 When a server responds to the client, below is how the response looks like HTTP/1.1 200 OK Date: Fri, 30 Mar 2018 10:48:00 GMT Expires: -1 Cache-Control: private, max-age=0 Content-Type: text/html; charset=UTF-8 Strict-Transport-Security: max-age=3600 Server: gws Set-Cookie: 1P_JAR=2018-03-30-10; expires=Sun, 29-Apr-2018 10:48:00 GMT; path=/; domain=.google.co.in Connection: close
HTTP Status:
The Status Code element in a server response, is a 3-digit integer where the first digit of the Status Code defines the class of response and the last two digits do not have any categorization role.
There are 5 values for the first digit:
1xx: Informational - It means the request has been received and the process is continuing.
2xx: Success - It means the action was successfully received, understood, and accepted.
3xx: Redirection - It means further action must be taken in order to complete the request.
4xx: Client Error - It means the request contains incorrect syntax or cannot be fulfilled.
5xx: Server Error - It means the server failed to fulfill an apparently valid request.
Given below is a list of some of the status codes.
100: Continue - Only a part of the request has been received by the server, but as long as it has not been rejected, the client should continue with the request.
101: Switching Protocols - The server switches protocol.
200: OK - The request is OK.
202: Accepted - The request is accepted for processing, but the processing is not complete.
301: Moved Permanently - The requested page has moved to a new url.
302: Found - The requested page has moved temporarily to a new url .
403: Forbidden - Access is forbidden to the requested page.
404: Not Found - The server can not find the requested page.
502: Bad Gateway - The request was not completed. The server received an invalid response from the upstream server.
503: Service Unavailable - The request was not completed. The server is temporarily overloading or down.
Sources: www.nginx.com www.javatpoint.com www.daniel.haxx.se www.tutorialspoint.com www.w3schools.com
Comentarios