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.buffer.ByteBuf;
18  import io.netty.channel.ChannelHandlerContext;
19  
20  import java.io.Closeable;
21  import java.util.List;
22  
23  /**
24   * Handler for inbound traffic on behalf of {@link Http2ConnectionHandler}. Performs basic protocol
25   * conformance on inbound frames before calling the delegate {@link Http2FrameListener} for
26   * application-specific processing. Note that frames of an unknown type (i.e. HTTP/2 extensions)
27   * will skip all protocol checks and be given directly to the listener for processing.
28   */
29  public interface Http2ConnectionDecoder extends Closeable {
30  
31      /**
32       * Builder for new instances of {@link Http2ConnectionDecoder}.
33       */
34      interface Builder {
35  
36          /**
37           * Sets the {@link Http2Connection} to be used when building the decoder.
38           */
39          Builder connection(Http2Connection connection);
40  
41          /**
42           * Sets the {@link Http2LifecycleManager} to be used when building the decoder.
43           */
44          Builder lifecycleManager(Http2LifecycleManager lifecycleManager);
45  
46          /**
47           * Gets the {@link Http2LifecycleManager} to be used when building the decoder.
48           */
49          Http2LifecycleManager lifecycleManager();
50  
51          /**
52           * Sets the {@link Http2FrameReader} to be used when building the decoder.
53           */
54          Builder frameReader(Http2FrameReader frameReader);
55  
56          /**
57           * Sets the {@link Http2FrameListener} to be used when building the decoder.
58           */
59          Builder listener(Http2FrameListener listener);
60  
61          /**
62           * Sets the {@link Http2ConnectionEncoder} used when building the decoder.
63           */
64          Builder encoder(Http2ConnectionEncoder encoder);
65  
66          /**
67           * Creates a new decoder instance.
68           */
69          Http2ConnectionDecoder build();
70      }
71  
72      /**
73       * Provides direct access to the underlying connection.
74       */
75      Http2Connection connection();
76  
77      /**
78       * Provides the local flow controller for managing inbound traffic.
79       */
80      Http2LocalFlowController flowController();
81  
82      /**
83       * Provides direct access to the underlying frame listener.
84       */
85      Http2FrameListener listener();
86  
87      /**
88       * Called by the {@link Http2ConnectionHandler} to decode the next frame from the input buffer.
89       */
90      void decodeFrame(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Http2Exception;
91  
92      /**
93       * Gets the local settings for this endpoint of the HTTP/2 connection.
94       */
95      Http2Settings localSettings();
96  
97      /**
98       * Sets the local settings for this endpoint of the HTTP/2 connection.
99       */
100     void localSettings(Http2Settings settings) throws Http2Exception;
101 
102     /**
103      * Indicates whether or not the first initial {@code SETTINGS} frame was received from the remote endpoint.
104      */
105     boolean prefaceReceived();
106 
107     @Override
108     void close();
109 }