Web Server Design Week 7EncodingsIdentity EncodingContent Encoding vs. Transfer EncodingContent-EncodingsContent-Encoding Example (Correct)Content-Encoding Example (Incorrect)Why is it incorrect?CompressZipTransfer EncodingsChunked EncodingChunked Encoding ExampleChunked Encoding Example 2TE Request Header & Transfer-Encoding Response HeaderTE Example (Almost)Time / Space TradeoffTrailer Response HeaderTrailer ExampleTwo More Request Headers to ProcessUser-Agent Request HeaderReferer Request HeaderWeb Server DesignWeek 7Old Dominion UniversityDepartment of Computer ScienceCS 495/595 Spring 2012Michael L. Nelson <[email protected]>02/21/12Encodings•gzip–extension: .gz–(sometimes seen as x-gzip)•compress–extension: .Z–(sometimes seen as x-compress)•deflate –extension: .zip•identity –no encoding at all•chunked–breaks the body into a series of server-chosen “chunks”–optimization for dynamically produced contentIdentity Encoding•The default, “no transformation” encoding–“applying the identity encoding to a resource is an _________ operation”Content Encoding vs. Transfer EncodingClientOriginServer GET /bottle1 HTTP/1.1 HTTP/1.1 200 OKimages from: http://www.madeirawineguide.com/madeira_v300/Content-EncodingTransfer-EncodingContent-Encodings•“Content-Encoding is primarily used to allow a document to be compressed without losing the identity of its underlying media type.”–section 14.11Content-Encoding Example (Correct)AIHT:~/Desktop/cs595-s06 mln$ telnet www.cs.odu.edu 80Trying 128.82.4.2...Connected to xenon.cs.odu.edu.Escape character is '^]'.HEAD /~mln/pubs/bollenj_adaptive.ps.gz HTTP/1.1Host: www.cs.odu.eduConnection: closeHTTP/1.1 200 OKDate: Mon, 20 Feb 2006 04:30:25 GMTServer: Apache/1.3.26 (Unix) ApacheJServ/1.1.2 PHP/4.3.4Last-Modified: Thu, 25 Jul 2002 16:58:58 GMTETag: "1c16-139ea-3d402e52"Accept-Ranges: bytesContent-Length: 80362Connection: closeContent-Type: application/postscriptContent-Encoding: x-gzipConnection closed by foreign host.Content-Encoding Example (Incorrect)AIHT:~/Desktop mln$ telnet www.cs.odu.edu 80Trying 128.82.4.2...Connected to xenon.cs.odu.edu.Escape character is '^]'.HEAD /~mln/pubs/bollenj_adaptive.ps.gz HTTP/1.1Host: www.cs.odu.eduConnection: closeHTTP/1.1 200 OKDate: Mon, 26 Feb 2007 02:06:25 GMTServer: Apache/2.2.0Last-Modified: Thu, 25 Jul 2002 16:58:58 GMTETag: "1c16-139ea-92cab880"Accept-Ranges: bytesContent-Length: 80362Connection: closeContent-Type: application/x-gzipConnection closed by foreign host.Wrong, Wrong, Wrong!!!!!!!Why is it incorrect?% telnet www.cs.odu.edu 80Trying 128.82.4.2...Connected to xenon.cs.odu.edu.Escape character is '^]'.HEAD /~mln/adl98.ppt.gz HTTP/1.1Host: www.cs.odu.eduConnection: closeHTTP/1.1 200 OKDate: Mon, 20 Feb 2012 02:21:29 GMTServer: Apache/2.2.17 (Unix) PHP/5.3.5 mod_ssl/2.2.17 OpenSSL/0.9.8qLast-Modified: Mon, 25 Mar 2002 17:15:44 GMTETag: "33e94-39d06961d5000"Accept-Ranges: bytesContent-Length: 212628Connection: closeContent-Type: application/x-gzipthe encodings are the same,the types are differentCompress% telnet www.cs.odu.edu 80Trying 128.82.4.2...Connected to xenon.cs.odu.edu.Escape character is '^]'.HEAD /~mln/ntrs.tar.Z HTTP/1.1Host: www.cs.odu.eduConnection: closeHTTP/1.1 200 OKDate: Mon, 20 Feb 2012 02:31:45 GMTServer: Apache/2.2.17 (Unix) PHP/5.3.5 mod_ssl/2.2.17 OpenSSL/0.9.8qLast-Modified: Thu, 12 Jun 2003 18:45:46 GMTETag: "7fffffff-3bfeb99a3ca80"Accept-Ranges: bytesContent-Length: 2147483647Connection: closeContent-Type: application/x-compressZip% telnet www.cs.odu.edu 80Trying 128.82.4.2...Connected to xenon.cs.odu.edu.Escape character is '^]'.HEAD /~mln/michael-hany.zip HTTP/1.1Host: www.cs.odu.eduConnection: closeHTTP/1.1 200 OKDate: Mon, 20 Feb 2012 03:16:35 GMTServer: Apache/2.2.17 (Unix) PHP/5.3.5 mod_ssl/2.2.17 OpenSSL/0.9.8qLast-Modified: Fri, 17 Feb 2012 20:43:13 GMTETag: "223e5a1-4b92efe4dfc40"Accept-Ranges: bytesContent-Length: 35906977Connection: closeContent-Type: application/zipTransfer Encodings•“Transfer-Encoding is a property of the message, not of the entity, and thus MAY be added or removed by any application along the request/response chain.”–section 4.5Chunked Encoding•“The chunked encoding modifies the body of a message in order to transfer it as a series of chunks, each with its own size indicator, followed by an OPTIONAL trailer containing entity-header fields. This allows dynamically produced content to be transferred along with the information necessary for the recipient to verify that it has received the full message.”–sections 3.6.1, 19.4.6Chunked Encoding ExampleAIHT:~/Desktop/cs595-s06 mln$ telnet www.cs.odu.edu 80 Trying 128.82.4.2...Connected to xenon.cs.odu.edu.Escape character is '^]'.GET /~mln HTTP/1.1Connection: closeHost: www.cs.odu.eduConnection closed by foreign host.HTTP/1.1 301 Moved PermanentlyDate: Mon, 09 Jan 2006 19:32:24 GMTServer: Apache/1.3.26 (Unix) ApacheJServ/1.1.2 PHP/4.3.4Location: http://www.cs.odu.edu/~mln/Connection: closeTransfer-Encoding: chunkedContent-Type: text/html; charset=iso-8859-112e<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><HTML><HEAD><TITLE>301 Moved Permanently</TITLE></HEAD><BODY><H1>Moved Permanently</H1>The document has moved <A HREF="http://www.cs.odu.edu/~mln/">here</A>.<P><HR><ADDRESS>Apache/1.3.26 Server at www.cs.odu.edu Port 80</ADDRESS></BODY></HTML>0Chunked Encoding Example 2AIHT:~/Desktop/cs595-s06 mln$ telnet www.cs.odu.edu 80Trying 128.82.4.2...Connected to xenon.cs.odu.edu.Escape character is '^]'.GET / HTTP/1.1Host: www.cs.odu.eduHTTP/1.1 200 OKDate: Tue, 21 Feb 2006 03:54:31 GMTServer: Apache/1.3.26 (Unix) ApacheJServ/1.1.2 PHP/4.3.4Transfer-Encoding: chunkedContent-Type: text/html5f6<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- saved from url=(0036)http://www.cs.odu.edu/newcssite/new/ --><!-- saved from url=(0019)http://sci.odu.edu/ --><HTML xmlns:st1 = "urn:schemas-microsoft-com:office:smarttags"><HEAD><TITLE>Department Of Computer Science</TITLE>[lots of html deleted][demo this example to see the various “chunks”]0TE Request Header & Transfer-Encoding Response Header•Client specifies preferences for transfer encoding in the “TE:” header–section 14.39•Server marks the encoding used with the “Transfer-Encoding” header–section 14.41•Both headers use the same encoding values available with “Content-Encoding”, plus the special “chunked” encoding and the “Trailers”
View Full Document