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.util.function.*;
016
017import org.apache.juneau.http.annotation.*;
018
019/**
020 * Represents a parsed <l>Pragma</l> HTTP request/response header.
021 *
022 * <p>
023 * Implementation-specific fields that may have various effects anywhere along the request-response chain.
024 *
025 * <h5 class='figure'>Example</h5>
026 * <p class='bcode'>
027 *    Pragma: no-cache
028 * </p>
029 *
030 * <h5 class='topic'>RFC2616 Specification</h5>
031 *
032 * The Pragma general-header field is used to include implementation- specific directives that might apply to any
033 * recipient along the request/response chain.
034 * All pragma directives specify optional behavior from the viewpoint of the protocol; however, some systems MAY
035 * require that behavior be consistent with the directives.
036 *
037 * <p class='bcode'>
038 *    Pragma            = "Pragma" ":" 1#pragma-directive
039 *    pragma-directive  = "no-cache" | extension-pragma
040 *    extension-pragma  = token [ "=" ( token | quoted-string ) ]
041 * </p>
042 *
043 * <p>
044 * When the no-cache directive is present in a request message, an application SHOULD forward the request toward the
045 * origin server even if it has a cached copy of what is being requested.
046 * This pragma directive has the same semantics as the no-cache cache-directive (see section 14.9) and is defined here
047 * for backward compatibility with HTTP/1.0.
048 * Clients SHOULD include both header fields when a no-cache request is sent to a server not known to be HTTP/1.1
049 * compliant.
050 *
051 * <p>
052 * Pragma directives MUST be passed through by a proxy or gateway application, regardless of their significance to that
053 * application, since the directives might be applicable to all recipients along the request/response chain.
054 * It is not possible to specify a pragma for a specific recipient; however, any pragma directive not relevant to a
055 * recipient SHOULD be ignored by that recipient.
056 *
057 * <p>
058 * HTTP/1.1 caches SHOULD treat "Pragma: no-cache" as if the client had sent "Cache-Control: no-cache".
059 * No new Pragma directives will be defined in HTTP.
060 *
061 * <p>
062 * Note: because the meaning of "Pragma: no-cache as a response header field is not actually specified, it does not
063 * provide a reliable replacement for "Cache-Control: no-cache" in a response.
064 *
065 * <h5 class='section'>See Also:</h5><ul>
066 *    <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a>
067 *    <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a>
068 * </ul>
069 *
070 * @serial exclude
071 */
072@Header("Pragma")
073public class Pragma extends BasicStringHeader {
074
075   //-----------------------------------------------------------------------------------------------------------------
076   // Static
077   //-----------------------------------------------------------------------------------------------------------------
078
079   private static final long serialVersionUID = 1L;
080   private static final String NAME = "Pragma";
081
082   /**
083    * Static creator.
084    *
085    * @param value
086    *    The header value.
087    *    <br>Can be <jk>null</jk>.
088    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
089    */
090   public static Pragma of(String value) {
091      return value == null ? null : new Pragma(value);
092   }
093
094   /**
095    * Static creator with delayed value.
096    *
097    * <p>
098    * Header value is re-evaluated on each call to {@link #getValue()}.
099    *
100    * @param value
101    *    The supplier of the header value.
102    *    <br>Can be <jk>null</jk>.
103    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
104    */
105   public static Pragma of(Supplier<String> value) {
106      return value == null ? null : new Pragma(value);
107   }
108
109   //-----------------------------------------------------------------------------------------------------------------
110   // Instance
111   //-----------------------------------------------------------------------------------------------------------------
112
113   /**
114    * Constructor.
115    *
116    * @param value
117    *    The header value.
118    *    <br>Can be <jk>null</jk>.
119    */
120   public Pragma(String value) {
121      super(NAME, value);
122   }
123
124   /**
125    * Constructor with delayed value.
126    *
127    * <p>
128    * Header value is re-evaluated on each call to {@link #getValue()}.
129    *
130    * @param value
131    *    The supplier of the header value.
132    *    <br>Can be <jk>null</jk>.
133    */
134   public Pragma(Supplier<String> value) {
135      super(NAME, value);
136   }
137}