org.w3c.www.http
Class ChunkedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.w3c.www.http.ChunkedInputStream
All Implemented Interfaces:
java.io.Closeable

public class ChunkedInputStream
extends java.io.InputStream

A Stream that parses and present chunk encoded data. This stream should only be used on top of a buffered input stream, it might be very inefficient otherwise. Chunk encoding is defined in version 1.1 of the HTTP specification.


Field Summary
protected  int ahead
           
protected  org.w3c.www.http.HttpBuffer buf
           
protected  int clen
           
protected  boolean eof
           
protected  java.io.InputStream in
           
protected  boolean inited
           
protected  boolean isahead
           
protected  HttpStreamObserver observer
           
protected  org.w3c.www.http.ParseState ps
           
 
Constructor Summary
ChunkedInputStream(HttpStreamObserver observer, java.io.InputStream in)
           
ChunkedInputStream(java.io.InputStream in)
           
 
Method Summary
 int available()
           
 void close()
           
 void finalize()
          Make sure the stream is ultimately closed !
protected  int nextChunk(boolean skipCRLF)
          Read in next chunk description.
 int read()
           
 int read(byte[] b, int off, int len)
           
 long skip(long n)
           
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

protected java.io.InputStream in

buf

protected org.w3c.www.http.HttpBuffer buf

ps

protected org.w3c.www.http.ParseState ps

inited

protected boolean inited

clen

protected int clen

ahead

protected int ahead

isahead

protected boolean isahead

eof

protected boolean eof

observer

protected HttpStreamObserver observer
Constructor Detail

ChunkedInputStream

public ChunkedInputStream(java.io.InputStream in)
                   throws java.io.IOException
Throws:
java.io.IOException

ChunkedInputStream

public ChunkedInputStream(HttpStreamObserver observer,
                          java.io.InputStream in)
                   throws java.io.IOException
Throws:
java.io.IOException
Method Detail

nextChunk

protected int nextChunk(boolean skipCRLF)
                 throws java.io.IOException
Read in next chunk description. Sets the eof flag to true when reached.

Returns:
The length of next incomming chunk of data.
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

finalize

public void finalize()
Make sure the stream is ultimately closed !

Overrides:
finalize in class java.lang.Object