org.apache.coyote.http11.filters

Class ChunkedInputFilter

public class ChunkedInputFilter extends Object implements InputFilter

Chunked input filter. Parses chunked data according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1

Author: Remy Maucherat Filip Hanik

Field Summary
protected byte[]buf
Read bytes buffer.
protected InputBufferbuffer
Next buffer in the pipeline.
protected booleanendChunk
Flag set to true when the end chunk has been read.
protected static ByteChunkENCODING
protected static StringENCODING_NAME
protected intlastValid
Last valid byte in the buffer.
protected booleanneedCRLFParse
Flag set to true if the next call to doRead() must parse a CRLF pair before doing anything else.
protected intpos
Position in the buffer.
protected ByteChunkreadChunk
Byte chunk used to read bytes.
protected intremaining
Number of bytes remaining in the current chunk.
Method Summary
intavailable()
Amount of bytes still available in a buffer.
intdoRead(ByteChunk chunk, Request req)
Read bytes.
longend()
End the current request.
ByteChunkgetEncodingName()
Return the name of the associated encoding; Here, the value is "identity".
protected booleanparseChunkHeader()
Parse the header of a chunk.
protected booleanparseCRLF()
Parse CRLF at end of chunk.
protected booleanparseEndChunk()
Parse end chunk data.
protected intreadBytes()
Read bytes from the previous buffer.
voidrecycle()
Make the filter ready to process the next request.
voidsetBuffer(InputBuffer buffer)
Set the next buffer in the filter pipeline.
voidsetRequest(Request request)
Read the content length from the request.

Field Detail

buf

protected byte[] buf
Read bytes buffer.

buffer

protected InputBuffer buffer
Next buffer in the pipeline.

endChunk

protected boolean endChunk
Flag set to true when the end chunk has been read.

ENCODING

protected static final ByteChunk ENCODING

ENCODING_NAME

protected static final String ENCODING_NAME

lastValid

protected int lastValid
Last valid byte in the buffer.

needCRLFParse

protected boolean needCRLFParse
Flag set to true if the next call to doRead() must parse a CRLF pair before doing anything else.

pos

protected int pos
Position in the buffer.

readChunk

protected ByteChunk readChunk
Byte chunk used to read bytes.

remaining

protected int remaining
Number of bytes remaining in the current chunk.

Method Detail

available

public int available()
Amount of bytes still available in a buffer.

doRead

public int doRead(ByteChunk chunk, Request req)
Read bytes.

Returns: If the filter does request length control, this value is significant; it should be the number of bytes consumed from the buffer, up until the end of the current request body, or the buffer length, whichever is greater. If the filter does not do request body length control, the returned value should be -1.

end

public long end()
End the current request.

getEncodingName

public ByteChunk getEncodingName()
Return the name of the associated encoding; Here, the value is "identity".

parseChunkHeader

protected boolean parseChunkHeader()
Parse the header of a chunk. A chunk header can look like A10CRLF F23;chunk-extension to be ignoredCRLF The letters before CRLF but after the trailer mark, must be valid hex digits, we should not parse F23IAMGONNAMESSTHISUP34CRLF as a valid header according to spec

parseCRLF

protected boolean parseCRLF()
Parse CRLF at end of chunk.

parseEndChunk

protected boolean parseEndChunk()
Parse end chunk data. FIXME: Handle trailers

readBytes

protected int readBytes()
Read bytes from the previous buffer.

recycle

public void recycle()
Make the filter ready to process the next request.

setBuffer

public void setBuffer(InputBuffer buffer)
Set the next buffer in the filter pipeline.

setRequest

public void setRequest(Request request)
Read the content length from the request.
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.