protected boolean checkIfNoneMatch ( final HttpServletRequest request , final HttpServletResponse response , final Attributes resourceAttributes ) throws IOException { final String eTag = resourceAttributes . getETag ( ) ; final String headerValue = request . getHeader ( "If-None-Match" ) ; if ( headerValue != null ) { boolean conditionSatisfied = false ; if ( ! headerValue . equals ( "*" ) ) { final StringTokenizer commaTokenizer = new StringTokenizer ( headerValue , "," ) ; while ( ! conditionSatisfied && commaTokenizer . hasMoreTokens ( ) ) { final String currentToken = commaTokenizer . nextToken ( ) ; if ( currentToken . trim ( ) . equals ( eTag ) ) conditionSatisfied = true ; } } else { conditionSatisfied = true ; } if ( conditionSatisfied ) { // For GET and HEAD, we should respond with // 304 Not Modified. // For every other method, 412 Precondition Failed is sent // back. if ( ( "GET" . equals ( request . getMethod ( ) ) ) || ( "HEAD" . equals ( request . getMethod ( ) ) ) ) { response . setStatus ( HttpServletResponse . SC_NOT_MODIFIED ) ; response . setHeader ( "ETag" , eTag ) ; return false ; } response . sendError ( HttpServletResponse . SC_PRECONDITION_FAILED ) ; return false ; } } return true ; }
Check if the if - none - match condition is satisfied .