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  import io.netty.util.internal.UnstableApi;
20  
21  import java.io.Closeable;
22  import java.util.List;
23  
24  /**
25   * Handler for inbound traffic on behalf of {@link Http2ConnectionHandler}. Performs basic protocol
26   * conformance on inbound frames before calling the delegate {@link Http2FrameListener} for
27   * application-specific processing. Note that frames of an unknown type (i.e. HTTP/2 extensions)
28   * will skip all protocol checks and be given directly to the listener for processing.
29   */
30  @UnstableApi
31  public interface Http2ConnectionDecoder extends Closeable {
32  
33      /**
34       * Sets the lifecycle manager. Must be called as part of initialization before the decoder is used.
35       */
36      void lifecycleManager(Http2LifecycleManager lifecycleManager);
37  
38      /**
39       * Provides direct access to the underlying connection.
40       */
41      Http2Connection connection();
42  
43      /**
44       * Provides the local flow controller for managing inbound traffic.
45       */
46      Http2LocalFlowController flowController();
47  
48      /**
49       * Set the {@link Http2FrameListener} which will be notified when frames are decoded.
50       * <p>
51       * This <strong>must</strong> be set before frames are decoded.
52       */
53      void frameListener(Http2FrameListener listener);
54  
55      /**
56       * Get the {@link Http2FrameListener} which will be notified when frames are decoded.
57       */
58      Http2FrameListener frameListener();
59  
60      /**
61       * Called by the {@link Http2ConnectionHandler} to decode the next frame from the input buffer.
62       */
63      void decodeFrame(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Http2Exception;
64  
65      /**
66       * Gets the local settings for this endpoint of the HTTP/2 connection.
67       */
68      Http2Settings localSettings();
69  
70      /**
71       * Indicates whether or not the first initial {@code SETTINGS} frame was received from the remote endpoint.
72       */
73      boolean prefaceReceived();
74  
75      @Override
76      void close();
77  }