public int doWrite(ByteChunk chunk,
Response res) throws IOException {
// ------------------------------------------------------------- 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;
}
|