CURLOPT_ACCEPT_ENCODING.3 4.4 KB

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