CURLOPT_TRANSFER_ENCODING.md (1644B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_TRANSFER_ENCODING 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_ACCEPT_ENCODING (3) 9 - CURLOPT_HTTP_TRANSFER_DECODING (3) 10 Protocol: 11 - HTTP 12 Added-in: 7.21.6 13 --- 14 15 # NAME 16 17 CURLOPT_TRANSFER_ENCODING - ask for HTTP Transfer Encoding 18 19 # SYNOPSIS 20 21 ~~~c 22 #include <curl/curl.h> 23 24 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRANSFER_ENCODING, 25 long enable); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a long set to 1L to *enable* or 0 to disable. 31 32 Adds a request for compressed Transfer Encoding in the outgoing HTTP 33 request. If the server supports this and so desires, it can respond with the 34 HTTP response sent using a compressed Transfer-Encoding that is automatically 35 uncompressed by libcurl on reception. 36 37 Transfer-Encoding differs slightly from the Content-Encoding you ask for with 38 CURLOPT_ACCEPT_ENCODING(3) in that a Transfer-Encoding is strictly meant 39 to be for the transfer and thus MUST be decoded before the data arrives in the 40 client. Traditionally, Transfer-Encoding has been much less used and supported 41 by both HTTP clients and HTTP servers. 42 43 # DEFAULT 44 45 0 46 47 # %PROTOCOLS% 48 49 # EXAMPLE 50 51 ~~~c 52 int main(void) 53 { 54 CURL *curl = curl_easy_init(); 55 if(curl) { 56 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 57 curl_easy_setopt(curl, CURLOPT_TRANSFER_ENCODING, 1L); 58 curl_easy_perform(curl); 59 } 60 } 61 ~~~ 62 63 # %AVAILABILITY% 64 65 # RETURN VALUE 66 67 curl_easy_setopt(3) returns a CURLcode indicating success or error. 68 69 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 70 libcurl-errors(3).