org.mortbay.http

Class HttpInputStream

public class HttpInputStream extends 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.13 2005/08/23 20:02:26 gregwilkins Exp $

Author: Greg Wilkins (gregw)

See Also: LineInput

Constructor Summary
HttpInputStream(InputStream in)
Constructor.
HttpInputStream(InputStream in, int bufferSize)
Constructor.
Method Summary
voidclose()
voiddestroy()
intgetContentLength()
Get the content length.
OutputStreamgetExpectContinues()
InputStreamgetFilterStream()
Get Filter InputStream.
InputStreamgetInputStream()
Get the raw stream.
HttpFieldsgetTrailer()
booleanisChunking()
Get chunking mode
intread()
intread(byte[] b, int off, int len)
intread(byte[] b)
voidresetStream()
Reset the stream.
voidsetChunking()
Set chunking mode.
voidsetContentLength(int len)
Set the content length.
voidsetExpectContinues(OutputStream expectContinues)
voidsetFilterStream(InputStream filter)
Set Filter InputStream.
longskip(long n)

Constructor Detail

HttpInputStream

public HttpInputStream(InputStream in)
Constructor.

HttpInputStream

public HttpInputStream(InputStream in, int bufferSize)
Constructor.

Method Detail

close

public void close()

destroy

public void destroy()

getContentLength

public int getContentLength()
Get the content length.

Returns: Number of bytes until EOF is returned or -1 for no limit.

getExpectContinues

public OutputStream getExpectContinues()

Parameters: expectContinues The expectContinues to set.

getFilterStream

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

Returns: InputStream.

getInputStream

public 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.

getTrailer

public HttpFields getTrailer()

isChunking

public boolean isChunking()
Get chunking mode

read

public int read()

read

public int read(byte[] b, int off, int len)

read

public int read(byte[] b)

resetStream

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

Throws: IllegalStateException The stream cannot be reset if there is some unread chunked input or a content length greater than zero remaining.

setChunking

public void setChunking()
Set chunking mode. Chunking can only be turned off with a call to resetStream().

Throws: IllegalStateException Checking cannot be set if a content length has been set.

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.

setExpectContinues

public void setExpectContinues(OutputStream expectContinues)

Parameters: expectContinues The expectContinues to set.

setFilterStream

public void setFilterStream(InputStream filter)
Set Filter InputStream. Set input filter stream, which should be constructed to wrap the stream returned from get FilterStream.

skip

public long skip(long n)
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.