View Javadoc

    1   /*
    2    * Copyright 2012 The Netty Project
    3    *
    4    * The Netty Project licenses this file to you under the Apache License,
    5    * version 2.0 (the "License"); you may not use this file except in compliance
    6    * with the License. You may obtain a copy of the License at:
    7    *
    8    *   http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    13   * License for the specific language governing permissions and limitations
    14   * under the License.
    15   */
    16  package org.jboss.netty.handler.codec.http;
    17
    18  import java.util.List;
    19  import java.util.Map;
    20  import java.util.Set;
    21
    22  /**
    23   * The last {@link HttpChunk} which has trailing headers.
    24   */
    25  public interface HttpChunkTrailer extends HttpChunk {
    26
    27      /**
    28       * Always returns {@code true}.
    29       */
    30      boolean isLast();
    31
    32      /**
    33       * Returns the trailing header value with the specified header name.
    34       * If there are more than one trailing header value for the specified
    35       * header name, the first value is returned.
    36       *
    37       * @return the header value or {@code null} if there is no such header
    38       */
    39      String getHeader(String name);
    40
    41      /**
    42       * Returns the trailing header values with the specified header name.
    43       *
    44       * @return the {@link List} of header values.  An empty list if there is no
    45       *         such header.
    46       */
    47      List<String> getHeaders(String name);
    48
    49      /**
    50       * Returns the all header names and values that this trailer contains.
    51       *
    52       * @return the {@link List} of the header name-value pairs.  An empty list
    53       *         if there is no header in this trailer.
    54       */
    55      List<Map.Entry<String, String>> getHeaders();
    56
    57      /**
    58       * Returns {@code true} if and only if there is a trailing header with
    59       * the specified header name.
    60       */
    61      boolean containsHeader(String name);
    62
    63      /**
    64       * Returns the {@link Set} of all trailing header names that this trailer
    65       * contains.
    66       */
    67      Set<String> getHeaderNames();
    68
    69      /**
    70       * Adds a new trailing header with the specified name and value.
    71       */
    72      void addHeader(String name, Object value);
    73
    74      /**
    75       * Sets a new trailing header with the specified name and value.
    76       * If there is an existing trailing header with the same name, the existing
    77       * one is removed.
    78       */
    79      void setHeader(String name, Object value);
    80
    81      /**
    82       * Sets a new trailing header with the specified name and values.
    83       * If there is an existing trailing header with the same name, the existing
    84       * one is removed.
    85       */
    86      void setHeader(String name, Iterable<?> values);
    87
    88      /**
    89       * Removes the trailing header with the specified name.
    90       */
    91      void removeHeader(String name);
    92
    93      /**
    94       * Removes all trailing headers from this trailer.
    95       */
    96      void clearHeaders();
    97  }