1 2 Content Encoding Support for libcurl 3 4* About content encodings: 5 6HTTP/1.1 [RFC 2616] specifies that a client may request that a server encode 7its response. This is usually used to compress a response using one of a set 8of commonly available compression techniques. These schemes are `deflate' (the 9zlib algorithm), `gzip' and `compress' [sec 3.5, RFC 2616]. A client requests 10that the sever perform an encoding by including an Accept-Encoding header in 11the request document. The value of the header should be one of the recognized 12tokens `deflate', ... (there's a way to register new schemes/tokens, see sec 133.5 of the spec). A server MAY honor the client's encoding request. When a 14response is encoded, the server includes a Content-Encoding header in the 15response. The value of the Content-Encoding header indicates which scheme was 16used to encode the data. 17 18A client may tell a server that it can understand several different encoding 19schemes. In this case the server may choose any one of those and use it to 20encode the response (indicating which one using the Content-Encoding header). 21It's also possible for a client to attach priorities to different schemes so 22that the server knows which it prefers. See sec 14.3 of RFC 2616 for more 23information on the Accept-Encoding header. 24 25* Current support for content encoding: 26 27Support for the 'deflate' and 'gzip' content encoding are supported by 28libcurl. Both regular and chunked transfers should work fine. The library 29zlib is required for this feature. 'deflate' support was added by James 30Gallagher, and support for the 'gzip' encoding was added by Dan Fandrich. 31 32* The libcurl interface: 33 34To cause libcurl to request a content encoding use: 35 36 curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, <string>) 37 38where <string> is the intended value of the Accept-Encoding header. 39 40Currently, libcurl only understands how to process responses that use the 41"deflate" or "gzip" Content-Encoding, so the only values for 42CURLOPT_ACCEPT_ENCODING that will work (besides "identity," which does 43nothing) are "deflate" and "gzip" If a response is encoded using the 44"compress" or methods, libcurl will return an error indicating that the 45response could not be decoded. If <string> is NULL no Accept-Encoding header 46is generated. If <string> is a zero-length string, then an Accept-Encoding 47header containing all supported encodings will be generated. 48 49The CURLOPT_ACCEPT_ENCODING must be set to any non-NULL value for content to 50be automatically decoded. If it is not set and the server still sends encoded 51content (despite not having been asked), the data is returned in its raw form 52and the Content-Encoding type is not checked. 53 54* The curl interface: 55 56Use the --compressed option with curl to cause it to ask servers to compress 57responses using any format supported by curl. 58 59James Gallagher <jgallagher@gso.uri.edu> 60Dan Fandrich <dan@coneharvesters.com> 61