jodd-servlet/src/main/java/jodd/servlet/filter/GzipFilter.java
protected boolean isGzipEligible(final HttpServletRequest request) {
		// request parameter name

		if (requestParameterName.length() != 0) {
			String forceGzipString = request.getParameter(requestParameterName);

			if (forceGzipString != null) {
				return Converter.get().toBooleanValue(forceGzipString, false);
			}
		}

		// extract uri

		String uri = request.getRequestURI();

		if (uri == null) {
			return false;
		}

		uri = uri.toLowerCase();

		boolean result = false;

		// check uri

		if (matches == null) {					// match == *
			if (extensions == null) {			// extensions == *
				return true;
			}
			// extension
			String extension = FileNameUtil.getExtension(uri);

			if (extension.length() > 0) {
				extension = extension.toLowerCase();

				if (StringUtil.equalsOne(extension, extensions) != -1) {
					result = true;
				}
			}
		} else {
			if (wildcards) {
				result = Wildcard.matchPathOne(uri, matches) != -1;
			} else {
				for (String match : matches) {
					if (uri.contains(match)) {
						result = true;
						break;
					}
				}
			}
		}

		if ((result) && (excludes != null)) {
			if (wildcards) {
				if (Wildcard.matchPathOne(uri, excludes) != -1) {
					result = false;
				}
			} else {
				for (String exclude : excludes) {
					if (uri.contains(exclude)) {
						result = false;						// excludes founded
						break;
					}
				}
			}
		}

		return result;
	}
protected boolean isGzipEligible(final HttpServletRequest request) {
		// request parameter name

		if (requestParameterName.length() != 0) {
			String forceGzipString = request.getParameter(requestParameterName);

			if (forceGzipString != null) {
				return Converter.get().toBooleanValue(forceGzipString, false);
			}
		}

		// extract uri

		String uri = request.getRequestURI();

		if (uri == null) {
			return false;
		}

		uri = uri.toLowerCase();

		boolean result = false;

		// check uri

		if (matches == null) {					// match == *
			if (extensions == null) {			// extensions == *
				return true;
			}
			// extension
			String extension = FileNameUtil.getExtension(uri);

			if (extension.length() > 0) {
				extension = extension.toLowerCase();

				if (StringUtil.equalsOne(extension, extensions) != -1) {
					result = true;
				}
			}
		} else {
			if (wildcards) {
				result = Wildcard.matchPathOne(uri, matches) != -1;
			} else {
				for (String match : matches) {
					if (uri.contains(match)) {
						result = true;
						break;
					}
				}
			}
		}

		if ((result) && (excludes != null)) {
			if (wildcards) {
				if (Wildcard.matchPathOne(uri, excludes) != -1) {
					result = false;
				}
			} else {
				for (String exclude : excludes) {
					if (uri.contains(exclude)) {
						result = false;						// excludes founded
						break;
					}
				}
			}
		}

		return result;
	}
protected boolean isGzipEligible ( final HttpServletRequest request ) { // request parameter name if ( requestParameterName . length ( ) != 0 ) { String forceGzipString = request . getParameter ( requestParameterName ) ; if ( forceGzipString != null ) { return Converter . get ( ) . toBooleanValue ( forceGzipString , false ) ; } } // extract uri String uri = request . getRequestURI ( ) ; if ( uri == null ) { return false ; } uri = uri . toLowerCase ( ) ; boolean result = false ; // check uri if ( matches == null ) { // match == * if ( extensions == null ) { // extensions == * return true ; } // extension String extension = FileNameUtil . getExtension ( uri ) ; if ( extension . length ( ) > 0 ) { extension = extension . toLowerCase ( ) ; if ( StringUtil . equalsOne ( extension , extensions ) != - 1 ) { result = true ; } } } else { if ( wildcards ) { result = Wildcard . matchPathOne ( uri , matches ) != - 1 ; } else { for ( String match : matches ) { if ( uri . contains ( match ) ) { result = true ; break ; } } } } if ( ( result ) && ( excludes != null ) ) { if ( wildcards ) { if ( Wildcard . matchPathOne ( uri , excludes ) != - 1 ) { result = false ; } } else { for ( String exclude : excludes ) { if ( uri . contains ( exclude ) ) { result = false ; // excludes founded break ; } } } } return result ; }
Determine if request is eligible for GZipping.
Determine if request is eligible for GZipping .