public class AutoCloseableContentLengthVerifyingInputStream extends ContentLengthVerifyingInputStream
A wrapper over an InputStream
whose length is known, which verifies that
the length of the wrapped stream matches its known length and auto-closes the stream once the content length bytes
of the stream have been read. This auto-close feature has been added to release the connection from the Apache
connection pool which can otherwise lead to indefinite hangs
NOTE: This implementation of auto closesable content length verification does not support InputStream.reset()
and throws an IOException when reset is called
contentLength, delegate, isVerificationEnabled, totalBytesProcessed
Constructor and Description |
---|
AutoCloseableContentLengthVerifyingInputStream(InputStream delegate,
long contentLength) |
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close() |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
skip(long n) |
processBytesRead
public AutoCloseableContentLengthVerifyingInputStream(InputStream delegate, long contentLength)
public int read() throws IOException
read
in class ContentLengthVerifyingInputStream
IOException
public int read(byte[] b) throws IOException
read
in class ContentLengthVerifyingInputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class ContentLengthVerifyingInputStream
IOException
public long skip(long n) throws IOException
skip
in class ContentLengthVerifyingInputStream
IOException
public boolean markSupported()
markSupported
in class ContentLengthVerifyingInputStream
public void mark(int readlimit)
mark
in class ContentLengthVerifyingInputStream
public void reset() throws IOException
reset
in class ContentLengthVerifyingInputStream
IOException
public int available() throws IOException
available
in class ContentLengthVerifyingInputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class ContentLengthVerifyingInputStream
IOException
Copyright © 2016–2022. All rights reserved.