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