public class ChunkedInputFilter extends Object implements InputFilter, ApplicationBufferHandler
Modifier and Type | Field and Description |
---|---|
protected InputBuffer |
buffer
Next buffer in the pipeline.
|
protected static ByteChunk |
ENCODING |
protected static String |
ENCODING_NAME |
protected boolean |
endChunk
Flag set to true when the end chunk has been read.
|
protected boolean |
needCRLFParse
Flag set to true if the next call to doRead() must parse a CRLF pair
before doing anything else.
|
protected ByteBuffer |
readChunk
Byte chunk used to read bytes.
|
protected int |
remaining
Number of bytes remaining in the current chunk.
|
protected ByteChunk |
trailingHeaders
Byte chunk used to store trailing headers.
|
Constructor and Description |
---|
ChunkedInputFilter(int maxTrailerSize,
Set<String> allowedTrailerHeaders,
int maxExtensionSize,
int maxSwallowSize) |
Modifier and Type | Method and Description |
---|---|
int |
available()
Amount of bytes still available in a buffer.
|
int |
doRead(ApplicationBufferHandler handler)
Read from the input stream into the ByteBuffer provided by the
ApplicationBufferHandler.
|
long |
end()
End the current request.
|
void |
expand(int size) |
ByteBuffer |
getByteBuffer() |
ByteChunk |
getEncodingName()
Return the name of the associated encoding; Here, the value is
"identity".
|
boolean |
isFinished()
Has the request body been read fully?
|
protected boolean |
parseChunkHeader()
Parse the header of a chunk.
|
protected void |
parseCRLF(boolean tolerant)
Parse CRLF at end of chunk.
|
protected void |
parseEndChunk()
Parse end chunk data.
|
protected int |
readBytes()
Read bytes from the previous buffer.
|
void |
recycle()
Make the filter ready to process the next request.
|
void |
setBuffer(InputBuffer buffer)
Set the next buffer in the filter pipeline.
|
void |
setByteBuffer(ByteBuffer buffer) |
void |
setRequest(Request request)
Read the content length from the request.
|
protected static final String ENCODING_NAME
protected static final ByteChunk ENCODING
protected InputBuffer buffer
protected int remaining
protected ByteBuffer readChunk
protected boolean endChunk
protected final ByteChunk trailingHeaders
protected boolean needCRLFParse
public int doRead(ApplicationBufferHandler handler) throws IOException
InputBuffer
doRead
in interface InputBuffer
handler
- ApplicationBufferHandler that provides the buffer to read
data into.IOException
- If an I/O error occurs reading from the input streampublic void setRequest(Request request)
setRequest
in interface InputFilter
request
- The request to be associated with this filterpublic long end() throws IOException
end
in interface InputFilter
IOException
- If an error happenspublic int available()
available
in interface InputBuffer
public void setBuffer(InputBuffer buffer)
setBuffer
in interface InputFilter
buffer
- The next bufferpublic void recycle()
recycle
in interface InputFilter
public ByteChunk getEncodingName()
getEncodingName
in interface InputFilter
public boolean isFinished()
InputFilter
isFinished
in interface InputFilter
true
if the request body has been fully read, otherwise
false
protected int readBytes() throws IOException
IOException
- Read errorprotected boolean parseChunkHeader() throws IOException
The letters before CRLF or ';' (whatever comes first) must be valid hex digits. We should not parse F23IAMGONNAMESSTHISUP34CRLF as a valid header according to the spec.
true
if the chunk header has been
successfully parsedIOException
- Read errorprotected void parseCRLF(boolean tolerant) throws IOException
tolerant
- Should tolerant parsing (LF and CRLF) be used? This
is recommended (RFC2616, section 19.3) for message
headers.IOException
- An error occurred parsing CRLFprotected void parseEndChunk() throws IOException
IOException
- Error propagationpublic void setByteBuffer(ByteBuffer buffer)
setByteBuffer
in interface ApplicationBufferHandler
public ByteBuffer getByteBuffer()
getByteBuffer
in interface ApplicationBufferHandler
public void expand(int size)
expand
in interface ApplicationBufferHandler
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.