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>Allow</l> HTTP response header.
019 *
020 * <p>
021 * Valid methods for a specified resource. To be used for a 405 Method not allowed.
022 *
023 * <h5 class='figure'>Example</h5>
024 * <p class='bcode w800'>
025 *    Allow: GET, HEAD
026 * </p>
027 *
028 * <h5 class='topic'>RFC2616 Specification</h5>
029 *
030 * The Allow entity-header field lists the set of methods supported by the resource identified by the Request-URI.
031 * The purpose of this field is strictly to inform the recipient of valid methods associated with the resource.
032 * An Allow header field MUST be present in a 405 (Method Not Allowed) response.
033 *
034 * <p class='bcode w800'>
035 *    Allow   = "Allow" ":" #Method
036 * </p>
037 *
038 * <p>
039 * Example of use:
040 * <p class='bcode w800'>
041 *    Allow: GET, HEAD, PUT
042 * </p>
043 *
044 * <p>
045 * This field cannot prevent a client from trying other methods.
046 * However, the indications given by the Allow header field value SHOULD be followed.
047 *
048 * <p>
049 * The actual set of allowed methods is defined by the origin server at the time of each request.
050 *
051 * <p>
052 * The Allow header field MAY be provided with a PUT request to recommend the methods to be supported by the new or
053 * modified resource.
054 *
055 * <p>
056 * The server is not required to support these methods and SHOULD include an Allow header in the response giving the
057 * actual supported methods.
058 *
059 * <p>
060 * A proxy MUST NOT modify the Allow header field even if it does not understand all the methods specified, since the
061 * user agent might
062 * have other means of communicating with the origin server.
063 *
064 * <h5 class='section'>See Also:</h5>
065 * <ul class='doctree'>
066 *    <li class='extlink'>{@doc RFC2616}
067 * </ul>
068 */
069@Header("Allow")
070public final class Allow extends HeaderStringArray {
071
072   /**
073    * Constructor.
074    *
075    * @param value
076    */
077   public Allow(String[] value) {
078      super(value);
079   }
080
081   /**
082    * Returns a parsed <code>Allow</code> header.
083    *
084    * @param value The <code>Allow</code> header string.
085    * @return The parsed <code>Allow</code> header, or <jk>null</jk> if the string was null.
086    */
087   public static Allow forString(String value) {
088      if (value == null)
089         return null;
090      return new Allow(value);
091   }
092
093   private Allow(String value) {
094      super(value);
095   }
096}