View Javadoc
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License, version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * 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 distributed under the License
11   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing permissions and limitations under
13   * the License.
14   */
15  package io.netty.handler.codec.http2;
16  
17  import io.netty.handler.codec.AsciiString;
18  import io.netty.handler.codec.BinaryHeaders;
19  import io.netty.handler.codec.DefaultBinaryHeaders;
20  
21  public class DefaultHttp2Headers extends DefaultBinaryHeaders implements Http2Headers {
22  
23      /**
24       * Creates an instance that will convert all header names to lowercase.
25       */
26      public DefaultHttp2Headers() {
27          this(true);
28      }
29  
30      /**
31       * Creates an instance that can be configured to either do header field name conversion to
32       * lowercase, or not do any conversion at all.
33       * <p>
34       *
35       * <strong>Note</strong> that setting {@code forceKeyToLower} to {@code false} can violate the
36       * <a href="https://tools.ietf.org/html/draft-ietf-httpbis-http2-16#section-8.1.2">HTTP/2 specification</a>
37       * which specifies that a request or response containing an uppercase header field MUST be treated
38       * as malformed. Only set {@code forceKeyToLower} to {@code false} if you are explicitly using lowercase
39       * header field names and want to avoid the conversion to lowercase.
40       *
41       * @param forceKeyToLower if @{code false} no header name conversion will be performed
42       */
43      public DefaultHttp2Headers(boolean forceKeyToLower) {
44          super(forceKeyToLower);
45      }
46  
47      @Override
48      public Http2Headers add(AsciiString name, AsciiString value) {
49          super.add(name, value);
50          return this;
51      }
52  
53      @Override
54      public Http2Headers add(AsciiString name, Iterable<? extends AsciiString> values) {
55          super.add(name, values);
56          return this;
57      }
58  
59      @Override
60      public Http2Headers add(AsciiString name, AsciiString... values) {
61          super.add(name, values);
62          return this;
63      }
64  
65      @Override
66      public Http2Headers addObject(AsciiString name, Object value) {
67          super.addObject(name, value);
68          return this;
69      }
70  
71      @Override
72      public Http2Headers addObject(AsciiString name, Iterable<?> values) {
73          super.addObject(name, values);
74          return this;
75      }
76  
77      @Override
78      public Http2Headers addObject(AsciiString name, Object... values) {
79          super.addObject(name, values);
80          return this;
81      }
82  
83      @Override
84      public Http2Headers addBoolean(AsciiString name, boolean value) {
85          super.addBoolean(name, value);
86          return this;
87      }
88  
89      @Override
90      public Http2Headers addChar(AsciiString name, char value) {
91          super.addChar(name, value);
92          return this;
93      }
94  
95      @Override
96      public Http2Headers addByte(AsciiString name, byte value) {
97          super.addByte(name, value);
98          return this;
99      }
100 
101     @Override
102     public Http2Headers addShort(AsciiString name, short value) {
103         super.addShort(name, value);
104         return this;
105     }
106 
107     @Override
108     public Http2Headers addInt(AsciiString name, int value) {
109         super.addInt(name, value);
110         return this;
111     }
112 
113     @Override
114     public Http2Headers addLong(AsciiString name, long value) {
115         super.addLong(name, value);
116         return this;
117     }
118 
119     @Override
120     public Http2Headers addFloat(AsciiString name, float value) {
121         super.addFloat(name, value);
122         return this;
123     }
124 
125     @Override
126     public Http2Headers addDouble(AsciiString name, double value) {
127         super.addDouble(name, value);
128         return this;
129     }
130 
131     @Override
132     public Http2Headers addTimeMillis(AsciiString name, long value) {
133         super.addTimeMillis(name, value);
134         return this;
135     }
136 
137     @Override
138     public Http2Headers add(BinaryHeaders headers) {
139         super.add(headers);
140         return this;
141     }
142 
143     @Override
144     public Http2Headers set(AsciiString name, AsciiString value) {
145         super.set(name, value);
146         return this;
147     }
148 
149     @Override
150     public Http2Headers set(AsciiString name, Iterable<? extends AsciiString> values) {
151         super.set(name, values);
152         return this;
153     }
154 
155     @Override
156     public Http2Headers set(AsciiString name, AsciiString... values) {
157         super.set(name, values);
158         return this;
159     }
160 
161     @Override
162     public Http2Headers setObject(AsciiString name, Object value) {
163         super.setObject(name, value);
164         return this;
165     }
166 
167     @Override
168     public Http2Headers setObject(AsciiString name, Iterable<?> values) {
169         super.setObject(name, values);
170         return this;
171     }
172 
173     @Override
174     public Http2Headers setObject(AsciiString name, Object... values) {
175         super.setObject(name, values);
176         return this;
177     }
178 
179     @Override
180     public Http2Headers setBoolean(AsciiString name, boolean value) {
181         super.setBoolean(name, value);
182         return this;
183     }
184 
185     @Override
186     public Http2Headers setChar(AsciiString name, char value) {
187         super.setChar(name, value);
188         return this;
189     }
190 
191     @Override
192     public Http2Headers setByte(AsciiString name, byte value) {
193         super.setByte(name, value);
194         return this;
195     }
196 
197     @Override
198     public Http2Headers setShort(AsciiString name, short value) {
199         super.setShort(name, value);
200         return this;
201     }
202 
203     @Override
204     public Http2Headers setInt(AsciiString name, int value) {
205         super.setInt(name, value);
206         return this;
207     }
208 
209     @Override
210     public Http2Headers setLong(AsciiString name, long value) {
211         super.setLong(name, value);
212         return this;
213     }
214 
215     @Override
216     public Http2Headers setFloat(AsciiString name, float value) {
217         super.setFloat(name, value);
218         return this;
219     }
220 
221     @Override
222     public Http2Headers setDouble(AsciiString name, double value) {
223         super.setDouble(name, value);
224         return this;
225     }
226 
227     @Override
228     public Http2Headers setTimeMillis(AsciiString name, long value) {
229         super.setTimeMillis(name, value);
230         return this;
231     }
232 
233     @Override
234     public Http2Headers set(BinaryHeaders headers) {
235         super.set(headers);
236         return this;
237     }
238 
239     @Override
240     public Http2Headers setAll(BinaryHeaders headers) {
241         super.setAll(headers);
242         return this;
243     }
244 
245     @Override
246     public Http2Headers clear() {
247         super.clear();
248         return this;
249     }
250 
251     @Override
252     public Http2Headers method(AsciiString value) {
253         set(PseudoHeaderName.METHOD.value(), value);
254         return this;
255     }
256 
257     @Override
258     public Http2Headers scheme(AsciiString value) {
259         set(PseudoHeaderName.SCHEME.value(), value);
260         return this;
261     }
262 
263     @Override
264     public Http2Headers authority(AsciiString value) {
265         set(PseudoHeaderName.AUTHORITY.value(), value);
266         return this;
267     }
268 
269     @Override
270     public Http2Headers path(AsciiString value) {
271         set(PseudoHeaderName.PATH.value(), value);
272         return this;
273     }
274 
275     @Override
276     public Http2Headers status(AsciiString value) {
277         set(PseudoHeaderName.STATUS.value(), value);
278         return this;
279     }
280 
281     @Override
282     public AsciiString method() {
283         return get(PseudoHeaderName.METHOD.value());
284     }
285 
286     @Override
287     public AsciiString scheme() {
288         return get(PseudoHeaderName.SCHEME.value());
289     }
290 
291     @Override
292     public AsciiString authority() {
293         return get(PseudoHeaderName.AUTHORITY.value());
294     }
295 
296     @Override
297     public AsciiString path() {
298         return get(PseudoHeaderName.PATH.value());
299     }
300 
301     @Override
302     public AsciiString status() {
303         return get(PseudoHeaderName.STATUS.value());
304     }
305 }