@Override
    public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback connectionCallback) throws BackgroundException {
        final MantaHttpHeaders headers = new MantaHttpHeaders();
        try {
            try {
                if(status.isAppend()) {
                    final HttpRange range = HttpRange.withStatus(status);
                    headers.setByteRange(range.getStart(), range.getEnd() < 0 ? null : range.getEnd());
                }
                // Requesting an empty file as an InputStream doesn't work, but we also don't want to
                // perform a HEAD request for every read so we'll opt to handle the exception instead
                // see https://github.com/joyent/java-manta/issues/248
                return session.getClient().getAsInputStream(file.getAbsolute(), headers);
            }
            catch(UnsupportedOperationException e) {
                final MantaObject probablyEmptyFile = session.getClient().head(file.getAbsolute());
                if(probablyEmptyFile.getContentLength() != 0) {
                    throw new AccessDeniedException();
                }
                return new NullInputStream(0L);
            }
        }
        catch(MantaException e) {
            throw new MantaExceptionMappingService().map("Download {0} failed", e, file);
        }
        catch(MantaClientHttpResponseException e) {
            throw new MantaHttpExceptionMappingService().map("Download {0} failed", e, file);
        }
        catch(IOException e) {
            throw new DefaultIOExceptionMappingService().map("Download {0} failed", e, file);
        }
    }
@Test
    public void testReadRange() throws Exception {
        final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), new TransferStatus());
        final Path test = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        new MantaTouchFeature(session).touch(test, new TransferStatus());

        final Local local = new Local(PROPERTIES.get("java.io.tmpdir"), new AlphanumericRandomStringService().random());

        final int BYTES_TOTAL = 10;//00;
        final int BYTES_OFFSET = 1;//00;

        final byte[] content = RandomUtils.nextBytes(BYTES_TOTAL);
        final OutputStream out = local.getOutputStream(false);
        assertNotNull(out);
        IOUtils.write(content, out);
        out.close();
        new DefaultUploadFeature<>(new MantaWriteFeature(session)).upload(
                test,
                local,
                new BandwidthThrottle(BandwidthThrottle.UNLIMITED),
                new DisabledStreamListener(),
                new TransferStatus().withLength(content.length),
                new DisabledConnectionCallback());
        final TransferStatus status = new TransferStatus();
        status.setLength(content.length);
        status.setAppend(true);
        status.setOffset(BYTES_OFFSET);
        final MantaReadFeature read = new MantaReadFeature(session);
        assertTrue(read.offset(test));
        final InputStream in = read.read(test, status.withLength(content.length - BYTES_OFFSET), new DisabledConnectionCallback());
        assertNotNull(in);
        final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length - BYTES_OFFSET);
        new StreamCopier(status, status).transfer(in, buffer);
        final byte[] reference = new byte[content.length - BYTES_OFFSET];
        System.arraycopy(content, BYTES_OFFSET, reference, 0, content.length - BYTES_OFFSET);
        assertArrayEquals(reference, buffer.toByteArray());
        in.close();
        new MantaDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }