@Test public void testAcceptGzipEncoding() { GZipRequestResponseFactory requestResponseFactory = new GZipRequestResponseFactory(new Application()); HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class); Mockito.doReturn(null).when(httpServletRequest).getHeader("accept-encoding"); assertFalse(requestResponseFactory.acceptsGZipEncoding(httpServletRequest)); Mockito.doReturn("gzip,deflate,identity").when(httpServletRequest).getHeader("accept-encoding"); assertTrue(requestResponseFactory.acceptsGZipEncoding(httpServletRequest)); Mockito.doReturn("*").when(httpServletRequest).getHeader("accept-encoding"); assertTrue(requestResponseFactory.acceptsGZipEncoding(httpServletRequest)); Mockito.doReturn("deflate,identity").when(httpServletRequest).getHeader("accept-encoding"); assertFalse(requestResponseFactory.acceptsGZipEncoding(httpServletRequest)); }
protected boolean acceptsGZipEncoding(HttpServletRequest httpServletRequest) { String acceptEncoding = httpServletRequest.getHeader("accept-encoding"); return !StringUtils.isNullOrEmpty(acceptEncoding) && ( acceptEncoding.contains("gzip") || acceptEncoding.contains("*") ); }
GZipRequestResponseFactory extends RequestResponseFactory { protected boolean acceptsGZipEncoding(HttpServletRequest httpServletRequest) { String acceptEncoding = httpServletRequest.getHeader("accept-encoding"); return !StringUtils.isNullOrEmpty(acceptEncoding) && ( acceptEncoding.contains("gzip") || acceptEncoding.contains("*") ); } }
GZipRequestResponseFactory extends RequestResponseFactory { protected boolean acceptsGZipEncoding(HttpServletRequest httpServletRequest) { String acceptEncoding = httpServletRequest.getHeader("accept-encoding"); return !StringUtils.isNullOrEmpty(acceptEncoding) && ( acceptEncoding.contains("gzip") || acceptEncoding.contains("*") ); } GZipRequestResponseFactory(Application application); }
GZipRequestResponseFactory extends RequestResponseFactory { protected boolean acceptsGZipEncoding(HttpServletRequest httpServletRequest) { String acceptEncoding = httpServletRequest.getHeader("accept-encoding"); return !StringUtils.isNullOrEmpty(acceptEncoding) && ( acceptEncoding.contains("gzip") || acceptEncoding.contains("*") ); } GZipRequestResponseFactory(Application application); @Override RequestResponse createRequestResponse(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse); }
GZipRequestResponseFactory extends RequestResponseFactory { protected boolean acceptsGZipEncoding(HttpServletRequest httpServletRequest) { String acceptEncoding = httpServletRequest.getHeader("accept-encoding"); return !StringUtils.isNullOrEmpty(acceptEncoding) && ( acceptEncoding.contains("gzip") || acceptEncoding.contains("*") ); } GZipRequestResponseFactory(Application application); @Override RequestResponse createRequestResponse(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse);  }