xref: /curl/docs/cmdline-opts/range.md (revision 3040971d)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Long: range
5Short: r
6Help: Retrieve only the bytes within RANGE
7Arg: <range>
8Protocols: HTTP FTP SFTP FILE
9Category: http ftp sftp file
10Added: 4.0
11Multi: single
12See-also:
13  - continue-at
14  - append
15Example:
16  - --range 22-44 $URL
17---
18
19# `--range`
20
21Retrieve a byte range (i.e. a partial document) from an HTTP/1.1, FTP or SFTP
22server or a local FILE. Ranges can be specified in a number of ways.
23
24## 0-499
25specifies the first 500 bytes
26
27## 500-999
28specifies the second 500 bytes
29
30## -500
31specifies the last 500 bytes
32
33## 9500-
34specifies the bytes from offset 9500 and forward
35
36## 0-0,-1
37specifies the first and last byte only(*)(HTTP)
38
39## 100-199,500-599
40specifies two separate 100-byte ranges(*) (HTTP)
41
42##
43
44(*) = NOTE that these make the server reply with a multipart response, which
45is returned as-is by curl. Parsing or otherwise transforming this response is
46the responsibility of the caller.
47
48Only digit characters (0-9) are valid in the 'start' and 'stop' fields of the
49'start-stop' range syntax. If a non-digit character is given in the range, the
50server's response is unspecified, depending on the server's configuration.
51
52Many HTTP/1.1 servers do not have this feature enabled, so that when you
53attempt to get a range, curl instead gets the whole document.
54
55FTP and SFTP range downloads only support the simple 'start-stop' syntax
56(optionally with one of the numbers omitted). FTP use depends on the extended
57FTP command SIZE.
58