View Javadoc
1   /*
2    * Copyright 2013 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 io.netty.handler.codec.spdy;
17  
18  import io.netty.handler.codec.Headers;
19  import io.netty.util.AsciiString;
20  
21  import java.util.Iterator;
22  import java.util.List;
23  import java.util.Map.Entry;
24  
25  /**
26   * Provides the constants for the standard SPDY HTTP header names and commonly
27   * used utility methods that access a {@link SpdyHeadersFrame}.
28   */
29  public interface SpdyHeaders extends Headers<CharSequence, CharSequence, SpdyHeaders> {
30  
31      /**
32       * SPDY HTTP header names
33       */
34      final class HttpNames {
35          /**
36           * {@code ":host"}
37           */
38          public static final AsciiString HOST = AsciiString.cached(":host");
39          /**
40           * {@code ":method"}
41           */
42          public static final AsciiString METHOD = AsciiString.cached(":method");
43          /**
44           * {@code ":path"}
45           */
46          public static final AsciiString PATH = AsciiString.cached(":path");
47          /**
48           * {@code ":scheme"}
49           */
50          public static final AsciiString SCHEME = AsciiString.cached(":scheme");
51          /**
52           * {@code ":status"}
53           */
54          public static final AsciiString STATUS = AsciiString.cached(":status");
55          /**
56           * {@code ":version"}
57           */
58          public static final AsciiString VERSION = AsciiString.cached(":version");
59  
60          private HttpNames() { }
61      }
62  
63      /**
64       * {@link Headers#get(Object)} and convert the result to a {@link String}.
65       * @param name the name of the header to retrieve
66       * @return the first header value if the header is found. {@code null} if there's no such header.
67       */
68      String getAsString(CharSequence name);
69  
70      /**
71       * {@link Headers#getAll(Object)} and convert each element of {@link List} to a {@link String}.
72       * @param name the name of the header to retrieve
73       * @return a {@link List} of header values or an empty {@link List} if no values are found.
74       */
75      List<String> getAllAsString(CharSequence name);
76  
77      /**
78       * {@link #iterator()} that converts each {@link Entry}'s key and value to a {@link String}.
79       */
80      Iterator<Entry<String, String>> iteratorAsString();
81  
82      /**
83       * Returns {@code true} if a header with the {@code name} and {@code value} exists, {@code false} otherwise.
84       * <p>
85       * If {@code ignoreCase} is {@code true} then a case insensitive compare is done on the value.
86       * @param name the name of the header to find
87       * @param value the value of the header to find
88       * @param ignoreCase {@code true} then a case insensitive compare is run to compare values.
89       * otherwise a case sensitive compare is run to compare values.
90       */
91      boolean contains(CharSequence name, CharSequence value, boolean ignoreCase);
92  }