1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_RANGE 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_LOW_SPEED_LIMIT (3) 9 - CURLOPT_MAXFILESIZE_LARGE (3) 10 - CURLOPT_MAX_RECV_SPEED_LARGE (3) 11 - CURLOPT_RESUME_FROM (3) 12Protocol: 13 - HTTP 14 - FTP 15 - FILE 16 - RTSP 17 - SFTP 18--- 19 20# NAME 21 22CURLOPT_RANGE - byte range to request 23 24# SYNOPSIS 25 26~~~c 27#include <curl/curl.h> 28 29CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RANGE, char *range); 30~~~ 31 32# DESCRIPTION 33 34Pass a char pointer as parameter, which should contain the specified range you 35want to retrieve. It should be in the format "X-Y", where either X or Y may be 36left out and X and Y are byte indexes. 37 38HTTP transfers also support several intervals, separated with commas as in 39*"X-Y,N-M"*. Using this kind of multiple intervals causes the HTTP server 40to send the response document in pieces (using standard MIME separation 41techniques). Unfortunately, the HTTP standard (RFC 7233 section 3.1) allows 42servers to ignore range requests so even when you set CURLOPT_RANGE(3) 43for a request, you may end up getting the full response sent back. 44 45For RTSP, the formatting of a range should follow RFC 2326 Section 12.29. For 46RTSP, byte ranges are **not** permitted. Instead, ranges should be given in 47**npt**, **utc**, or **smpte** formats. 48 49For HTTP PUT uploads this option should not be used, since it may conflict with 50other options. 51 52Pass a NULL to this option to disable the use of ranges. 53 54The application does not have to keep the string around after setting this 55option. 56 57# DEFAULT 58 59NULL 60 61# EXAMPLE 62 63~~~c 64int main(void) 65{ 66 CURL *curl = curl_easy_init(); 67 if(curl) { 68 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 69 70 /* get the first 200 bytes */ 71 curl_easy_setopt(curl, CURLOPT_RANGE, "0-199"); 72 73 /* Perform the request */ 74 curl_easy_perform(curl); 75 } 76} 77~~~ 78 79# AVAILABILITY 80 81FILE since 7.18.0, RTSP since 7.20.0 82 83# RETURN VALUE 84 85Returns CURLE_OK on success or 86CURLE_OUT_OF_MEMORY if there was insufficient heap space. 87