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