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) |
processBytesReadpublic AutoCloseableContentLengthVerifyingInputStream(InputStream delegate, long contentLength)
public int read()
throws IOException
read in class ContentLengthVerifyingInputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in class ContentLengthVerifyingInputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class ContentLengthVerifyingInputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class ContentLengthVerifyingInputStreamIOExceptionpublic boolean markSupported()
markSupported in class ContentLengthVerifyingInputStreampublic void mark(int readlimit)
mark in class ContentLengthVerifyingInputStreampublic void reset()
throws IOException
reset in class ContentLengthVerifyingInputStreamIOExceptionpublic int available()
throws IOException
available in class ContentLengthVerifyingInputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class ContentLengthVerifyingInputStreamIOExceptionCopyright © 2016–2022. All rights reserved.