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