Matthew Clarkson
Matthew Clarkson

Reputation: 95

Curl range not working(downloads entire file)

curl -v -r 0-500 http://somefile -o localfile

It should download just the first 501 bytes, no? Instead, it just downloads the entire thing. All 67 megabytes. Thanks curl! Could my companies proxy servers be blocking this feature somehow? I am skeptical about that, since the downloads themselves do work, just not the range feature. Am I missing something?

Upvotes: 2

Views: 11221

Answers (3)

MyQuestion
MyQuestion

Reputation: 41

Please use the following command

curl -H "range: bytes=354-500" -O http://example.com/file.extension

Upvotes: 1

Håkan Kvist
Håkan Kvist

Reputation: 173

As a client you could always abort the download when you have received what you want.

By using head, you will be able to limit the download to 500 bytes, even if the server does not accept the range-header

curl -v -r 0-500 http://somefile |head -c 500 > localfile

Upvotes: 3

janos
janos

Reputation: 124646

It should download just the first 501 bytes, no?

It depends on the server. From man curl:

You should also be aware that many HTTP/1.1 servers do not have this feature enabled, so that when you attempt to get a range, you'll instead get the whole document.

As you can see in the response from the server, it's using HTTP/1.1. So it's not surprising that the range feature is not supported at the server side.

Upvotes: 1

Related Questions