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    * https://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.netty5.handler.codec.http2;
16  
17  import io.netty5.buffer.api.Buffer;
18  import io.netty5.channel.ChannelHandlerContext;
19  import io.netty5.util.internal.UnstableApi;
20  
21  import java.io.Closeable;
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  @UnstableApi
30  public interface Http2ConnectionDecoder extends Closeable {
31  
32      /**
33       * Sets the lifecycle manager. Must be called as part of initialization before the decoder is used.
34       */
35      void lifecycleManager(Http2LifecycleManager lifecycleManager);
36  
37      /**
38       * Provides direct access to the underlying connection.
39       */
40      Http2Connection connection();
41  
42      /**
43       * Provides the local flow controller for managing inbound traffic.
44       */
45      Http2LocalFlowController flowController();
46  
47      /**
48       * Set the {@link Http2FrameListener} which will be notified when frames are decoded.
49       * <p>
50       * This <strong>must</strong> be set before frames are decoded.
51       */
52      void frameListener(Http2FrameListener listener);
53  
54      /**
55       * Get the {@link Http2FrameListener} which will be notified when frames are decoded.
56       */
57      Http2FrameListener frameListener();
58  
59      /**
60       * Called by the {@link Http2ConnectionHandler} to decode the next frame from the input buffer.
61       */
62      void decodeFrame(ChannelHandlerContext ctx, Buffer in) throws Http2Exception;
63  
64      /**
65       * Gets the local settings for this endpoint of the HTTP/2 connection.
66       */
67      Http2Settings localSettings();
68  
69      /**
70       * Indicates whether or not the first initial {@code SETTINGS} frame was received from the remote endpoint.
71       */
72      boolean prefaceReceived();
73  
74      @Override
75      void close();
76  }