001
014
015 package com.liferay.portal.servlet.filters.gzip;
016
017 import com.liferay.portal.util.PropsValues;
018
019 import java.io.IOException;
020 import java.io.OutputStream;
021
022 import java.util.zip.GZIPOutputStream;
023
024 import javax.servlet.ServletOutputStream;
025
026
030 public class GZipServletOutputStream extends ServletOutputStream {
031
032 public GZipServletOutputStream(OutputStream outputStream)
033 throws IOException {
034
035 _gZipOutputStream = new GZIPOutputStream(outputStream) {
036
037 {
038 def.setLevel(PropsValues.GZIP_COMPRESSION_LEVEL);
039 }
040
041 };
042 }
043
044 @Override
045 public void close() throws IOException {
046 _gZipOutputStream.close();
047 }
048
049 @Override
050 public void flush() throws IOException {
051 _gZipOutputStream.flush();
052 }
053
054 @Override
055 public void write(byte[] bytes) throws IOException {
056 _gZipOutputStream.write(bytes);
057 }
058
059 @Override
060 public void write(byte[] bytes, int offset, int length)
061 throws IOException {
062
063 _gZipOutputStream.write(bytes, offset, length);
064 }
065
066 @Override
067 public void write(int b) throws IOException {
068 _gZipOutputStream.write(b);
069 }
070
071 private GZIPOutputStream _gZipOutputStream;
072
073 }