What is HTTP?
It stands for hypertext transfer protocol. Using this protocol the
client sends a request to the server and based on the request the
server and the web browser respond to the client.
In a nutshell, we can say that it’s the base using which one
computer (the client) communicates with another (the server)
HTTP request
Once the connection is established using the Http
protocol between client and server, the client then sends a
request in the form of binary data to the server asking to access
specific files or information from the server.
What’s actually inside the request
Every HTTP request contains three elements which are:- Request
Line, Request Header, Body of Request(optional).
Request line:-
1. It specifies the method, which tells the server what to do
with the information or resource.
2. It contains the URL of the request which is used to find the
resource on the server.
3. It also specifies HTTP protocol version being used (Ex. HTTP/
1.0 or HTTP/1.1)
Request Header:- It consists of 0 or more headers.
1. The headers are used to pass more information about the
request so that using the request headers the server knows
how to deal with the information the client is demanding.
2. I.e What should be the language of content to be displayed,
what should be the content-type that client demands.
Request Body:-
1. This is an optional part of the HTTP request which is used to
send additional data to the server
HTTP Response
The response from the server with the target to provide the client
with the desired resources is HTTP Response.
Ok now let’s look inside the Response from the server:-
Status line:- HTTP/1.1 302 Found This is how the status line of
the response header looks like. It contains the HTTP protocol
version, status code, Reason phrase (known as status text).
Response Header:- There can be one or more response header
lines and they are used to pass additional information to the client
from the server.
Response Body:- The response body contains the resource
demanded by the client. If the request is unsuccessful then the
response body contains the reason for the error, it may also
contain the steps to be done by the client to complete the request
successfully.