## org.mortbay.http
Class HttpInputStream

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

public class HttpInputStream
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: HttpInputStream.java,v 1.2 2002/12/14 13:02:50 bretts Exp $
Author:
  Greg Wilkins (gregw)
See Also:
  `LineInput`

Constructor Summary
`HttpInputStream(java.io.InputStream in)` Constructor.
`HttpInputStream(java.io.InputStream in, int bufferSize)` Constructor.

Method Summary
`void` `close()`
`void` `destroy()`
`int` `getContentLength()` Get the content length.
`java.io.InputStream` `getFilterStream()` Get Filter InputStream.
`java.io.InputStream` `getInputStream()` Get the raw stream.
`HttpFields` `getTrailer()`
`boolean` `isChunking()` Get chunking mode
`void` `resetStream()` Reset the stream.
`void` `setChunking()` Set chunking mode.
`void` `setContentLength(int len)` Set the content length.
`void` `setFilterStream(java.io.InputStream filter)` Set Filter InputStream.

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`

Constructor Detail

### HttpInputStream

    public HttpInputStream(java.io.InputStream in)

  Constructor.

### HttpInputStream

    public HttpInputStream(java.io.InputStream in,
                           int bufferSize)

  Constructor.

Method Detail

### getInputStream

    public java.io.InputStream getInputStream()

  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.

### getFilterStream

    public java.io.InputStream getFilterStream()

  Get Filter InputStream. Get the current top of the InputStream filter stack

  Returns:
    InputStream.

### setFilterStream

    public void setFilterStream(java.io.InputStream filter)

  Set Filter InputStream. Set input filter stream, which should be constructed to wrap the stream returned from get FilterStream.

### 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`
    `java.io.IOException`

### 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()

### destroy

    public void destroy()

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