Example usage for io.netty.handler.codec.http2 Http2DataFrame initialFlowControlledBytes

List of usage examples for io.netty.handler.codec.http2 Http2DataFrame initialFlowControlledBytes

Introduction

In this page you can find the example usage for io.netty.handler.codec.http2 Http2DataFrame initialFlowControlledBytes.

Prototype

int initialFlowControlledBytes();

Source Link

Document

Returns the number of bytes that are flow-controlled initially, so even if the #content() is consumed this will not change.

Usage

From source file:example.http2.helloworld.frame.server.HelloWorldHttp2Handler.java

License:Apache License

/**
 * If receive a frame with end-of-stream set, send a pre-canned response.
 *///from www.  j  a v a 2  s .  c  o  m
private static void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception {
    Http2FrameStream stream = data.stream();

    if (data.isEndStream()) {
        sendResponse(ctx, stream, data.content());
    } else {
        // We do not send back the response to the remote-peer, so we need to release it.
        data.release();
    }

    // Update the flowcontroller
    ctx.write(new DefaultHttp2WindowUpdateFrame(data.initialFlowControlledBytes()).stream(stream));
}