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