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 015/** 016 * Represents a parsed <l>If-Modified-Since</l> HTTP request header. 017 * 018 * <p> 019 * Allows a 304 Not Modified to be returned if content is unchanged. 020 * 021 * <h5 class='figure'>Example</h5> 022 * <p class='bcode'> 023 * If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT 024 * </p> 025 * 026 * <h5 class='topic'>RFC2616 Specification</h5> 027 * 028 * The If-Modified-Since request-header field is used with a method to make it conditional: 029 * if the requested variant has not been modified since the time specified in this field, an entity will not be returned 030 * from the server; instead, a 304 (not modified) response will be returned without any message-body. 031 * 032 * <p class='bcode'> 033 * If-Modified-Since = "If-Modified-Since" ":" HTTP-date 034 * </p> 035 * 036 * <p> 037 * An example of the field is: 038 * <p class='bcode'> 039 * If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT 040 * </p> 041 * 042 * <p> 043 * A GET method with an If-Modified-Since header and no Range header requests that the identified entity be transferred 044 * only if it has been modified since the date given by the If-Modified-Since header. 045 * The algorithm for determining this includes the following cases: 046 * <ol> 047 * <li>If the request would normally result in anything other than a 200 (OK) status, or if the passed 048 * If-Modified-Since date is invalid, the response is exactly the same as for a normal GET. 049 * A date which is later than the server's current time is invalid. 050 * <li>If the variant has been modified since the If-Modified-Since date, the response is exactly the same as for a 051 * normal GET. 052 * <li>If the variant has not been modified since a valid If-Modified-Since date, the server SHOULD return a 304 053 * (Not Modified) response. 054 * </ol> 055 * 056 * <p> 057 * The purpose of this feature is to allow efficient updates of cached information with a minimum amount of transaction 058 * overhead. 059 * 060 * <p> 061 * Note: The Range request-header field modifies the meaning of If-Modified-Since; see section 14.35 for full details. 062 * 063 * <p> 064 * Note: If-Modified-Since times are interpreted by the server, whose clock might not be synchronized with the client. 065 * 066 * <p> 067 * Note: When handling an If-Modified-Since header field, some servers will use an exact date comparison function, 068 * rather than a less-than function, for deciding whether to send a 304 (Not Modified) response. 069 * To get best results when sending an If-Modified-Since header field for cache validation, clients are 070 * advised to use the exact date string received in a previous Last-Modified header field whenever possible. 071 * 072 * <p> 073 * Note: If a client uses an arbitrary date in the If-Modified-Since header instead of a date taken from the 074 * Last-Modified header for the same request, the client should be aware of the fact that this date is interpreted in 075 * the server's understanding of time. 076 * The client should consider unsynchronized clocks and rounding problems due to the different encodings of time between 077 * the client and server. 078 * This includes the possibility of race conditions if the document has changed between the time it was first requested 079 * and the If-Modified-Since date of a subsequent request, and the possibility of clock-skew-related problems if the 080 * If-Modified-Since date is derived from the client's clock without correction to the server's clock. 081 * Corrections for different time bases between client and server are at best approximate due to network latency. 082 * The result of a request having both an If-Modified-Since header field and either an If-Match or an 083 * If-Unmodified-Since header fields is undefined by this specification. 084 * 085 * <h5 class='section'>See Also:</h5> 086 * <ul class='doctree'> 087 * <li class='extlink'><a class='doclink' href='https://www.w3.org/Protocols/rfc2616/rfc2616.html'>Hypertext Transfer Protocol -- HTTP/1.1</a> 088 * </ul> 089 */ 090public final class IfModifiedSince extends HeaderDate { 091 092 /** 093 * Returns a parsed <code>If-Modified-Since</code> header. 094 * 095 * @param value The <code>If-Modified-Since</code> header string. 096 * @return The parsed <code>If-Modified-Since</code> header, or <jk>null</jk> if the string was null. 097 */ 098 public static IfModifiedSince forString(String value) { 099 if (value == null) 100 return null; 101 return new IfModifiedSince(value); 102 } 103 104 private IfModifiedSince(String value) { 105 super(value); 106 } 107}