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.header; 014 015import java.time.*; 016import java.util.function.*; 017 018import org.apache.juneau.http.annotation.*; 019 020/** 021 * Represents a parsed <l>If-Unmodified-Since</l> HTTP request header. 022 * 023 * <p> 024 * Only send the response if the entity has not been modified since a specific time. 025 * 026 * <h5 class='figure'>Example</h5> 027 * <p class='bcode'> 028 * If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT 029 * </p> 030 * 031 * <h5 class='topic'>RFC2616 Specification</h5> 032 * 033 * The If-Unmodified-Since request-header field is used with a method to make it conditional. 034 * If the requested resource has not been modified since the time specified in this field, the server SHOULD perform the 035 * requested operation as if the If-Unmodified-Since header were not present. 036 * 037 * <p> 038 * If the requested variant has been modified since the specified time, the server MUST NOT perform the requested 039 * operation, and MUST return a 412 (Precondition Failed). 040 * 041 * <p class='bcode'> 042 * If-Unmodified-Since = "If-Unmodified-Since" ":" HTTP-date 043 * </p> 044 * 045 * <p> 046 * An example of the field is: 047 * <p class='bcode'> 048 * If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT 049 * </p> 050 * 051 * <p> 052 * If the request normally (i.e., without the If-Unmodified-Since header) would result in anything other than a 2xx or 053 * 412 status, the If-Unmodified-Since header SHOULD be ignored. 054 * 055 * <p> 056 * If the specified date is invalid, the header is ignored. 057 * 058 * <p> 059 * The result of a request having both an If-Unmodified-Since header field and either an If-None-Match or an 060 * If-Modified-Since header fields is undefined by this specification. 061 * 062 * <h5 class='section'>See Also:</h5><ul> 063 * <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a> 064 * <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a> 065 * </ul> 066 * 067 * @serial exclude 068 */ 069@Header("If-Unmodified-Since") 070public class IfUnmodifiedSince extends BasicDateHeader { 071 072 //----------------------------------------------------------------------------------------------------------------- 073 // Static 074 //----------------------------------------------------------------------------------------------------------------- 075 076 private static final long serialVersionUID = 1L; 077 private static final String NAME = "If-Unmodified-Since"; 078 079 /** 080 * Static creator. 081 * 082 * @param value 083 * The header value. 084 * <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>). 085 * <br>Can be <jk>null</jk>. 086 * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>. 087 */ 088 public static IfUnmodifiedSince of(String value) { 089 return value == null ? null : new IfUnmodifiedSince(value); 090 } 091 092 /** 093 * Static creator. 094 * 095 * @param value 096 * The header value. 097 * <br>Can be <jk>null</jk>. 098 * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>. 099 */ 100 public static IfUnmodifiedSince of(ZonedDateTime value) { 101 return value == null ? null : new IfUnmodifiedSince(value); 102 } 103 104 /** 105 * Static creator with delayed value. 106 * 107 * <p> 108 * Header value is re-evaluated on each call to {@link #getValue()}. 109 * 110 * @param value 111 * The supplier of the header value. 112 * <br>Can be <jk>null</jk>. 113 * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>. 114 */ 115 public static IfUnmodifiedSince of(Supplier<ZonedDateTime> value) { 116 return value == null ? null : new IfUnmodifiedSince(value); 117 } 118 119 //----------------------------------------------------------------------------------------------------------------- 120 // Instance 121 //----------------------------------------------------------------------------------------------------------------- 122 123 /** 124 * Constructor. 125 * 126 * @param value 127 * The header value. 128 * <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>). 129 * <br>Can be <jk>null</jk>. 130 */ 131 public IfUnmodifiedSince(String value) { 132 super(NAME, value); 133 } 134 135 /** 136 * Constructor. 137 * 138 * @param value 139 * The header value. 140 * <br>Can be <jk>null</jk>. 141 */ 142 public IfUnmodifiedSince(ZonedDateTime value) { 143 super(NAME, value); 144 } 145 146 /** 147 * Constructor with delayed value. 148 * 149 * <p> 150 * Header value is re-evaluated on each call to {@link #getValue()}. 151 * 152 * @param value 153 * The supplier of the header value. 154 * <br>Can be <jk>null</jk>. 155 */ 156 public IfUnmodifiedSince(Supplier<ZonedDateTime> value) { 157 super(NAME, value); 158 } 159}