|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream java.io.FilterInputStream smbdav.LimitInputStream
Limits the amount of data that can be read from the underlying stream to a predefined value. This is used to prevent an XML DOS attack, in which the client sents a very large XML document in a PROPFIND or LOCK request.
Field Summary |
Fields inherited from class java.io.FilterInputStream |
in |
Constructor Summary | |
LimitInputStream(java.io.InputStream in,
long limit)
Creates a LimitInputStream from the specified underlying
stream, using the provided limit. |
Method Summary | |
void |
mark(int readLimit)
Marks the current position in the stream. |
int |
read()
Reads a byte of data from the stream. |
int |
read(byte[] b)
Reads bytes from the stream into the specified buffer. |
int |
read(byte[] b,
int offset,
int length)
Reads up to the given number of bytes from the stream into the specified buffer starting at the specified offset in the buffer. |
void |
reset()
Resets the stream to the previously marked position. |
Methods inherited from class java.io.FilterInputStream |
available, close, markSupported, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LimitInputStream(java.io.InputStream in, long limit)
LimitInputStream
from the specified underlying
stream, using the provided limit. Attempts to read after the limit
has been reached will result in an EOFException
.
in
- The underlying input stream.limit
- The maximum number of bytes that can be read from this
stream.Method Detail |
public int read() throws java.io.IOException
int
containing the next byte of data, or -1
if the end of the stream is reached.
java.io.IOException
- If an IO error occurs.
java.io.EOFException
- If the limit has already been read.public int read(byte[] b) throws java.io.IOException
b
- The buffer that will receive the data.
int
indicating the number of bytes read, or
-1 if the end of the stream is reached.
java.io.IOException
- If an IO error occurs.
java.io.EOFException
- If the limit has already been read.public int read(byte[] b, int offset, int length) throws java.io.IOException
b
- The buffer that will receive the data.offset
- The offset into the buffer where the data is to be
written.length
- The maximum number of bytes to read.
int
indicating the number of bytes read, or
-1 if the end of the stream is reached.
java.io.IOException
- If an IO error occurs.
java.io.EOFException
- If the limit has already been read.public void mark(int readLimit)
readLimit
- The amount that can be read before the mark is
invalidated.public void reset() throws java.io.IOException
java.io.IOException
- If the stream has not been marked, or the mark
has been invalidated.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |