HTTP Requests and Responses

team bbl


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:

[View full width]

HTTP/1.1 200 OK Date: Wed, 17 Mar 2004 21:38:55 GMT Server: Apache/2.0.40 (Red Hat Linux) Accept-Ranges: bytes Connection: close Transfer-Encoding: chunked Content-Type: text/html <cr><lf> 50c <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!-- $Id: index.shtml,v 1.222 2004/02/24 02:05:15 hpa Exp $ --> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> <TITLE>The Linux Kernel Archives</TITLE> <LINK REL="icon" TYPE="image/png" HREF="images/tux16-16.png"> </HEAD> <BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000E0" VLINK="#8A1A49" ALINK="#ff0000" BACKGROUND="images/splash.png"> <CENTER><P><H1>The Linux Kernel Archives</H1></CENTER> <P> <CENTER> Welcome to the Linux Kernel Archives. This is the primary site for the Linux kernel source, but it has much more than just kernels. </CENTER>

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.

    team bbl



    Performance Tuning for Linux Servers
    Performance Tuning for Linux Servers
    ISBN: 0137136285
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net