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>Vary</l> HTTP response header.
017 * 
018 * <p>
019 * Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather
020 * than requesting a fresh one from the origin server.
021 * 
022 * <h5 class='figure'>Example</h5>
023 * <p class='bcode'>
024 *    Vary: *
025 *    Vary: Accept-Language
026 * </p>
027 * 
028 * <h5 class='topic'>RFC2616 Specification</h5>
029 * 
030 * The Vary field value indicates the set of request-header fields that fully determines, while the response is fresh,
031 * whether a cache is permitted to use the response to reply to a subsequent request without revalidation.
032 * For uncacheable or stale responses, the Vary field value advises the user agent about the criteria that were used to
033 * select the representation.
034 * A Vary field value of "*" implies that a cache cannot determine from the request headers of a subsequent request
035 * whether this response is the appropriate representation.
036 * See section 13.6 for use of the Vary header field by caches.
037 * <p class='bcode'>
038 *    Vary  = "Vary" ":" ( "*" | 1#field-name )
039 * </p>
040 * 
041 * <p>
042 * An HTTP/1.1 server SHOULD include a Vary header field with any cacheable response that is subject to server-driven
043 * negotiation.
044 * Doing so allows a cache to properly interpret future requests on that resource and informs the user agent about the
045 * presence of negotiation on that resource.
046 * A server MAY include a Vary header field with a non-cacheable response that is subject to server-driven negotiation,
047 * since this might provide the user agent with useful information about the dimensions over which the response varies
048 * at the time of the response.
049 * 
050 * <p>
051 * A Vary field value consisting of a list of field-names signals that the representation selected for the response is
052 * based on a selection algorithm which considers ONLY the listed request-header field values in selecting the most
053 * appropriate representation.
054 * A cache MAY assume that the same selection will be made for future requests with the same values for the listed
055 * field names, for the duration of time for which the response is fresh.
056 * 
057 * <p>
058 * The field-names given are not limited to the set of standard request-header fields defined by this specification.
059 * Field names are case-insensitive.
060 * 
061 * <p>
062 * A Vary field value of "*" signals that unspecified parameters not limited to the request-headers (e.g., the network
063 * address of the client), play a role in the selection of the response representation.
064 * The "*" value MUST NOT be generated by a proxy server; it may only be generated by an origin server.
065 * 
066 * <h5 class='section'>See Also:</h5>
067 * <ul class='doctree'>
068 *    <li class='extlink'><a class='doclink' href='https://www.w3.org/Protocols/rfc2616/rfc2616.html'>Hypertext Transfer Protocol -- HTTP/1.1</a>
069 * </ul>
070 */
071public final class Vary extends HeaderString {
072
073   /**
074    * Returns a parsed <code>Vary</code> header.
075    * 
076    * @param value The <code>Vary</code> header string.
077    * @return The parsed <code>Vary</code> header, or <jk>null</jk> if the string was null.
078    */
079   public static Vary forString(String value) {
080      if (value == null)
081         return null;
082      return new Vary(value);
083   }
084
085   private Vary(String value) {
086      super(value);
087   }
088}