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>Trailer</l> HTTP response header.
019 *
020 * <p>
021 * The Trailer general field value indicates that the given set of header fields is present in the trailer of a message
022 * encoded with chunked transfer coding.
023 *
024 * <h5 class='figure'>Example</h5>
025 * <p class='bcode w800'>
026 *    Trailer: Max-Forwards
027 * </p>
028 *
029 * <h5 class='topic'>RFC2616 Specification</h5>
030 *
031 * The Trailer general field value indicates that the given set of header fields is present in the trailer of a message
032 * encoded with chunked transfer-coding.
033 *
034 * <p class='bcode w800'>
035 *    Trailer  = "Trailer" ":" 1#field-name
036 * </p>
037 *
038 * <p>
039 * An HTTP/1.1 message SHOULD include a Trailer header field in a message using chunked transfer-coding with a non-empty
040 * trailer.
041 * Doing so allows the recipient to know which header fields to expect in the trailer.
042 *
043 * <p>
044 * If no Trailer header field is present, the trailer SHOULD NOT include any header fields.
045 * See section 3.6.1 for restrictions on the use of trailer fields in a "chunked" transfer-coding.
046 *
047 * <p>
048 * Message header fields listed in the Trailer header field MUST NOT include the following header fields:
049 * <ul>
050 *    <li>Transfer-Encoding
051 *    <li>Content-Length
052 *    <li>Trailer
053 * </ul>
054 *
055 * <h5 class='section'>See Also:</h5>
056 * <ul class='doctree'>
057 *    <li class='extlink'>{@doc RFC2616}
058 * </ul>
059 */
060@Header("Trailer")
061public final class Trailer extends HeaderString {
062
063   /**
064    * Returns a parsed <code>Trailer</code> header.
065    *
066    * @param value The <code>Trailer</code> header string.
067    * @return The parsed <code>Trailer</code> header, or <jk>null</jk> if the string was null.
068    */
069   public static Trailer forString(String value) {
070      if (value == null)
071         return null;
072      return new Trailer(value);
073   }
074
075   private Trailer(String value) {
076      super(value);
077   }
078}