Introduction to HTTP - Hypertext Transfer Protocol

Apr 10
07:15

2008

Atul Jindal

Atul Jindal

  • Share this article on Facebook
  • Share this article on Twitter
  • Share this article on Linkedin

HTTP is one of the most successful and widely used protocols on the Internet today. It is application-layer protocol used to transmit and receive hype...

mediaimage

HTTP is one of the most successful and widely used protocols on the Internet today. It is application-layer protocol used to transmit and receive hypertext pages. HTTP allows a client usually a web browser to send a simple request and receive response back from the server. Whenever you write a URL in address bar of you browser,Introduction to HTTP - Hypertext Transfer Protocol Articles your browser firstly contacts the web server, web server locates the requested page and sends the appropriate response. These requests and responses are issued in HTTP.

Each HTTP cycle has following steps:

Connection

The connection is established between a web browser and a web server. The connection is established via TCP/IP protocols over particular port generally port 80 is used. However, HTTP is not used to establish connection, it only defines the rules that specify how they communicate.

Request

The web browser sends a request to server, specifying the resource to retrieve. HTTP defines the set of rules for sending the request. Every HTTP request consists of Request-Line, Request-Headers and Message-Body. Sample HTTP request is shown below.

GET /index.htm HTTP/1.1

HOST: www.google.com

Accept: text/html, text/plain

User-Agent: Mozilla/4.0

Each HTTP request has request line and consists of request methods, URI, and HTTP version. After Request-Line, Request-Header starts and providing the characteristics associated with data returned.

Response

It is the response send by the web server to client. The server firstly locates the requested document and sends the appropriate response. However there is a format specified by HTTP to send the response from server. Every HTTP response consists of Status-Line, Response-Headers and Message-Body. Sample HTTP response is shown below.

HTTP/1.1 200 OK

Server: Apache/1.3.3.7

Date: Mon, 23 May 2005 22:38:34 GMT

Accept-Ranges: bytes

Content-Type: text/html

Content-Length: 512

Last-Modified: Tue, 18 Jan 2007 10:12:30 GMT

Connection: close

hello worldHello world

The first line of the every HTTP response is called the Status-Line and consists of numeric status code returned along with reason phrase. It is the response returned associated with the HTTP request. After Status-Line, Response-Header starts and providing the characteristics associated with data returned.

Close

Finally connection is closed. After each request and response cycle the connection is closed. Each time the web browser makes request, new connection is established. There is no account for the previous requested resource on web server or I can say that there is no session maintained. This makes HTTP a stateless protocol.