@Override public void write(int b) throws IOException { // Shouldn't get used for good performance, but is needed for // compatibility with Sun JDK 1.4.0 outputChunk.put(0, (byte) (b & 0xff)); buffer.doWrite(outputChunk); } @Override
@Override public void end() throws IOException { buffer.end(); } }
@Override public void flush() throws IOException { // No data buffered in this filter. Flush next buffer. buffer.flush(); }
buffer.doWrite(endChunk); endChunk.position(0).limit(endChunk.capacity()); } else { buffer.doWrite(lastChunk); lastChunk.position(0).limit(lastChunk.capacity()); buffer.doWrite(ByteBuffer.wrap(baos.toByteArray())); buffer.doWrite(crlfChunk); crlfChunk.position(0).limit(crlfChunk.capacity()); buffer.end();
@Override public long getBytesWritten() { return buffer.getBytesWritten(); }
@Override public long getBytesWritten() { return buffer.getBytesWritten(); }
@Override public void flush() throws IOException { // No data buffered in this filter. Flush next buffer. buffer.flush(); }
@Override public void end() throws IOException { next.end(); }
@Override public void write(byte[] b, int off, int len) throws IOException { buffer.doWrite(ByteBuffer.wrap(b, off, len)); } @Override
@Override public long getBytesWritten() { return next.getBytesWritten(); }
@Override public void flush() throws IOException { next.flush(); } }
@Override public void end() throws IOException { buffer.end(); }
@Override public int doWrite(ByteBuffer chunk) throws IOException { int result = chunk.remaining(); if (result <= 0) { return 0; } int pos = calculateChunkHeader(result); chunkHeader.position(pos + 1).limit(chunkHeader.position() + 9 - pos); buffer.doWrite(chunkHeader); buffer.doWrite(chunk); chunkHeader.position(8).limit(10); buffer.doWrite(chunkHeader); return result; }
@Override public long getBytesWritten() { return buffer.getBytesWritten(); }
@Override public void flush() throws IOException { this.buffer.flush(); }
@Override public void end() throws IOException { if (compressionStream == null) { compressionStream = new GZIPOutputStream(fakeOutputStream, true); } compressionStream.finish(); compressionStream.close(); buffer.end(); }
@Override public long getBytesWritten() { if (lastActiveFilter == -1) { return outputStreamOutputBuffer.getBytesWritten(); } else { return activeFilters[lastActiveFilter].getBytesWritten(); } }
/** * Flush the response. * * @throws IOException an underlying I/O error occurred */ @Override public void flush() throws IOException { if (lastActiveFilter == -1) { outputStreamOutputBuffer.flush(); } else { activeFilters[lastActiveFilter].flush(); } }
@Override public void end() throws IOException { if (responseFinished) { return; } if (lastActiveFilter == -1) { outputStreamOutputBuffer.end(); } else { activeFilters[lastActiveFilter].end(); } responseFinished = true; }