1 /*
2 * Copyright 2009 Red Hat, Inc.
3 *
4 * Red Hat licenses this file to you under the Apache License, version 2.0
5 * (the "License"); you may not use this file except in compliance with the
6 * 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.http2;
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 * @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
26 * @author <a href="http://gleamynode.net/">Trustin Lee</a>
27 * @version $Rev: 619 $, $Date: 2010-11-11 20:30:06 +0100 (jeu., 11 nov. 2010) $
28 */
29 public interface HttpChunkTrailer extends HttpChunk {
30
31 /**
32 * Always returns {@code true}.
33 */
34 boolean isLast();
35
36 /**
37 * Returns the trailing header value with the specified header name.
38 * If there are more than one trailing header value for the specified
39 * header name, the first value is returned.
40 *
41 * @return the header value or {@code null} if there is no such header
42 *
43 */
44 String getHeader(String name);
45
46 /**
47 * Returns the trailing header values with the specified header name.
48 *
49 * @return the {@link List} of header values. An empty list if there is no
50 * such header.
51 */
52 List<String> getHeaders(String name);
53
54 /**
55 * Returns the all header names and values that this trailer contains.
56 *
57 * @return the {@link List} of the header name-value pairs. An empty list
58 * if there is no header in this trailer.
59 */
60 List<Map.Entry<String, String>> getHeaders();
61
62 /**
63 * Returns {@code true} if and only if there is a trailing header with
64 * the specified header name.
65 */
66 boolean containsHeader(String name);
67
68 /**
69 * Returns the {@link Set} of all trailing header names that this trailer
70 * contains.
71 */
72 Set<String> getHeaderNames();
73
74 /**
75 * Adds a new trailing header with the specified name and value.
76 */
77 void addHeader(String name, Object value);
78
79 /**
80 * Sets a new trailing header with the specified name and value.
81 * If there is an existing trailing header with the same name, the existing
82 * one is removed.
83 */
84 void setHeader(String name, Object value);
85
86 /**
87 * Sets a new trailing header with the specified name and values.
88 * If there is an existing trailing header with the same name, the existing
89 * one is removed.
90 */
91 void setHeader(String name, Iterable<?> values);
92
93 /**
94 * Removes the trailing header with the specified name.
95 */
96 void removeHeader(String name);
97
98 /**
99 * Removes all trailing headers from this trailer.
100 */
101 void clearHeaders();
102 }