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