ChunkedOutputFilterpublic class ChunkedOutputFilter extends Object implements org.apache.coyote.http11.OutputFilter
Fields Summary |
---|
protected static final String | ENCODING_NAME | protected static final org.apache.tomcat.util.buf.ByteChunk | ENCODING | protected static final org.apache.tomcat.util.buf.ByteChunk | END_CHUNKEnd chunk. | protected org.apache.coyote.OutputBuffer | bufferNext buffer in the pipeline. | protected byte[] | chunkLengthBuffer used for chunk length conversion. | protected org.apache.tomcat.util.buf.ByteChunk | chunkHeaderChunk header. |
Constructors Summary |
---|
public ChunkedOutputFilter()Default constructor.
// ----------------------------------------------------- Static Initializer
ENCODING.setBytes(ENCODING_NAME.getBytes(), 0, ENCODING_NAME.length());
String endChunkValue = "0\r\n\r\n";
END_CHUNK.setBytes(endChunkValue.getBytes(),
0, endChunkValue.length());
chunkLength = new byte[10];
chunkLength[8] = (byte) '\r";
chunkLength[9] = (byte) '\n";
|
Methods Summary |
---|
public int | doWrite(org.apache.tomcat.util.buf.ByteChunk chunk, org.apache.coyote.Response res)Write some bytes.
// ------------------------------------------------------------- Properties
// --------------------------------------------------- OutputBuffer Methods
int result = chunk.getLength();
if (result <= 0) {
return 0;
}
// Calculate chunk header
int pos = 7;
int current = result;
while (current > 0) {
int digit = current % 16;
current = current / 16;
chunkLength[pos--] = HexUtils.HEX[digit];
}
chunkHeader.setBytes(chunkLength, pos + 1, 9 - pos);
buffer.doWrite(chunkHeader, res);
buffer.doWrite(chunk, res);
chunkHeader.setBytes(chunkLength, 8, 2);
buffer.doWrite(chunkHeader, res);
return result;
| public long | end()End the current request. It is acceptable to write extra bytes using
buffer.doWrite during the execution of this method.
// Write end chunk
buffer.doWrite(END_CHUNK, null);
return 0;
| public org.apache.tomcat.util.buf.ByteChunk | getEncodingName()Return the name of the associated encoding; Here, the value is
"identity".
return ENCODING;
| public void | recycle()Make the filter ready to process the next request.
| public void | setBuffer(org.apache.coyote.OutputBuffer buffer)Set the next buffer in the filter pipeline.
this.buffer = buffer;
| public void | setResponse(org.apache.coyote.Response response)Some filters need additional parameters from the response. All the
necessary reading can occur in that method, as this method is called
after the response header processing is complete.
|
|