+ empty = false;
+ if (left == 0)
+ decorate();
+ left--;
+ out.write(i);
+ }
+ }
+
+
+ final class GZIPServletOutputStream extends CountingServletOutputStream {
+
+ final static int MINIMAL_BUFFER_SIZE = 128;
+
+ private ByteArrayOutputStream buffer;
+ private OutputStream out;
+ private GZIPOutputStream zout;
+ private int bufferSize;
+ private boolean decorated = false;
+
+
+ public GZIPServletOutputStream() throws IOException {
+ setBuffer(AcceleratorFilter.this.buffer);
+ }
+
+
+ @Override
+ void finish() throws IOException {
+ decorate();
+ zout.finish();
+ super.out.write(buffer.toByteArray());
+ }
+
+ @Override
+ boolean isZipped() {
+ if (decorated)
+ return true;
+ return !empty;
+ }
+
+ @Override
+ void setBuffer(int size) throws IllegalStateException {
+ if (!empty)
+ throw new IllegalStateException("attemp to change buffer size after writing data to response!");
+
+ if (size > MINIMAL_BUFFER_SIZE) {
+ left = size;