@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(expected = NotfoundException.class)
    public void testReadNotFound() throws Exception {
        final TransferStatus status = new TransferStatus();
        try {
            final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), new TransferStatus());
            new MantaReadFeature(session).read(new Path(drive, "nosuchname", EnumSet.of(Path.Type.file)), status, new DisabledConnectionCallback());
        }
        catch(NotfoundException e) {
            assertEquals("Not Found. Please contact your web hosting service provider for assistance.", e.getDetail());
            throw e;
        }
    }