|
HTTP requests and responses are unusual compared to other client/server exchanges in that they are ASCII text-based rather than binary encoded, as in NFS. This is an artifact of how the web was developed, yet it is convenient in that it allows humans to easily read the generated requests and responses. The following is an example of a web request generated by a browser (in this case, Mozilla): GET /index.html HTTP/1.1Host: www.kernel.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Accept:text/xml,application/xml,application/xhtml+xml, text/html; q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg, image/gif;q=0.2,text/css,*/*;q=0.1 Accept-Language: en-us, en;q=0.50 Accept-Encoding: identity;q=1.0, *;q=0 Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66 Cache-Control: max-age=0 Connection: close <cr><lf> Note that the first line contains the request for the file desired and that each following line contains headers with appropriate values. The GET request specifies both the file requested and the protocol version used by the client. The headers communicate information to the server about what kinds of features this particular client supports. In this case, the client is Mozilla, which accepts various formats such as HTML text, GIF, JPEG, and XML, and uses the English language. This negotiation allows clients and servers to dynamically learn each others' capabilities so that they can communicate most effectively. We continue the example with the server's ASCII HTTP response:
This response shows that the server understood the client request and is providing the response (indicated by the 200 OK message). In addition, the server uses the headers to tell the client that it is using a feature to send messages in chunks rather than all at once (called chunked encoding) and is capable of sending subsets of the response rather than the entire response (called byte range requests). Finally, the HTML content is returned, which is parsed and displayed by the browser. This exchange is just an example of one of the ways in which HTTP works, albeit perhaps the most common example. HTTP is a large, complex protocol, and elaborating on its many intricacies is beyond the scope of this book. We refer you to Krishnamurthy and Rexford 2001 for an excellent overview of HTTP. |
|