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