HTML and CSS Reference
In-Depth Information
requested resources, such as an HTML page, as well as additional information about the
page. HTTP was also designed for fetching documents; HTTP/1.0 sufficed for a single
document request from a server. However, as the Web grew beyond simple document
sharing and began to include more interactivity, connectivity needed to be refined to
enable quicker response time between the browser request and the server response.
In HTTP/1.0, a separate connection was made for every request to the server, which,
to say the least, did not scale well. The next revision of HTTP, HTTP/1.1, added reusable
connections. With the introduction of reusable connections, browsers could initialize a
connection to a web server to retrieve the HTML page, then reuse the same connection
to retrieve resources like images, scripts, and so on. HTTP/1.1 reduced latency between
requests by reducing the number of connections that had to be made from clients to servers.
HTTP is stateless, which means it treats each request as unique and independent.
There are advantages to a stateless protocol: for example, the server doesn't need to keep
information about the session and thus doesn't require storage of that data. However, this
also means that redundant information about the request is sent for every HTTP request
and response.
Let's take a look at an example HTTP/1.1 request from a client to a server. Listing 1-1
shows a complete HTTP request containing several HTTP headers.
Listing 1-1. HTTP/1.1 Request Headers from the Client to the Server
GET /PollingStock/PollingStock HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
Gecko/20091102 Firefox/3.5.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:8080/PollingStock/
Cookie: showInheritedConstant=false; showInheritedProtectedConst
ant=false; showInheritedProperty=false; showInheritedProtectedPr
operty=false; showInheritedMethod=false; showInheritedProtectedM
ethod=false; showInheritedEvent=false; showInheritedStyle=false;
Listing 1-2 shows an example HTTP/1.1 response from a server to a client.
Listing 1-2. HTTP/1.1 Response Headers from the Server to the Client
HTTP/1.x 200 OK
X-Powered-By: Servlet/2.5
Server: Sun Java System Application Server 9.1_02
Content-Type: text/html;charset=UTF-8
Content-Length: 321
Date: Wed, 06 Dec 2012 00:32:46 GMT
Search WWH ::

Custom Search