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