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>Allow</l> HTTP response header. 021 * 022 * <p> 023 * Valid methods for a specified resource. To be used for a 405 Method not allowed. 024 * 025 * <h5 class='figure'>Example</h5> 026 * <p class='bcode'> 027 * Allow: GET, HEAD 028 * </p> 029 * 030 * <h5 class='topic'>RFC2616 Specification</h5> 031 * 032 * The Allow entity-header field lists the set of methods supported by the resource identified by the Request-URI. 033 * The purpose of this field is strictly to inform the recipient of valid methods associated with the resource. 034 * An Allow header field MUST be present in a 405 (Method Not Allowed) response. 035 * 036 * <p class='bcode'> 037 * Allow = "Allow" ":" #Method 038 * </p> 039 * 040 * <p> 041 * Example of use: 042 * <p class='bcode'> 043 * Allow: GET, HEAD, PUT 044 * </p> 045 * 046 * <p> 047 * This field cannot prevent a client from trying other methods. 048 * However, the indications given by the Allow header field value SHOULD be followed. 049 * 050 * <p> 051 * The actual set of allowed methods is defined by the origin server at the time of each request. 052 * 053 * <p> 054 * The Allow header field MAY be provided with a PUT request to recommend the methods to be supported by the new or 055 * modified resource. 056 * 057 * <p> 058 * The server is not required to support these methods and SHOULD include an Allow header in the response giving the 059 * actual supported methods. 060 * 061 * <p> 062 * A proxy MUST NOT modify the Allow header field even if it does not understand all the methods specified, since the 063 * user agent might 064 * have other means of communicating with the origin server. 065 * 066 * <h5 class='section'>See Also:</h5><ul> 067 * <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a> 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 * 071 * @serial exclude 072 */ 073@Header("Allow") 074public class Allow extends BasicCsvHeader { 075 076 //----------------------------------------------------------------------------------------------------------------- 077 // Static 078 //----------------------------------------------------------------------------------------------------------------- 079 080 private static final long serialVersionUID = 1L; 081 private static final String NAME = "Allow"; 082 083 /** 084 * Static creator. 085 * 086 * @param value 087 * The header value. 088 * <br>Can be <jk>null</jk>. 089 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 090 */ 091 public static Allow of(String value) { 092 return value == null ? null : new Allow(value); 093 } 094 095 /** 096 * Static creator. 097 * 098 * @param value 099 * The header value. 100 * <br>Can be <jk>null</jk>. 101 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 102 */ 103 public static Allow of(String...value) { 104 return value == null ? null : new Allow(value); 105 } 106 107 /** 108 * Static creator with delayed value. 109 * 110 * <p> 111 * Header value is re-evaluated on each call to {@link #getValue()}. 112 * 113 * @param value 114 * The supplier of the header value. 115 * <br>Can be <jk>null</jk>. 116 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 117 */ 118 public static Allow of(Supplier<String[]> value) { 119 return value == null ? null : new Allow(value); 120 } 121 122 //----------------------------------------------------------------------------------------------------------------- 123 // Instance 124 //----------------------------------------------------------------------------------------------------------------- 125 126 /** 127 * Constructor. 128 * 129 * @param value 130 * The header value. 131 * <br>Can be <jk>null</jk>. 132 */ 133 public Allow(String value) { 134 super(NAME, value); 135 } 136 137 /** 138 * Constructor. 139 * 140 * @param value 141 * The header value. 142 * <br>Can be <jk>null</jk>. 143 */ 144 public Allow(String...value) { 145 super(NAME, value); 146 } 147 148 /** 149 * Constructor with delayed value. 150 * 151 * <p> 152 * Header value is re-evaluated on each call to {@link #getValue()}. 153 * 154 * @param value 155 * The supplier of the header value. 156 * <br>Can be <jk>null</jk>. 157 */ 158 public Allow(Supplier<String[]> value) { 159 super(NAME, value); 160 } 161}