2
0

CURLOPT_ACCEPT_ENCODING.3 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_ACCEPT_ENCODING 3 "17 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_ACCEPT_ENCODING \- automatic decompression of HTTP downloads
  26. .SH SYNOPSIS
  27. .nf
  28. #include <curl/curl.h>
  29. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ACCEPT_ENCODING, char *enc);
  30. .fi
  31. .SH DESCRIPTION
  32. Pass a char * argument specifying what encoding you would like.
  33. Sets the contents of the Accept-Encoding: header sent in an HTTP request, and
  34. enables decoding of a response when a Content-Encoding: header is received.
  35. libcurl potentially supports several different compressed encodings depending
  36. on what support that has been built-in.
  37. To aid applications not having to bother about what specific algorithms this
  38. particular libcurl build supports, libcurl allows a zero-length string to be
  39. set ("") to ask for an Accept-Encoding: header to be used that contains all
  40. built-in supported encodings.
  41. Alternatively, you can specify exactly the encoding or list of encodings you
  42. want in the response. Four encodings are supported: \fIidentity\fP, meaning
  43. non-compressed, \fIdeflate\fP which requests the server to compress its
  44. response using the zlib algorithm, \fIgzip\fP which requests the gzip
  45. algorithm, (since curl 7.57.0) \fIbr\fP which is brotli and (since curl
  46. 7.72.0) \fIzstd\fP which is zstd. Provide them in the string as a
  47. comma-separated list of accepted encodings, like:
  48. "br, gzip, deflate".
  49. Set \fICURLOPT_ACCEPT_ENCODING(3)\fP to NULL to explicitly disable it, which
  50. makes libcurl not send an Accept-Encoding: header and not decompress received
  51. contents automatically.
  52. You can also opt to just include the Accept-Encoding: header in your request
  53. with \fICURLOPT_HTTPHEADER(3)\fP but then there will be no automatic
  54. decompressing when receiving data.
  55. This is a request, not an order; the server may or may not do it. This option
  56. must be set (to any non-NULL value) or else any unsolicited encoding done by
  57. the server is ignored.
  58. Servers might respond with Content-Encoding even without getting a
  59. Accept-Encoding: in the request. Servers might respond with a different
  60. Content-Encoding than what was asked for in the request.
  61. The Content-Length: servers send for a compressed response is supposed to
  62. indicate the length of the compressed content so when auto decoding is enabled
  63. it may not match the sum of bytes reported by the write callbacks (although,
  64. sending the length of the non-compressed content is a common server mistake).
  65. The application does not have to keep the string around after setting this
  66. option.
  67. .SH DEFAULT
  68. NULL
  69. .SH PROTOCOLS
  70. HTTP
  71. .SH EXAMPLE
  72. .nf
  73. CURL *curl = curl_easy_init();
  74. if(curl) {
  75. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  76. /* enable all supported built-in compressions */
  77. curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
  78. /* Perform the request */
  79. curl_easy_perform(curl);
  80. }
  81. .fi
  82. .SH AVAILABILITY
  83. This option was called CURLOPT_ENCODING before 7.21.6
  84. The specific libcurl you are using must have been built with zlib to be able to
  85. decompress gzip and deflate responses, with the brotli library to
  86. decompress brotli responses and with the zstd library to decompress zstd
  87. responses.
  88. .SH RETURN VALUE
  89. Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
  90. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  91. .SH "SEE ALSO"
  92. .BR CURLOPT_TRANSFER_ENCODING "(3), " CURLOPT_HTTPHEADER "(3), "
  93. .BR CURLOPT_HTTP_CONTENT_DECODING "(3), "