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 private static final long serialVersionUID = 1L; 079 private static final String NAME = "Pragma"; 080 081 /** 082 * Static creator. 083 * 084 * @param value 085 * The header value. 086 * <br>Can be <jk>null</jk>. 087 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 088 */ 089 public static Pragma of(String value) { 090 return value == null ? null : new Pragma(value); 091 } 092 093 /** 094 * Static creator with delayed value. 095 * 096 * <p> 097 * Header value is re-evaluated on each call to {@link #getValue()}. 098 * 099 * @param value 100 * The supplier of the header value. 101 * <br>Can be <jk>null</jk>. 102 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 103 */ 104 public static Pragma of(Supplier<String> value) { 105 return value == null ? null : new Pragma(value); 106 } 107 108 /** 109 * Constructor. 110 * 111 * @param value 112 * The header value. 113 * <br>Can be <jk>null</jk>. 114 */ 115 public Pragma(String value) { 116 super(NAME, value); 117 } 118 119 /** 120 * Constructor with delayed value. 121 * 122 * <p> 123 * Header value is re-evaluated on each call to {@link #getValue()}. 124 * 125 * @param value 126 * The supplier of the header value. 127 * <br>Can be <jk>null</jk>. 128 */ 129 public Pragma(Supplier<String> value) { 130 super(NAME, value); 131 } 132}