WroUtil { @SuppressWarnings("unchecked") public static boolean isGzipSupported(final HttpServletRequest request) { if (request != null) { final Enumeration<String> headerNames = request.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { final String headerName = headerNames.nextElement(); final Matcher m = PATTERN_ACCEPT_ENCODING.matcher(headerName); if (m.find()) { final String headerValue = request.getHeader(headerName); final Matcher mValue = PATTERN_GZIP.matcher(headerValue); return mValue.find(); } } } } return false; } private  WroUtil(); static ThreadFactory createDaemonThreadFactory(final String name); static String toDateAsString(final long milliseconds); static String getPathInfoFromLocation(final HttpServletRequest request, final String location); static boolean startsWithIgnoreCase(final String str, final String prefix); static String toPackageAsFolder(final Class<?> clazz); static String getServletPathFromLocation(final HttpServletRequest request, final String location); @SuppressWarnings("unchecked") static boolean isGzipSupported(final HttpServletRequest request); static String toJSMultiLineString(final String data); static boolean matchesUrl(final HttpServletRequest request, final String path); static ResourcePostProcessor newResourceProcessor(final Resource resource,
      final ResourcePreProcessor preProcessor); static WroModelFactory factoryFor(final WroModel model); static ObjectFactory<T> simpleObjectFactory(final T object); static String loadRegexpWithKey(final String key); static String getImplementationVersion(); static void safeCopy(final Reader reader, final Writer writer); static File createTempFile(); static File createTempFile(final String extension); static File createTempDirectory(); static String joinPath(final String left, final String right); static final String cleanImageUrl(final String imageUrl); static final String removeQueryString(final String path); static final File getWorkingDirectory(); static final String getFullPath(final String path); static final String normalize(final String path); static final Pattern EMTPY_LINE_PATTERN; static final InputStream EMPTY_STREAM; }
@Test public void testGzipSupport() throws Exception { HttpServletRequest request = mockRequestHeader("", ""); assertFalse(WroUtil.isGzipSupported(request)); request = mockRequestHeader("Accept-Encoding", ""); assertFalse(WroUtil.isGzipSupported(request)); request = mockRequestHeader("Accept-Encoding", "gzip, deflate"); assertTrue(WroUtil.isGzipSupported(request)); request = mockRequestHeader("Accept-Encoding", "XYZ"); assertFalse(WroUtil.isGzipSupported(request)); request = mockRequestHeader("Accept-EncodXng", "XXXXXXXXXXXXX"); assertTrue(WroUtil.isGzipSupported(request)); request = mockRequestHeader("X-cept-Encoding", "gzip,deflate"); assertTrue(WroUtil.isGzipSupported(request)); request = mockRequestHeader("XXXXXXXXXXXXXXX", "XXXXXXXXXXXXX"); assertTrue(WroUtil.isGzipSupported(request)); request = mockRequestHeader("XXXXXXXXXXXXXXXX", "gzip, deflate"); assertFalse(WroUtil.isGzipSupported(request)); request = mockRequestHeader("---------------", "-------------"); assertTrue(WroUtil.isGzipSupported(request)); request = mockRequestHeader("~~~~~~~~~~~~~~~", "~~~~~~~~~~~~~"); assertTrue(WroUtil.isGzipSupported(request)); request = mockRequestHeader("Accept-Encoding", "gzip,deflate,sdch"); assertTrue(WroUtil.isGzipSupported(request)); }