Web design conference - D:rss-book19code>python ZippyClient.py connect: (thorne.id.au, 80) send: GET /feeds
D:rss-book19code>python ZippyClient.py connect: (thorne.id.au, 80) send: GET /feeds HTTP/1.0rnHost: thorne.id.aurnUser-agent: Python-urllib/2. 1rnAccept-encoding: gziprnrn reply: HTTP/1.0 200 OKrn header: Date: Thu, 24 Jun 2004 13:40:51 GMT header: Content-length: 61411 header: Content-encoding: gzip header: Content-type: text/html header: Server: TwistedWeb/1.2.0 ZIPPED! Note the values for Content-length (61411) and Content-encoding (gzip) returned by the server. 5. Now modify the source code again, this time to comment out this line by adding a # at the start: # request.add_header( Accept-Encoding , gzip ) 6. Again open a command window and type: python ZippyClient.py The result this time should be slightly different, something like this: D:rss-book19code>python ZippyClient.py connect: (thorne.id.au, 80) send: GET /feeds HTTP/1.0rnHost: thorne.id.aurnUser-agent: Python-urllib/2. 1rnrn reply: HTTP/1.0 200 OKrn header: Date: Thu, 24 Jun 2004 13:46:08 GMT header: Content-length: 204733 header: Content-type: text/html header: Server: TwistedWeb/1.2.0 Note the lack of gzip, and the considerably larger value of Content-length, 204733 bytes, which shows the gzip compression would save around three-fourths of the original bandwidth. How It Works The kind of data a client is prepared to accept is passed to the server in the header part of its request. When the server is told that the client can accept gzip compressed data, it may supply the material zipped. Note that this is all entirely optional. If the server does compress the feed data then the client will need to know so it can uncompress it. In this case the response header will have a value gzip in its Content-Encoding field. Figure 19-6 shows relevant parts of client-server HTTP dialog box where gzip is supported. Most Web servers offer very good support for compression, and it s pretty straightforward to support it on the client side too. 228 Chapter 19
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.