@Override
    public HttpResponseOutputStream<Void> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
        try {
            return this.write(file, this.toHeaders(file, status, expect), status);
        }
        catch(ConflictException e) {
            if(expect) {
                if(null != status.getLockId()) {
                    // Handle 412 Precondition Failed with expired token
                    log.warn(String.format("Retry failure %s with lock id %s removed", e, status.getLockId()));
                    return this.write(file, this.toHeaders(file, status.withLockId(null), expect), status);
                }
            }
            throw e;
        }
        catch(InteroperabilityException e) {
            if(expect) {
                // Handle 417 Expectation Failed
                log.warn(String.format("Retry failure %s with Expect: Continue removed", e));
                return this.write(file, this.toHeaders(file, status.withLockId(null), false), status);
            }
            throw e;
        }
    }
@Test
    public void testWriteContentRangeTwoBytes() throws Exception {
        final DAVWriteFeature feature = new DAVWriteFeature(session);
        final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        final byte[] source = RandomUtils.nextBytes(2);
        {
            final TransferStatus status = new TransferStatus();
            status.setLength(1L);
            status.setOffset(0L);
            final HttpResponseOutputStream<Void> out = feature.write(test, status, new DisabledConnectionCallback());
            new StreamCopier(status, status).withOffset(status.getOffset()).withLimit(status.getLength()).transfer(new ByteArrayInputStream(source), out);
            out.close();
        }
        {
            final TransferStatus status = new TransferStatus();
            status.setLength(1L);
            status.setOffset(1L);
            status.setAppend(true);
            final HttpResponseOutputStream<Void> out = feature.write(test, status, new DisabledConnectionCallback());
            new StreamCopier(status, status).withOffset(status.getOffset()).withLimit(status.getLength()).transfer(new ByteArrayInputStream(source), out);
            out.close();
        }
        final ByteArrayOutputStream out = new ByteArrayOutputStream(source.length);
        IOUtils.copy(new DAVReadFeature(session).read(test, new TransferStatus().withLength(source.length), new DisabledConnectionCallback()), out);
        assertArrayEquals(source, out.toByteArray());
        new DAVDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }