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.spdy;
17
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Set;
21
22 /**
23 * A SPDY Name/Value Header Block which provides common properties for
24 * {@link SpdySynStreamFrame}, {@link SpdySynReplyFrame}, and
25 * {@link SpdyHeadersFrame}.
26 * @see SpdyHeaders
27 */
28 public interface SpdyHeaderBlock {
29
30 /**
31 * Returns {@code true} if this header block is invalid.
32 * A RST_STREAM frame with code PROTOCOL_ERROR should be sent.
33 */
34 boolean isInvalid();
35
36 /**
37 * Marks this header block as invalid.
38 */
39 void setInvalid();
40
41 /**
42 * Returns the header value with the specified header name. If there is
43 * more than one header value for the specified header name, the first
44 * value is returned.
45 *
46 * @return the header value or {@code null} if there is no such header
47 */
48 String getHeader(String name);
49
50 /**
51 * Returns the header values with the specified header name.
52 *
53 * @return the {@link List} of header values. An empty list if there is no
54 * such header.
55 */
56 List<String> getHeaders(String name);
57
58 /**
59 * Returns all header names and values that this block contains.
60 *
61 * @return the {@link List} of the header name-value pairs. An empty list
62 * if there is no header in this message.
63 */
64 List<Map.Entry<String, String>> getHeaders();
65
66 /**
67 * Returns {@code true} if and only if there is a header with the specified
68 * header name.
69 */
70 boolean containsHeader(String name);
71
72 /**
73 * Returns the {@link Set} of all header names that this block contains.
74 */
75 Set<String> getHeaderNames();
76
77 /**
78 * Adds a new header with the specified name and value.
79 */
80 void addHeader(String name, Object value);
81
82 /**
83 * Sets a new header with the specified name and value. If there is an
84 * existing header with the same name, the existing header is removed.
85 */
86 void setHeader(String name, Object value);
87
88 /**
89 * Sets a new header with the specified name and values. If there is an
90 * existing header with the same name, the existing header is removed.
91 */
92 void setHeader(String name, Iterable<?> values);
93
94 /**
95 * Removes the header with the specified name.
96 */
97 void removeHeader(String name);
98
99 /**
100 * Removes all headers from this block.
101 */
102 void clearHeaders();
103 }