The request should use the Range header. But you can only use it if the server tells you that it is accepting a range request from the Accept-Ranges response header.
This is an example session. Suppose we are interested in getting a portion of this image . First, we send an HTTP HEAD request to determine: a) if the server supports byte ranges, b) content length:
> HEAD /2238/2758537173_670161cac7_b.jpg HTTP/1.1 > Host: farm3.static.flickr.com > Accept: */* > < HTTP/1.1 200 OK < Date: Thu, 08 Jul 2010 12:22:12 GMT < Content-Type: image/jpeg < Connection: keep-alive < Server: Apache/2.0.52 (Red Hat) < Expires: Mon, 28 Jul 2014 23:30:00 GMT < Last-Modified: Wed, 13 Aug 2008 06:13:54 GMT < Accept-Ranges: bytes < Content-Length: 350015
Then we send a GET request with a Range header requesting the first 11 bytes of picure:
> GET /2238/2758537173_670161cac7_b.jpg HTTP/1.1 > Host: farm3.static.flickr.com > Accept: */* > Range: bytes=0-10 > < HTTP/1.1 206 Partial Content < Date: Thu, 08 Jul 2010 12:26:54 GMT < Content-Type: image/jpeg < Connection: keep-alive < Server: Apache/2.0.52 (Red Hat) < Expires: Mon, 28 Jul 2014 23:30:00 GMT < Last-Modified: Wed, 13 Aug 2008 06:13:54 GMT < Accept-Ranges: bytes < Content-Range: bytes 0-10/350015 < Content-Length: 11 <
This is the hexadecimal dump of the first 11 bytes:
00000000 ff d8 ff e0 00 10 4a 46 49 46 00 |......JFIF.| 0000000b
See the Range Header Specification in HTTP RFC 2616 for details.
Andrey Vlasovskikh
source share