xref: /aosp_15_r20/external/curl/docs/cmdline-opts/range.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerLong: range
5*6236dae4SAndroid Build Coastguard WorkerShort: r
6*6236dae4SAndroid Build Coastguard WorkerHelp: Retrieve only the bytes within RANGE
7*6236dae4SAndroid Build Coastguard WorkerArg: <range>
8*6236dae4SAndroid Build Coastguard WorkerProtocols: HTTP FTP SFTP FILE
9*6236dae4SAndroid Build Coastguard WorkerCategory: http ftp sftp file
10*6236dae4SAndroid Build Coastguard WorkerAdded: 4.0
11*6236dae4SAndroid Build Coastguard WorkerMulti: single
12*6236dae4SAndroid Build Coastguard WorkerSee-also:
13*6236dae4SAndroid Build Coastguard Worker  - continue-at
14*6236dae4SAndroid Build Coastguard Worker  - append
15*6236dae4SAndroid Build Coastguard WorkerExample:
16*6236dae4SAndroid Build Coastguard Worker  - --range 22-44 $URL
17*6236dae4SAndroid Build Coastguard Worker---
18*6236dae4SAndroid Build Coastguard Worker
19*6236dae4SAndroid Build Coastguard Worker# `--range`
20*6236dae4SAndroid Build Coastguard Worker
21*6236dae4SAndroid Build Coastguard WorkerRetrieve a byte range (i.e. a partial document) from an HTTP/1.1, FTP or SFTP
22*6236dae4SAndroid Build Coastguard Workerserver or a local FILE. Ranges can be specified in a number of ways.
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard Worker## 0-499
25*6236dae4SAndroid Build Coastguard Workerspecifies the first 500 bytes
26*6236dae4SAndroid Build Coastguard Worker
27*6236dae4SAndroid Build Coastguard Worker## 500-999
28*6236dae4SAndroid Build Coastguard Workerspecifies the second 500 bytes
29*6236dae4SAndroid Build Coastguard Worker
30*6236dae4SAndroid Build Coastguard Worker## -500
31*6236dae4SAndroid Build Coastguard Workerspecifies the last 500 bytes
32*6236dae4SAndroid Build Coastguard Worker
33*6236dae4SAndroid Build Coastguard Worker## 9500-
34*6236dae4SAndroid Build Coastguard Workerspecifies the bytes from offset 9500 and forward
35*6236dae4SAndroid Build Coastguard Worker
36*6236dae4SAndroid Build Coastguard Worker## 0-0,-1
37*6236dae4SAndroid Build Coastguard Workerspecifies the first and last byte only(*)(HTTP)
38*6236dae4SAndroid Build Coastguard Worker
39*6236dae4SAndroid Build Coastguard Worker## 100-199,500-599
40*6236dae4SAndroid Build Coastguard Workerspecifies two separate 100-byte ranges(*) (HTTP)
41*6236dae4SAndroid Build Coastguard Worker
42*6236dae4SAndroid Build Coastguard Worker##
43*6236dae4SAndroid Build Coastguard Worker
44*6236dae4SAndroid Build Coastguard Worker(*) = NOTE that these make the server reply with a multipart response, which
45*6236dae4SAndroid Build Coastguard Workeris returned as-is by curl. Parsing or otherwise transforming this response is
46*6236dae4SAndroid Build Coastguard Workerthe responsibility of the caller.
47*6236dae4SAndroid Build Coastguard Worker
48*6236dae4SAndroid Build Coastguard WorkerOnly digit characters (0-9) are valid in the 'start' and 'stop' fields of the
49*6236dae4SAndroid Build Coastguard Worker'start-stop' range syntax. If a non-digit character is given in the range, the
50*6236dae4SAndroid Build Coastguard Workerserver's response is unspecified, depending on the server's configuration.
51*6236dae4SAndroid Build Coastguard Worker
52*6236dae4SAndroid Build Coastguard WorkerMany HTTP/1.1 servers do not have this feature enabled, so that when you
53*6236dae4SAndroid Build Coastguard Workerattempt to get a range, curl instead gets the whole document.
54*6236dae4SAndroid Build Coastguard Worker
55*6236dae4SAndroid Build Coastguard WorkerFTP and SFTP range downloads only support the simple 'start-stop' syntax
56*6236dae4SAndroid Build Coastguard Worker(optionally with one of the numbers omitted). FTP use depends on the extended
57*6236dae4SAndroid Build Coastguard WorkerFTP command SIZE.
58