RandomAccessFile over HTTP

2019-07-08 09:10发布

It's easy to open a connection to a remote asset using URL.openStream() which returns an InputStream. What about random access?

标签: java http
2条回答
姐就是有狂的资本
2楼-- · 2019-07-08 09:55

HTTP 1.1 allows retrieval of parts of a resource through use of Byte Ranges, but...

  • servers are not required to support it
  • you will incur extra overhead due extra request/response headers, (possibly) establishing extra network connections, etc.
查看更多
相关推荐>>
3楼-- · 2019-07-08 10:04

True random access is not possible via http. You can simulate it though by passing a starting point as a paramater and return a stream that represents data from that position onwards.

For example this is how progressive HTTP download works (e.g. YouTube video seek).

查看更多
登录 后发表回答