Mediator
Mediator

Reputation: 15388

How to download a certain byte of the file via http

How to download first 125 bytes and 125 last byte file via HTTP protocol ?

Upvotes: 4

Views: 1420

Answers (2)

Jon Skeet
Jon Skeet

Reputation: 1504132

I believe you want to send an appropriate Range header. See the HTTP/1.1 spec for more information. Be aware that not all servers will support this, mind you. You may need to transfer the whole file, just to get to the last 125 bytes. Of course, you can get just the first 125 bytes by requesing the whole thing, and then only reading the first 125 bytes before killing the connection.

In theory I believe you should be able to use:

Range: 0-124,-125

Note that this will give interesting results if the full response would be less than 250 bytes...

Accept-Ranges: bytes
Range: bytes=-255

Upvotes: 9

Surya Chaitanya
Surya Chaitanya

Reputation: 602

send content-range in request headers for specific range of content as response. but for which the webserver has to support range requests

Upvotes: 2

Related Questions