When a site user opens a web page in a web browser's window, the browser generates a request message and sends it using HTTP protocol to the web server. The web server directs this HTTP request to your web application.
HTTP (stands for Hyper Text Transfer Protocol) -- a protocol for transferring data in the form of hyper text documents (web pages). HTTP is based on the client-server technology: the client initiates a connection and sends a request to web server, and the server waits for a connection, performs the necessary actions and returns a response message back.
Thus, the main underlying goal of any web application is handling the HTTP request and producing an HTTP response typically containing the HTML code of the requested web page. The response is sent by the web server to the client web browser and the browser displays a web page on the screen.
A typical HTTP request is presented below:
GET http://www.w3schools.com/ HTTP/1.1
Host: www.w3schools.com
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US;q=0.8,en;q=0.6
Cookie: __gads=ID=42213729da4df8df:T=1368250765:S=ALNI_MaOAFe3U1T9Syh;
(empty line)
(message body goes here)
The HTTP request message above consists of three parts:
The headers and the message body may be absent, but the starting line is always present in the request, because it indicates its type and URL.
The server response for the above request is presented below:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
Set-Cookie: ASPSESSIONIDQQRBACTR=FOCCINICEFAMEKODNKIBFOJP; path=/
X-Powered-By: ASP.NET
Date: Sun, 04 Aug 2013 13:33:59 GMT
Content-Length: 8434
(empty line)
(page content follows)
As you can see from the dump above, the HTTP response has almost the same format as the request:
The starting line (line 1) represents the HTTP protocol version, response status code and message (200 OK).
Optional headers (lines 2-10) provide various meta information about the response.
Optional message body follows the headers, and must be separated from headers by an empty line. The message body typically contains the HTML code of the requested web page.