1CURLOPT_RANGE(3)           curl_easy_setopt options           CURLOPT_RANGE(3)
2
3
4

NAME

6       CURLOPT_RANGE - byte range to request
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RANGE, char *range);
12

DESCRIPTION

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  re‐
24       sponse 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.
32
33       Pass a NULL to this option to disable the use of ranges.
34
35       The application does not have to keep the string around  after  setting
36       this option.
37

DEFAULT

39       NULL
40

PROTOCOLS

42       HTTP, FTP, FILE, RTSP and SFTP.
43

EXAMPLE

45       CURL *curl = curl_easy_init();
46       if(curl) {
47         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
48
49         /* get the first 200 bytes */
50         curl_easy_setopt(curl, CURLOPT_RANGE, "0-199");
51
52         /* Perform the request */
53         curl_easy_perform(curl);
54       }
55

AVAILABILITY

57       FILE since 7.18.0, RTSP since 7.20.0
58

RETURN VALUE

60       Returns  CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insuf‐
61       ficient heap space.
62

SEE ALSO

64       CURLOPT_RESUME_FROM(3),
65
66
67
68libcurl 7.85.0                   May 17, 2022                 CURLOPT_RANGE(3)
Impressum