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