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>Max-Forwards</l> HTTP request header.
019 *
020 * <p>
021 * Limit the number of times the message can be forwarded through proxies or gateways.
022 *
023 * <h5 class='figure'>Example</h5>
024 * <p class='bcode w800'>
025 *    Max-Forwards: 10
026 * </p>
027 *
028 * <h5 class='topic'>RFC2616 Specification</h5>
029 *
030 * The Max-Forwards request-header field provides a mechanism with the TRACE (section 9.8) and OPTIONS (section 9.2)
031 * methods to limit the number of proxies or gateways that can forward the request to the next inbound server.
032 * This can be useful when the client is attempting to trace a request chain which appears to be failing or looping in
033 * mid-chain.
034 *
035 * <p class='bcode w800'>
036 *    Max-Forwards   = "Max-Forwards" ":" 1*DIGIT
037 * </p>
038 *
039 * <p>
040 * The Max-Forwards value is a decimal integer indicating the remaining number of times this request message may be
041 * forwarded.
042 *
043 * <p>
044 * Each proxy or gateway recipient of a TRACE or OPTIONS request containing a Max-Forwards header field MUST check and
045 * update its value prior to forwarding the request.
046 * If the received value is zero (0), the recipient MUST NOT forward the request; instead, it MUST respond as the final
047 * recipient.
048 * If the received Max-Forwards value is greater than zero, then the forwarded message MUST contain an updated
049 * Max-Forwards field with a value decremented by one (1).
050 *
051 * <p>
052 * The Max-Forwards header field MAY be ignored for all other methods defined by this specification and for any
053 * extension methods for which it is not explicitly referred to as part of that method definition.
054 *
055 * <h5 class='section'>See Also:</h5>
056 * <ul class='doctree'>
057 *    <li class='extlink'>{@doc RFC2616}
058 * </ul>
059 */
060@Header("Max-Forwards")
061public final class MaxForwards extends HeaderInteger {
062
063   /**
064    * Constructor.
065    *
066    * @param value
067    */
068   public MaxForwards(Integer value) {
069      super(value);
070   }
071
072   /**
073    * Returns a parsed <code>Max-Forwards</code> header.
074    *
075    * @param value The <code>Max-Forwards</code> header string.
076    * @return The parsed <code>Max-Forwards</code> header, or <jk>null</jk> if the string was null.
077    */
078   public static MaxForwards forString(String value) {
079      if (value == null)
080         return null;
081      return new MaxForwards(value);
082   }
083
084   private MaxForwards(String value) {
085      super(value);
086   }
087}