1CURLOPT_ACCEPT_ENCODING(3) curl_easy_setopt options CURLOPT_ACCEPT_ENCODING(3)
2
3
4

NAME

6       CURLOPT_ACCEPT_ENCODING - enables automatic decompression of HTTP down‐
7       loads
8

SYNOPSIS

10       #include <curl/curl.h>
11
12       CURLcode curl_easy_setopt(CURL *handle,  CURLOPT_ACCEPT_ENCODING,  char
13       *enc);
14

DESCRIPTION

16       Pass a char * argument specifying what encoding you'd like.
17
18       Sets  the  contents  of  the  Accept-Encoding:  header  sent in an HTTP
19       request, and enables decoding of a response  when  a  Content-Encoding:
20       header is received.
21
22       libcurl  potentially  supports  several  different compressed encodings
23       depending on what support that has been built-in.
24
25       To aid applications not having to bother about what specific algorithms
26       this  particular  libcurl  build supports, libcurl allows a zero-length
27       string to be set ("") to ask for an Accept-Encoding: header to be  used
28       that contains all built-in supported encodings.
29
30       Alternatively,  you  can specify exactly the encoding or list of encod‐
31       ings you want in the response. Four encodings are supported:  identity,
32       meaning  non-compressed,  deflate which requests the server to compress
33       its response using the zlib algorithm, gzip  which  requests  the  gzip
34       algorithm  and (since curl 7.57.0) br which is brotli.  Provide them in
35       the string as a comma-separated list of accepted encodings, like:
36
37         "br, gzip, deflate".
38
39       Set CURLOPT_ACCEPT_ENCODING(3) to NULL to explicitly disable it,  which
40       makes  libcurl  not  send an Accept-Encoding: header and not decompress
41       received contents automatically.
42
43       You can also opt to just include the Accept-Encoding:  header  in  your
44       request  with CURLOPT_HTTPHEADER(3) but then there will be no automatic
45       decompressing when receiving data.
46
47       This is a request, not an order; the server may or may not do it.  This
48       option  must  be  set  (to  any non-NULL value) or else any unsolicited
49       encoding done by the server is ignored.
50
51       Servers might respond with  Content-Encoding  even  without  getting  a
52       Accept-Encoding: in the request. Servers might respond with a different
53       Content-Encoding than what was asked for in the request.
54
55       The Content-Length: servers send for a compressed response is  supposed
56       to  indicate the length of the compressed content so when auto decoding
57       is enabled it may not match the sum of  bytes  reported  by  the  write
58       callbacks  (although,  sending the length of the non-compressed content
59       is a common server mistake).
60
61       The application does not have to keep the string around  after  setting
62       this option.
63

DEFAULT

65       NULL
66

PROTOCOLS

68       HTTP
69

EXAMPLE

71       CURL *curl = curl_easy_init();
72       if(curl) {
73         curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
74
75         /* enable all supported built-in compressions */
76         curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
77
78         /* Perform the request */
79         curl_easy_perform(curl);
80       }
81

AVAILABILITY

83       This option was called CURLOPT_ENCODING before 7.21.6
84
85       The  specific libcurl you're using must have been built with zlib to be
86       able to decompress gzip and  deflate  responses  and  with  the  brotli
87       library to decompress brotli responses.
88

RETURN VALUE

90       Returns  CURLE_OK  if  the option is supported, CURLE_UNKNOWN_OPTION if
91       not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space.
92

SEE ALSO

94       CURLOPT_TRANSFER_ENCODING(3), CURLOPT_HTTPHEADER(3),  CURLOPT_HTTP_CON‐
95       TENT_DECODING(3),
96
97
98
99libcurl 7.61.1                  August 27, 2018     CURLOPT_ACCEPT_ENCODING(3)
Impressum