001package co.codewizards.cloudstore.rest.shared.interceptor; 002 003import java.io.IOException; 004 005import javax.ws.rs.WebApplicationException; 006import javax.ws.rs.ext.WriterInterceptorContext; 007 008import co.codewizards.cloudstore.rest.shared.GZIPUtil; 009 010/** 011 * Interceptor compressing response only if corresponding request was also compressed 012 * @author Wojtek Wilk - wilk.wojtek at gmail.com 013 */ 014public class GZIPConditionalWriterInterceptor extends GZIPWriterInterceptor{ 015 016 @Override 017 public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { 018 if(GZIPUtil.isRequestCompressedWithGzip(context)){ 019 super.aroundWriteTo(context); 020 } else { 021 context.proceed(); 022 } 023 } 024}