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

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

Introduction

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

Prototype

boolean isEndStream();

Source Link

Document

Returns true if the END_STREAM flag ist set.

Usage

From source file:com.flysoloing.learning.network.netty.http2.helloworld.multiplex.server.HelloWorldHttp2Handler.java

License:Apache License

/**
 * If receive a frame with end-of-stream set, send a pre-canned response.
 *//* w  w  w.j  a  v  a 2 s.com*/
public void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception {
    if (data.isEndStream()) {
        sendResponse(ctx, data.content().retain());
    }
}

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  w  w  w  . j  av 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));
}

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

License:Apache License

/**
 * If receive a frame with end-of-stream set, send a pre-canned response.
 */// w  w w .j av  a  2  s .c om
private static void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception {
    if (data.isEndStream()) {
        sendResponse(ctx, data.content());
    } else {
        // We do not send back the response to the remote-peer, so we need to release it.
        data.release();
    }
}

From source file:me.netty.http.handler.HelloWorldHttp2Handler.java

License:Apache License

/**
 * If receive a frame with end-of-stream set, send a pre-canned response.
 *//*from  ww  w . j ava  2s .c o m*/
public void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception {
    if (data.isEndStream()) {
        sendResponse(ctx, data.content().retain());
    }

    logger.debug("get body stream id is : " + data.streamId());
}

From source file:org.glassfish.jersey.netty.httpserver.JerseyHttp2ServerHandler.java

License:Open Source License

/**
 * Process incoming data.//from  w  w w . j  av  a2  s. co m
 */
private void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception {
    isList.add(new ByteBufInputStream(data.content()));
    if (data.isEndStream()) {
        isList.add(NettyInputStream.END_OF_INPUT);
    }
}

From source file:org.wso2.carbon.inbound.endpoint.protocol.http2.Http2RequestReader.java

License:Open Source License

/**
 * Handles data frames/*w  w w.jav  a2  s. c  o m*/
 *
 * @param frame
 */
public void onDataRead(Http2DataFrame frame) {
    int streamId = frame.streamId();
    Http2SourceRequest request = null;

    if (!requestMap.containsKey(streamId)) {
        return;
    }

    request = requestMap.get(streamId);

    request.setChannel(chContext);

    Pipe pipe = request.getPipe();
    if (pipe == null) {
        pipe = new Pipe(new HTTP2Producer(), sourceConfiguration.getBufferFactory().getBuffer(), "source",
                sourceConfiguration);
        request.setPipe(pipe);
    }
    try {
        pipe.produce(new HTTP2Decoder(frame));
    } catch (IOException e) {
        log.error(e);
    }
    if (!request.isProcessedReq()) {
        try {
            messageHandler.processRequest(request);
            request.setProcessedReq(true);
        } catch (AxisFault axisFault) {
            log.error(axisFault);
        }
    }
    if (frame.isEndStream())
        requestMap.remove(request.getStreamID());

}

From source file:org.wso2.esb.integration.common.utils.clients.http2client.Http2Response.java

License:Open Source License

public void setDataFrame(Http2DataFrame data) {
    setData(data);//from  w w w  .j  a  v a2  s.c om
    expectResponseBody = true;
    if (data.isEndStream()) {
        endOfStream = true;
    }
}

From source file:org.wso2.esb.integration.common.utils.servers.http2.Http2Handler.java

License:Open Source License

public void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception {
    if (data.isEndStream()) {
        ByteBuf content = ctx.alloc().buffer();
        content.writeBytes(DATA_RESPONSE.duplicate());
        Http2Headers headers = new DefaultHttp2Headers().status(OK.codeAsText());
        headers.add(HttpHeaderNames.CONTENT_TYPE, "text/xml");
        ctx.write(new DefaultHttp2HeadersFrame(headers));
        ctx.writeAndFlush(new DefaultHttp2DataFrame(content, true));
    }/*from   w  w w. j  av a2 s .  com*/
}