Class HTTPImageInputStream

java.lang.Object
javax.imageio.stream.ImageInputStreamImpl
is.galia.stream.HTTPImageInputStream
All Implemented Interfaces:
Closeable, DataInput, AutoCloseable, ImageInputStream

public class HTTPImageInputStream extends ImageInputStreamImpl implements ImageInputStream

Input stream that supports pseudo-seeking over HTTP.

The stream is divided conceptually into fixed-size windows from which chunks of data are fetched as needed using ranged HTTP requests. This technique may improve efficiency when reading small portions of large images that are selectively readable, like JPEG2000 and multiresolution+tiled TIFF, over low-bandwidth connections. Conversely, it may reduce efficiency when reading large portions of images.

Downloaded chunks can be cached in memory. This could help when readers seek around a lot beyond the window size, or request a lot more data than they would theoretically need.

The HTTP client is abstracted into the exceedingly simple HTTPImageInputStreamClient interface, so probably any existing client implementation, including many cloud storage clients, can be hooked up and used easily, without this class needing to know about things like SSL/TLS, request signing, etc.

This class works only with HTTP servers that support Range requests, as advertised by the presence of a Accept-Ranges: bytes header in a HEAD response.