Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. HTTP Content Negotiation > Encoding Negotiation

Encoding Negotiation

Clients can also negotiate the encoding of a message body. To save on network bandwidth, encodings are generally used to compress messages before they are sent. The most common algorithm for encoding is GZIP compression. Clients use the Accept-Encoding header to specify which encodings they support. For example:

GET http://example.com/stuff
Accept-Encoding: gzip, deflate

Here, the client is saying that it wants its response either compressed using GZIP or it wants it uncompressed (deflate).

The Accept-Encoding header also supports preference qualifiers:

GET http://example.com/stuff
Accept-Encoding: gzip;q=1.0, compress;0.5; deflate;q=0.1

Here, gzip is desired first, then compress, followed by deflate. In practice, clients use the Accept-Encoding header to tell the server which encoding formats they support and they really don’t care which one the server uses.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint