org.mortbay.http
Class ChunkableInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--org.mortbay.http.ChunkableInputStream

public class ChunkableInputStream
extends java.io.FilterInputStream

HTTP Chunking InputStream. This FilterInputStream acts as a BufferedInputStream until setChunking(true) is called. Once chunking is enabled, the raw stream is chunk decoded as per RFC2616. The "8859-1" encoding is used on underlying LineInput instance for line based reads from the raw stream. This class is not synchronized and should be synchronized explicitly if an instance is used by multiple threads.

Version:
$Id: ChunkableInputStream.java,v 1.1 2001/09/02 01:13:08 gregwilkins Exp $
Author:
Greg Wilkins (gregw)
See Also:
org.mortbay.util.LineInput.

Field Summary
static java.lang.Class[] __filterArg
           
static int __maxLineLength
          Limit max line length
 
Constructor Summary
ChunkableInputStream(java.io.InputStream in)
          Constructor.
 
Method Summary
 void close()
           
 int getContentLength()
          Get the content length.
 java.io.InputStream getRawStream()
          Get the raw stream.
 HttpFields getTrailer()
           
 void insertFilter(java.lang.reflect.Constructor filter, java.lang.Object[] args)
          Insert FilterInputStream.
 boolean isChunking()
          Get chunking mode
 void resetStream()
          Reset the stream.
 void setChunking()
          Set chunking mode.
 void setContentLength(int len)
          Set the content length.
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__maxLineLength

public static int __maxLineLength
Limit max line length

__filterArg

public static final java.lang.Class[] __filterArg
Constructor Detail

ChunkableInputStream

public ChunkableInputStream(java.io.InputStream in)
Constructor.
Method Detail

getRawStream

public java.io.InputStream getRawStream()
Get the raw stream. A stream without filters or chunking is returned. This stream may still be buffered and uprocessed bytes may be in the buffer.
Returns:
Raw InputStream.

isChunking

public boolean isChunking()
Get chunking mode

setChunking

public void setChunking()
                 throws java.lang.IllegalStateException
Set chunking mode. Chunking can only be turned off with a call to resetStream().
Throws:
java.lang.IllegalStateException - Checking cannot be set if a content length has been set.

resetStream

public void resetStream()
                 throws java.lang.IllegalStateException
Reset the stream. Turn chunking off and disable all filters.
Throws:
java.lang.IllegalStateException - The stream cannot be reset if there is some unread chunked input or a content length greater than zero remaining.

close

public void close()
           throws java.io.IOException
Overrides:
close in class java.io.FilterInputStream

insertFilter

public void insertFilter(java.lang.reflect.Constructor filter,
                         java.lang.Object[] args)
                  throws java.lang.InstantiationException,
                         java.lang.reflect.InvocationTargetException,
                         java.lang.IllegalAccessException
Insert FilterInputStream. Place a Filtering InputStream into this stream, after the chunking stream.
Parameters:
filter - The Filter constructor. It must take an InputStream as the first arguement.
arg - Optional argument array to pass to filter constructor. The first element of the array is replaced with the current input stream.

setContentLength

public void setContentLength(int len)
Set the content length. Only this number of bytes can be read before EOF is returned.
Parameters:
len - length.

getContentLength

public int getContentLength()
Get the content length.
Returns:
Number of bytes until EOF is returned or -1 for no limit.

getTrailer

public HttpFields getTrailer()


Copyright © 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.