What is http: HTTP full form HyperText Transfer Protocol used mainly to access data on the World Wide Web. HTTP is a Server and Client communication Protocol, which is primarily set of rules for formating and transferring webpage data (text, images, video and Multimedia files) over the world wide web. This is the Protocol used to create communication between Web Servers and Web Users. HTTP is an application layer Protocol that works on the top of the TCP/IP suite of Protocols.
HTTP protocol basically uses server and client model. It acts as a request-response protocol. For Example, A client which is use web browser and a server is a Web host that hosts the website. Whenever a client transmits a request to the Website server, HTTP protocol proceeds that request and creates a connection between client and server through TCP. After that HTTP sends a request to the server, which picks up the requested data and HTTP sends the response back to the client. Let's look into the depth how these requests work.
HTTP protocol functions like a combination of FTP and SMTP. It is similar to FTP because it transfers files and uses the services of TCP. However, it is much simpler than FTP because it uses only one TCP connection. There is no separate control connection; only data is transferred between the client and the server.
HTTP protocol is like SMTP protocol because the data transferred between the client and the server look like SMTP messages. In addition, MIME-like headers control the format of the messages. However, HTTP differs from SMTP in the way the messages are sent from the client to the server and from the server to the client. Unlike SMTP, the HTTP messages are not destined to be read by humans; they are read and interpreted by the HTTP server and HTTP client (browser). SMTP messages are stored and forwarded, but HTTP messages are delivered immediately.
The idea of HTTP protocol is very simple. A client sends a request, which looks like mail, to the server. The server sends the response, which looks like a mail reply, to the client. The request and response messages carry data in the form of a letter with MIME-like format.
The commands from the client to the server are embedded in a letter-like request message. The contents of the requested file or other information are embedded in a letter-like response message.
History of HTTP
Ted Nelson in 1965 coined the term hypertext. The original HTTP invented by Tim Berners-Lee at CERN in 1989.
Features of HTTP Protocol
The features of the http protocol are as follows:
• Http is Connectionless: The http client, i.e., the web browser makes an http request and waits for the server to respond. Now, it is the task of the server to process the request made by the client. So after processing, the server gives the response to the client. After receiving the response, the client disconnects the connection.
• Http is media independent: Here, media independent means that any data can send. Also, we have to mention the content type as per the requirement of the client and the server.
• Http is stateless: http is a stateless protocol. Only during the current request, the client and the server know about each other and when the connection disconnects, both client and the server forgets about each other. Due to this nature, both the client and the server do not retain the information between the different requests processed.
Basic architecture client/server
As we know, it is a client/server based architecture. So, it makes use of a request/response protocol. In this, web browsers, search engines, act as the client of the system and the web server acts as the server of the system.
This system is completely explained through the diagram also.
Http Client: The http client makes the request in the form of a request method. Which is followed by the message body over a TCP/IP connection.
Http Server: The request sent by the client, is responded by the server in the form of a status line followed by the other necessary information with the message body.
HTTP Request Methods
Http Protocol can use two case sensitive request-response Methods between client/server such as GET and POST that are used to handle form submissions.
A GET Requests data from a specified resource using a given URI to retrieve data.
A POST request Submits data to be processed to a specified resource to the server.
NOTE: URLs that start with "http://" are use port 80 by default and URL with "https://" are secure connection use port 443.
Differences between "GET" and "POST" Methods
"GET" is basically appends limited amount of variable and their values to the URL string because data is sent in header. It is non secure connection because variable and their values are exposed in URL.
"POST" appends large amount of data, because of data is sent in the message body.It is secure connection because variable and their values are not exposed in URL.
What is an HTTP request?
A Http request message consists of a request line, headers and sometimes a body.
An HTTP request is a way that web browsers ask for information to load website pages. HTTP request contains HTTP version type, a URL, HTTP request headers and HTTP body.
HTTP request Headers: HTTP request headers include text information saved in key-value pairs and these are contained in every HTTP request.
URL: A client that wants to access a document needs an address. To facilitate the access of documents distributed throughout the world, HTTP protocol uses the concept of locations. The World Wide Web uses a locator called a URL to identify and intertribal data.
URL is called as (Uniform Resource Locator). A URL is an internet address of any website in common format http://ecomputernotes.com, A URL has three parts: Method: //Host/Path. which is used for accessing any file, document or website.
What is an HTTP response?
An HTTP response means when the web client gets the answer back from the web server. It contains the information that was asked for in the HTTP request. HTTP response contains an HTTP status code, HTTP response headers, and HTTP body.
HTTP status codes: Many times when a client sends a request to the server and If the HTTP request is not correct then the error comes. These errors are shown in numeric codes. These are also called as HTTP status codes. These status codes are given by the server to identify the problem. If a client does not know the difference between codes how a client can solve the problem so the client has to know about every code. Some common codes are shown below.
3.404-“File not found”
HTTP is a stateless protocol: HTTP is a stateless protocol and it was likewise necessary. Because it executes every command independently without knowing the other commands those came before it. Otherwise, if a client sends multiple requests to the web server, the web server will handle multiple requests from one connection for a long time. That's why HTTP is a stateless protocol.
Working of the HTTP protocol
The working of the HTTP protocol is explained step by step as follows:
Step 1: Establishing a TCP/IP connection by the client.
The first step is initiating a TCP connection with the server by the client. Once the connection established, the browser and the server access TCP through their socket interfaces.
Step 2: Initiating an HTTP GET request to the server by the client.
The http request first line of the message is called the request line. The lines below the request line are known as header lines.
The request line has three fields- method, URL, and version. Method field can take several values like GET, POST, HEAD, PUT and DELETE, etc. The GET method used when the browser requests an object, with the requested object identified in the URL field.
The meaning of all these values is:
GET: it retrieves those document which identified in the URL.
POST: it will give information to the server.
HEAD: it retrieves the meta information about the document identified in the URL.
PUT: it stores those documents which are underspecified URL.
DELETE: it deletes the specified URL.
TRACE: it will loopback the request message.
Step 3: HTTP Server Response to an HTTP GET Request.
HTTP response message has three sections- status line, header lines, and an entity body. Further, the status line has 3 fields- version, status code, and phrase. After then, header lines are there. In the end, there is the entity body, which contains the requested message itself.
What is HTTPS?
HTTPS is a Hyper Text Transfer Protocol Secure. This is the secure version of HTTP Protocol. HTTPS means a secure layer between client and server. HTTPS encrypted our data by Transport Security Layer (TLS). HTTPS is a sign of security most of the websites are secured with HTTPS.