Wednesday, March 15, 2017

What is HTTP Protocol

HTTP: HTTP stands for Hypertext Transfer Protocol. HTTP is base for WWW (World Wide Web => internet) to communicate data between client and server. HTTP is stateless protocol that is used by its request methods, status like error code and headers of request or response. In this post, we will discuss HTTP for computer students and for developers. Let’s have a look on few parts of HTTP. There are mainly three features of HTTP.

First: Connection-less, HTTP is a connectionless. what happens when we make request to server for some data or images. so, it makes connection from client to server and get response also that is also a connection from server to client. In fact, the scenario is that when a client browser send request to server after sending request it discontinue the connection and wait for server, at the other hand server receive request and complete process and then make again connection to client and send back the response to client.

Second: Media independent, by using HTTP we can send any type of data but our client and server, both should know the content type and understand that how they will handle the data. there is no restriction just we must pass content type by using correct MIME-TYPE so it become easy to handle for the server.

Third: Stateless, HTTP is connectionless and stateless because client and server don't know each other after the request is completed. server and client know each other only when they are communicating with each other after completion connection is finished and client and server become unknown to each other. 

In HTTP/1.0 for each new request/response between server and client they create a new connection, but in HTTP/1.1 have the capability to make one or more request/response.
When we use term HTTP protocol then it means request/response based to the client/server architecture. as shown in below picture that web browser or search engines behave like a HTTP client and Web Server becomes servers.


What is Client: An HTTP client may be a browser or search engine or robot, is used to send request to server in the form of method, any protocol version or using URI which is attached with a specific MIME-TYPE which tell the server it contains a client information, a modifier and may a having content in the body of request.

What is Server: HTTP server who process the client request and send response to client. This response may have any protocol version or maybe it gives response in error code like status code 404 Not found, 401 Unauthorized, a response has some MIME-TYPE and may be the response data in body content. 

HTTP Versions: HTTP basically used HTTP/. version scheme. now updated is HTTP/2 actually HTTP/2.0. Example:

HTTP/1.0 or HTTP/1.1 or HTTP/2.0

What is URI: URI stands for Uniform Resource Identifier. it is used to represent any website or WebApi and it have all basic info of the resource like location, name etc.
Syntax for URI:
URI = "http:" "//" HTTP_HOST/HTTPS [ ":" port ] [ abs_path [ "?" query string ]]

Let have a look on below example for understanding:
1. http://abc.com:80/~jdoe/finaltext.html
2. http://ABC.com/%7Ejdoe/finaltext.html
3. http://ABC.com:/%7ejdoe/finaltext.html

These all above mentioned URI are same/equivalent. why? because as we know 80 is default port so it does not matter either its written or not, ~ notation HEX is %7E so either we enter the ~ or %7E it will be same and browser will convert this to HEX and understand automatically and also there is no restriction for case sensitive.

HTTP Request Methods:
1. GET: it is used to get some data or retrieve any information from the server. The basic purpose for what it is used for getting something from the server only.
2. HEAD: it’s used is same like GET but it is basically for header section information and give the status of request.
3. POST: mostly POST is used to send data or record to server for processing either insert into data or some other operation like file upload etc.
4. PUT: used to update the data or file or records, its function is to replace the current data with newly uploaded.
5. DELETE: as the name show it will remove all record on target server by the provided URI.
6. CONNECT: is used for tunneling between client and server. it will create a tunnel to server indicated from the URI.
7. OPTIONS: it is used to check the communication is allowed between the client and server.
8. TRACE: is used to send a response back to test with the path to the target resource.
In this post, we try to just a have look on mandatory part required for a developer to understand exactly what is HTTP this is not full description but it will give you good understanding as web developer.

No comments:

Post a Comment