Hi guys, In this blog we will learn, What is http and how is it used on internet. Firstly lets know what http stands for ?
HTTP stands for
Hyper-Text Transfer Protocol. Protocol means a set of well defined rules .
What is HTTP?
To understand what is http, first we need to relate the HTTP with our daily life.For example, As to convey message properly between humans, we use a particular language which is understandable by both sides. Similarly when two computers on internet wants to communicate they need to follow a set of standard rules ( protocols ) which are universal and HTTP is one of the protocol used to communicate on internet. And also HTTP mostly used protocol to communicate on internet. So the computers which communicates by http must use http protocol.
HTTP is used for communicating and exchanging data like videos, images, audios, html files etc. on internet. To simplfy, http is like a messanger on internet where data can be send betweem computers.
HTTP uses a request response cycles for communication, i.e client sends an acknowledgement to provide a particular file to the server and in response the server send the particular file date requested to the client.
Client: Its the computer which is asking the resource or data to other computer.
server: Its the computer which provides the data to the asking computer.
HTTP is connectionless protocol, i.e the two computers gets disconnected after client makes the request and when the response is ready by server connection is reestablishes again to send the response.
HTTP is media independent i.e, HTTP can be used to deliver any type of data as long as the both computers i.e, client and server are able to understand it.
HTTP is an application layer protocol based on TCP/IP.
HTTP is a generic and stateless protocol i.e, The client and the server knowns about each other just during the current request and when the connection break the computer becomes strangers to each other. When they want to connect again they treat as they are connecting for first time.HTTP can be used for other purposes as well by using different options available for request methods, error codes, and headers.
How http evolved?
HTTP was first designed to fetch html from server that means it was designed specifically for web but later new features were added and it was able to send data of different media. The continuous evolving and addition of features made it more convient to use. Thus it became the most convient and relaible method for transfering data on Internet.
how http is use on web explained by an example:
Lets understand the request response by an example, Let say you want to visit the amazon.com so you go to the browser and in address section types amazon.com. So the browser creates and connection between your computer and the server then an the http request is send to the amazon.com by the help of the internet and the http request sent is recieved by the server at the amazon.com and the connection in closed. know the server respond to the request by processing the request and reestablising the connection and sends the http response and ends the connection. The both computers used the http protocol for communication.
HTTP is consist of a standard message template based on which every http message is build.Lets see how the http protocol structure look likes. HTTP messages are plain text and easy to read.
HTTP Message template:
HTTP message consist of three sections
- starting line
Starting line: It is the first line of the http message, and it indicating what type of the request is it and what is expected from server or what happened to the response.It consist of mainly the http request method type, request targeted to or url, http version and status.
Header: Headers section consist of Zero or more header fields below the starting line. Each header field consists of a name and a value, separated by a colon. The headers end with a blank line. Adding a header field is as easy as adding another line.
Body: After the blank line is an optional message body containing any kind of data. Request bodies carry data to the web serversimilarly response bodies carry data back to the client. The body can contain arbitrary binary data (e.g., images, videos, audio tracks, software applications or text)
HTTP methods provides different methods and tell what a server need to perform based on method provided
HTTP status code:
Http status code is three digit number that indicates status of response from the server. It is seen in the response http message.
200 -> Ok,
302 -> Redirect. Go someplace else to get the resource.
404 -> Not Found. Can't find this resource. 500 -> Internal server error
If you like the blog,please share it with your friends and collegues . Thanks 😃