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.ChannelFuture;
19  import io.netty.channel.ChannelHandlerContext;
20  import io.netty.channel.ChannelPromise;
21  
22  /**
23   * Interface that defines an object capable of producing HTTP/2 data frames.
24   */
25  public interface Http2DataWriter {
26      /**
27       * Writes a {@code DATA} frame to the remote endpoint. This will result in one or more
28       * frames being written to the context.
29       *
30       * @param ctx the context to use for writing.
31       * @param streamId the stream for which to send the frame.
32       * @param data the payload of the frame. This will be released by this method.
33       * @param padding additional bytes that should be added to obscure the true content size. Must be between 0 and
34       *                256 (inclusive). A 1 byte padding is encoded as just the pad length field with value 0.
35       *                A 256 byte padding is encoded as the pad length field with value 255 and 255 padding bytes
36       *                appended to the end of the frame.
37       * @param endStream indicates if this is the last frame to be sent for the stream.
38       * @param promise the promise for the write.
39       * @return the future for the write.
40       */
41      ChannelFuture writeData(ChannelHandlerContext ctx, int streamId,
42              ByteBuf data, int padding, boolean endStream, ChannelPromise promise);
43  }