com.caucho.server.http
Class ContentLengthStream

java.lang.Object
  extended by com.caucho.vfs.StreamImpl
      extended by com.caucho.server.http.ContentLengthStream

public class ContentLengthStream
extends StreamImpl

Filter so POST readers can only read data up to the content length


Field Summary
 
Fields inherited from class com.caucho.vfs.StreamImpl
_nullPath, _path
 
Constructor Summary
ContentLengthStream()
           
 
Method Summary
 boolean canRead()
          Returns true if this is a read stream.
 int getAvailable()
          Returns the number of bytes available without blocking.
 int read(byte[] buffer, int offset, int length)
          Reads from the buffer, limiting to the content length.
 java.lang.String toString()
           
 
Methods inherited from class com.caucho.vfs.StreamImpl
canWrite, clearWrite, close, closeWrite, flush, flushBuffer, flushToDisk, getAttribute, getAttributeNames, getFlushOnNewline, getNewline, getPath, getReadBuffer, getReadPosition, hasSkip, isClosed, isEof, readNonBlock, readTimeout, removeAttribute, seekEnd, seekStart, setAttribute, setPath, setWriteEncoding, skip, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContentLengthStream

public ContentLengthStream()
Method Detail

canRead

public boolean canRead()
Description copied from class: StreamImpl
Returns true if this is a read stream.

Overrides:
canRead in class StreamImpl

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Reads from the buffer, limiting to the content length.

Overrides:
read in class StreamImpl
Parameters:
buffer - the buffer containing the results.
offset - the offset into the result buffer
length - the length of the buffer.
Returns:
the number of bytes read or -1 for the end of the file.
Throws:
java.io.IOException

getAvailable

public int getAvailable()
                 throws java.io.IOException
Description copied from class: StreamImpl
Returns the number of bytes available without blocking. Depending on the stream, this may return less than the actual bytes, but will always return a number > 0 if there is any data available.

Overrides:
getAvailable in class StreamImpl
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object