@Test public void testProcessShouldDoNothingWhenGzipCompressionIsNotNeeded() { given(req.getHeader(HEADER_KEY_ACCEPT_ENCODING)).willReturn("nothing"); underTest.process(req, resp, responseBody); verify(resp, times(0)).addHeader(HEADER_KEY_CONTENT_ENCODING, HEADER_VALUE_GZIP); verify(gzipCompressor, times(0)).compress(any(ByteArrayInputStream.class)); }
@Override public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) { byte[] result = responseBody; if (isGzipCompressionNeeded(req, resp)) { resp.addHeader(HEADER_KEY_CONTENT_ENCODING, HEADER_VALUE_GZIP); result = compressResponseStreamWithGzip(inputStreamFactory.createByteArrayInputStream(responseBody)); } return result; }
GzipCompressorProcessor implements ResponseProcessor { @Override public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) { byte[] result = responseBody; if (isGzipCompressionNeeded(req, resp)) { resp.addHeader(HEADER_KEY_CONTENT_ENCODING, HEADER_VALUE_GZIP); result = compressResponseStreamWithGzip(inputStreamFactory.createByteArrayInputStream(responseBody)); } return result; } }
GzipCompressorProcessor implements ResponseProcessor { @Override public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) { byte[] result = responseBody; if (isGzipCompressionNeeded(req, resp)) { resp.addHeader(HEADER_KEY_CONTENT_ENCODING, HEADER_VALUE_GZIP); result = compressResponseStreamWithGzip(inputStreamFactory.createByteArrayInputStream(responseBody)); } return result; }  }
GzipCompressorProcessor implements ResponseProcessor { @Override public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) { byte[] result = responseBody; if (isGzipCompressionNeeded(req, resp)) { resp.addHeader(HEADER_KEY_CONTENT_ENCODING, HEADER_VALUE_GZIP); result = compressResponseStreamWithGzip(inputStreamFactory.createByteArrayInputStream(responseBody)); } return result; }  @Override byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody); }
GzipCompressorProcessor implements ResponseProcessor { @Override public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) { byte[] result = responseBody; if (isGzipCompressionNeeded(req, resp)) { resp.addHeader(HEADER_KEY_CONTENT_ENCODING, HEADER_VALUE_GZIP); result = compressResponseStreamWithGzip(inputStreamFactory.createByteArrayInputStream(responseBody)); } return result; }  @Override byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody);  }