Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mortbay.http
Class HttpInputStream  view HttpInputStream download HttpInputStream.java

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended byorg.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.4 2003/10/05 23:46:20 gregwilkins Exp $

Nested Class Summary
private static class HttpInputStream.ClosedStream
          A closed input stream.
 
Field Summary
private static HttpInputStream.ClosedStream __closedStream
           
private  boolean _chunking
           
private  ChunkingInputStream _deChunker
           
private  org.mortbay.util.LineInput _realIn
           
private static org.apache.commons.logging.Log log
           
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
HttpInputStream(java.io.InputStream in)
          Constructor.
HttpInputStream(java.io.InputStream in, int bufferSize)
          Constructor.
 
Method Summary
 void close()
          This method closes the input stream by closing the input stream that this object is filtering.
 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

__closedStream

private static HttpInputStream.ClosedStream __closedStream

_deChunker

private ChunkingInputStream _deChunker

_realIn

private org.mortbay.util.LineInput _realIn

_chunking

private boolean _chunking
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.


getFilterStream

public java.io.InputStream getFilterStream()
Get Filter InputStream. Get the current top of the InputStream filter stack


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


resetStream

public void resetStream()
                 throws java.lang.IllegalStateException
Reset the stream. Turn chunking off and disable all filters.


close

public void close()
           throws java.io.IOException
Description copied from class: java.io.FilterInputStream
This method closes the input stream by closing the input stream that this object is filtering. Future attempts to access this stream may throw an exception.


setContentLength

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


getContentLength

public int getContentLength()
Get the content length.


getTrailer

public HttpFields getTrailer()

destroy

public void destroy()