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

void
close()
void
destroy()
int
getContentLength()
Get the content length.
OutputStream
getExpectContinues()
InputStream
getFilterStream()
Get Filter InputStream.
InputStream
getInputStream()
Get the raw stream.
HttpFields
getTrailer()
boolean
isChunking()
Get chunking mode
int
read()
int
read(byte[] b)
int
read(byte[] b, int off, int len)
void
resetStream()
Reset the stream.
void
setChunking()
Set chunking mode.
void
setContentLength(int len)
Set the content length.
void
setExpectContinues(OutputStream expectContinues)
void
setFilterStream(InputStream filter)
Set Filter InputStream.
long
skip(long n)

Constructor Details

HttpInputStream

public HttpInputStream(InputStream in)
Constructor.

HttpInputStream

public HttpInputStream(InputStream in,
                       int bufferSize)
Constructor.

Method Details

close

public void close()
            throws IOException

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:

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()
            throws IOException

read

public int read(byte[] b)
            throws IOException

read

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

resetStream

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

setChunking

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

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)
            throws IOException

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