It's easy to open a connection to a remote asset using URL.openStream() which returns an InputStream. What about random access?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
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).