use of org.springframework.util.FastByteArrayOutputStream in project BroadleafCommerce by BroadleafCommerce.
the class CachingCompressedResponseFilter method processDynamic.
protected void processDynamic(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
ContentCachingResponseWrapper wrapper = new ContentCachingResponseWrapper(response);
chain.doFilter(request, wrapper);
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(1024);
GZIPOutputStream zip = new GZIPOutputStream(baos);
StreamUtils.copy(wrapper.getContentInputStream(), zip);
zip.close();
response.addHeader("Content-Encoding", "gzip");
response.setContentLength(baos.size());
StreamUtils.copy(new ByteArrayInputStream(baos.toByteArray()), response.getOutputStream());
}
Aggregations