001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.http; 014 015import org.apache.juneau.http.annotation.*; 016 017/** 018 * Represents a parsed <l>If-None-Match</l> HTTP request header. 019 * 020 * <p> 021 * Allows a 304 Not Modified to be returned if content is unchanged. 022 * 023 * <h5 class='figure'>Example</h5> 024 * <p class='bcode w800'> 025 * If-None-Match: "737060cd8c284d8af7ad3082f209582d" 026 * </p> 027 * 028 * <h5 class='topic'>RFC2616 Specification</h5> 029 * 030 * The If-None-Match request-header field is used with a method to make it conditional. 031 * A client that has one or more entities previously obtained from the resource can verify that none of those entities 032 * is current by including a list of their associated entity tags in the If-None-Match header field. 033 * The purpose of this feature is to allow efficient updates of cached information with a minimum amount of transaction 034 * overhead. 035 * It is also used to prevent a method (e.g. PUT) from inadvertently modifying an existing resource when the client 036 * believes that the resource does not exist. 037 * 038 * <p> 039 * As a special case, the value "*" matches any current entity of the resource. 040 * 041 * <p class='bcode w800'> 042 * If-None-Match = "If-None-Match" ":" ( "*" | 1#entity-tag ) 043 * </p> 044 * 045 * <p> 046 * If any of the entity tags match the entity tag of the entity that would have been returned in the response to a 047 * similar GET request (without the If-None-Match header) on that resource, or if "*" is given 048 * and any current entity exists for that resource, then the server MUST NOT perform the requested method, unless 049 * required to do so because the resource's modification date fails to match that supplied in an If-Modified-Since 050 * header field in the request. 051 * Instead, if the request method was GET or HEAD, the server SHOULD respond with a 304 (Not Modified) response, 052 * including the cache- related header fields (particularly ETag) of one of the entities that matched. 053 * For all other request methods, the server MUST respond with a status of 412 (Precondition Failed). 054 * 055 * <p> 056 * See section 13.3.3 for rules on how to determine if two entities tags match. 057 * The weak comparison function can only be used with GET or HEAD requests. 058 * 059 * <p> 060 * If none of the entity tags match, then the server MAY perform the requested method as if the If-None-Match header 061 * field did not exist, but MUST also ignore any If-Modified-Since header field(s) in the request. 062 * That is, if no entity tags match, then the server MUST NOT return a 304 (Not Modified) response. 063 * 064 * <p> 065 * If the request would, without the If-None-Match header field, result in anything other than a 2xx or 304 status, 066 * then the If-None-Match header MUST be ignored. 067 * (See section 13.3.4 for a discussion of server behavior when both If-Modified-Since and If-None-Match appear in the 068 * same request.) 069 * 070 * <p> 071 * The meaning of "If-None-Match: *" is that the method MUST NOT be performed if the representation selected by the 072 * origin server (or by a cache, possibly using the Vary mechanism, see section 14.44) exists, and SHOULD be performed 073 * if the representation does not exist. 074 * This feature is intended to be useful in preventing races between PUT operations. 075 * 076 * <p> 077 * Examples: 078 * <p class='bcode w800'> 079 * If-None-Match: "xyzzy" 080 * If-None-Match: W/"xyzzy" 081 * If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz" 082 * If-None-Match: W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz" 083 * If-None-Match: * 084 * </p> 085 * 086 * <p> 087 * The result of a request having both an If-None-Match header field and either an If-Match or an If-Unmodified-Since 088 * header fields is undefined by this specification. 089 * 090 * <ul class='seealso'> 091 * <li class='extlink'>{@doc RFC2616} 092 * </ul> 093 */ 094@Header("If-None-Match") 095public final class IfNoneMatch extends HeaderEntityValidatorArray { 096 097 /** 098 * Returns a parsed <c>If-None-Match</c> header. 099 * 100 * @param value The <c>If-None-Match</c> header string. 101 * @return The parsed <c>If-None-Match</c> header, or <jk>null</jk> if the string was null. 102 */ 103 public static IfNoneMatch forString(String value) { 104 if (value == null) 105 return null; 106 return new IfNoneMatch(value); 107 } 108 109 private IfNoneMatch(String value) { 110 super(value); 111 } 112}