1CURLOPT_RANGE(3) curl_easy_setopt options CURLOPT_RANGE(3)
2
3
4
6 CURLOPT_RANGE - set byte range to request
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RANGE, char *range);
12
14 Pass a char * as parameter, which should contain the specified range
15 you want to retrieve. It should be in the format "X-Y", where either X
16 or Y may be left out and X and Y are byte indexes.
17
18 HTTP transfers also support several intervals, separated with commas as
19 in "X-Y,N-M". Using this kind of multiple intervals will cause the HTTP
20 server to send the response document in pieces (using standard MIME
21 separation techniques). Unfortunately, the HTTP standard (RFC 7233 sec‐
22 tion 3.1) allows servers to ignore range requests so even when you set
23 CURLOPT_RANGE(3) for a request, you may end up getting the full
24 response sent back.
25
26 For RTSP, the formatting of a range should follow RFC2326 Section
27 12.29. For RTSP, byte ranges are not permitted. Instead, ranges should
28 be given in npt, utc, or smpte formats.
29
30 For HTTP PUT uploads this option should not be used, since it may con‐
31 flict with other options. If you need to upload arbitrary parts of a
32 file (like for Amazon's web services) support is limited. We suggest
33 set resume position using CURLOPT_RESUME_FROM(3), set end (resume+size)
34 position using CURLOPT_INFILESIZE(3) and seek to the resume position
35 before initiating the transfer for each part. For more information
36 refer to https://curl.haxx.se/mail/lib-2019-05/0012.html
37
38 Pass a NULL to this option to disable the use of ranges.
39
40 The application does not have to keep the string around after setting
41 this option.
42
44 NULL
45
47 HTTP, FTP, FILE, RTSP and SFTP.
48
50 CURL *curl = curl_easy_init();
51 if(curl) {
52 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
53
54 /* get the first 200 bytes */
55 curl_easy_setopt(curl, CURLOPT_RANGE, "0-199");
56
57 /* Perform the request */
58 curl_easy_perform(curl);
59 }
60
62 FILE since 7.18.0, RTSP since 7.20.0
63
65 Returns CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insuf‐
66 ficient heap space.
67
69 CURLOPT_RESUME_FROM(3),
70
71
72
73libcurl 7.71.1 October 31, 2019 CURLOPT_RANGE(3)