查看本类的 API文档回源码主页即时通讯网 - 即时通讯开发者社区!
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  
16  package io.netty.handler.codec.http2;
17  
18  import io.netty.buffer.ByteBuf;
19  import io.netty.channel.ChannelHandlerContext;
20  import io.netty.util.internal.UnstableApi;
21  
22  import java.io.Closeable;
23  
24  /**
25   * Reads HTTP/2 frames from an input {@link ByteBuf} and notifies the specified
26   * {@link Http2FrameListener} when frames are complete.
27   */
28  @UnstableApi
29  public interface Http2FrameReader extends Closeable {
30      /**
31       * Configuration specific to {@link Http2FrameReader}
32       */
33      interface Configuration {
34          /**
35           * Get the {@link Http2HeadersDecoder.Configuration} for this {@link Http2FrameReader}
36           */
37          Http2HeadersDecoder.Configuration headersConfiguration();
38  
39          /**
40           * Get the {@link Http2FrameSizePolicy} for this {@link Http2FrameReader}
41           */
42          Http2FrameSizePolicy frameSizePolicy();
43      }
44  
45      /**
46       * Attempts to read the next frame from the input buffer. If enough data is available to fully
47       * read the frame, notifies the listener of the read frame.
48       */
49      void readFrame(ChannelHandlerContext ctx, ByteBuf input, Http2FrameListener listener)
50              throws Http2Exception;
51  
52      /**
53       * Get the configuration related elements for this {@link Http2FrameReader}
54       */
55      Configuration configuration();
56  
57      /**
58       * Closes this reader and frees any allocated resources.
59       */
60      @Override
61      void close();
62  }