CURLOPT_RANGE.3 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. .\" generated by cd2nroff 0.1 from CURLOPT_RANGE.md
  2. .TH CURLOPT_RANGE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_RANGE \- byte range to request
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RANGE, char *range);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a char pointer as parameter, which should contain the specified range you
  12. want to retrieve. It should be in the format "X\-Y", where either X or Y may be
  13. left out and X and Y are byte indexes.
  14. HTTP transfers also support several intervals, separated with commas as in
  15. \fI"X\-Y,N\-M"\fP. Using this kind of multiple intervals causes the HTTP server
  16. to send the response document in pieces (using standard MIME separation
  17. techniques). Unfortunately, the HTTP standard (RFC 7233 section 3.1) allows
  18. servers to ignore range requests so even when you set \fICURLOPT_RANGE(3)\fP
  19. for a request, you may end up getting the full response sent back.
  20. For RTSP, the formatting of a range should follow RFC 2326 Section 12.29. For
  21. RTSP, byte ranges are \fBnot\fP permitted. Instead, ranges should be given in
  22. \fBnpt\fP, \fButc\fP, or \fBsmpte\fP formats.
  23. For HTTP PUT uploads this option should not be used, since it may conflict with
  24. other options.
  25. Pass a NULL to this option to disable the use of ranges.
  26. The application does not have to keep the string around after setting this
  27. option.
  28. .SH DEFAULT
  29. NULL
  30. .SH PROTOCOLS
  31. This functionality affects file, ftp, http, rtsp and sftp
  32. .SH EXAMPLE
  33. .nf
  34. int main(void)
  35. {
  36. CURL *curl = curl_easy_init();
  37. if(curl) {
  38. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  39. /* get the first 200 bytes */
  40. curl_easy_setopt(curl, CURLOPT_RANGE, "0-199");
  41. /* Perform the request */
  42. curl_easy_perform(curl);
  43. }
  44. }
  45. .fi
  46. .SH HISTORY
  47. FILE since 7.18.0, RTSP since 7.20.0
  48. .SH AVAILABILITY
  49. Added in curl 7.1
  50. .SH RETURN VALUE
  51. Returns CURLE_OK on success or
  52. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  53. .SH SEE ALSO
  54. .BR CURLOPT_LOW_SPEED_LIMIT (3),
  55. .BR CURLOPT_MAXFILESIZE_LARGE (3),
  56. .BR CURLOPT_MAX_RECV_SPEED_LARGE (3),
  57. .BR CURLOPT_RESUME_FROM (3)