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