README.encoding 2.8 KB

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