当前位置: 首页>>代码示例>>Java>>正文


Java Http2Settings类代码示例

本文整理汇总了Java中io.netty.handler.codec.http2.Http2Settings的典型用法代码示例。如果您正苦于以下问题:Java Http2Settings类的具体用法?Java Http2Settings怎么用?Java Http2Settings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Http2Settings类属于io.netty.handler.codec.http2包,在下文中一共展示了Http2Settings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newHttp2ConnectionHandler

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
private Http2ClientConnectionHandler newHttp2ConnectionHandler(Channel ch) {
    final boolean validateHeaders = false;
    final Http2Connection conn = new DefaultHttp2Connection(false);
    conn.addListener(new Http2GoAwayListener(ch));

    Http2FrameReader reader = new DefaultHttp2FrameReader(validateHeaders);
    Http2FrameWriter writer = new DefaultHttp2FrameWriter();

    Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(conn, writer);
    Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(conn, encoder, reader);

    final Http2Settings http2Settings = http2Settings();

    final Http2ResponseDecoder listener = new Http2ResponseDecoder(conn, ch, encoder);
    final Http2ClientConnectionHandler handler =
            new Http2ClientConnectionHandler(decoder, encoder, http2Settings, listener);
    // Setup post build options
    handler.gracefulShutdownTimeoutMillis(clientFactory.idleTimeoutMillis());

    return handler;
}
 
开发者ID:line,项目名称:armeria,代码行数:22,代码来源:HttpClientPipelineConfigurator.java

示例2: channelRead

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    if (msg instanceof Http2Settings) {
        // Expected
    } else {
        try {
            final String typeInfo;
            if (msg instanceof ByteBuf) {
                typeInfo = msg + " HexDump: " + ByteBufUtil.hexDump((ByteBuf) msg);
            } else {
                typeInfo = String.valueOf(msg);
            }
            throw new IllegalStateException("unexpected message type: " + typeInfo);
        } finally {
            ReferenceCountUtil.release(msg);
        }
    }
}
 
开发者ID:line,项目名称:armeria,代码行数:19,代码来源:HttpSessionHandler.java

示例3: handleHttp2Settings

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
private void handleHttp2Settings(ChannelHandlerContext ctx, Http2Settings h2settings) {
    if (h2settings.isEmpty()) {
        logger.trace("{} HTTP/2 settings: <empty>", ctx.channel());
    } else {
        logger.debug("{} HTTP/2 settings: {}", ctx.channel(), h2settings);
    }

    if (protocol == H1) {
        protocol = H2;
    } else if (protocol == H1C) {
        protocol = H2C;
    }

    final Http2ConnectionHandler handler = ctx.pipeline().get(Http2ConnectionHandler.class);
    if (responseEncoder == null) {
        responseEncoder = new Http2ObjectEncoder(handler.encoder());
    } else if (responseEncoder instanceof Http1ObjectEncoder) {
        responseEncoder.close();
        responseEncoder = new Http2ObjectEncoder(handler.encoder());
    }
}
 
开发者ID:line,项目名称:armeria,代码行数:22,代码来源:HttpServerHandler.java

示例4: newHttp2ConnectionHandler

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
private Http2ConnectionHandler newHttp2ConnectionHandler(ChannelPipeline pipeline) {

        final Http2Connection conn = new DefaultHttp2Connection(true);
        conn.addListener(new Http2GoAwayListener(pipeline.channel()));

        Http2FrameReader reader = new DefaultHttp2FrameReader(true);
        Http2FrameWriter writer = new DefaultHttp2FrameWriter();

        Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(conn, writer);
        Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(conn, encoder, reader);

        final Http2ConnectionHandler handler =
                new Http2ServerConnectionHandler(decoder, encoder, new Http2Settings());

        // Setup post build options
        final Http2RequestDecoder listener =
                new Http2RequestDecoder(config, pipeline.channel(), handler.encoder());

        handler.connection().addListener(listener);
        handler.decoder().frameListener(listener);
        handler.gracefulShutdownTimeoutMillis(config.idleTimeoutMillis());

        return handler;
    }
 
开发者ID:line,项目名称:armeria,代码行数:25,代码来源:HttpServerPipelineConfigurator.java

示例5: updateWindow

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
public void updateWindow() throws Http2Exception {
  if (!autoTuneFlowControlOn) {
    return;
  }
  pingReturn++;
  long elapsedTime = (System.nanoTime() - lastPingTime);
  if (elapsedTime == 0) {
    elapsedTime = 1;
  }
  long bandwidth = (getDataSincePing() * TimeUnit.SECONDS.toNanos(1)) / elapsedTime;
  Http2LocalFlowController fc = decoder().flowController();
  // Calculate new window size by doubling the observed BDP, but cap at max window
  int targetWindow = Math.min(getDataSincePing() * 2, MAX_WINDOW_SIZE);
  setPinging(false);
  int currentWindow = fc.initialWindowSize(connection().connectionStream());
  if (targetWindow > currentWindow && bandwidth > lastBandwidth) {
    lastBandwidth = bandwidth;
    int increase = targetWindow - currentWindow;
    fc.incrementWindowSize(connection().connectionStream(), increase);
    fc.initialWindowSize(targetWindow);
    Http2Settings settings = new Http2Settings();
    settings.initialWindowSize(targetWindow);
    frameWriter().writeSettings(ctx(), settings, ctx().newPromise());
  }

}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:27,代码来源:AbstractNettyHandler.java

示例6: manualSetUp

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected void manualSetUp() throws Exception {
  assertNull("manualSetUp should not run more than once", handler());

  initChannel(new GrpcHttp2ServerHeadersDecoder(GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE));

  // replace the keepAliveManager with spyKeepAliveManager
  spyKeepAliveManager =
      mock(KeepAliveManager.class, delegatesTo(handler().getKeepAliveManagerForTest()));
  handler().setKeepAliveManagerForTest(spyKeepAliveManager);

  // Simulate receipt of the connection preface
  handler().handleProtocolNegotiationCompleted(Attributes.EMPTY);
  channelRead(Http2CodecUtil.connectionPrefaceBuf());
  // Simulate receipt of initial remote settings.
  ByteBuf serializedSettings = serializeSettings(new Http2Settings());
  channelRead(serializedSettings);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:19,代码来源:NettyServerHandlerTest.java

示例7: build

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected Http2TestHandler build(Http2ConnectionDecoder decoder,
        Http2ConnectionEncoder encoder, Http2Settings initialSettings) {
    Http2TestHandler handler = new Http2TestHandler(decoder, encoder, initialSettings);
    frameListener(handler);
    return handler;
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:8,代码来源:Http2TestHandler.java

示例8: channelRead0

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, Http2Settings msg) throws Exception {
    promise.setSuccess();

    // Only care about the first settings message
    ctx.pipeline().remove(this);
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:8,代码来源:Http2SettingsHandler.java

示例9: build

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected HelloWorldHttp2Handler build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder,
                                       Http2Settings initialSettings) {

    HelloWorldHttp2Handler handler = new HelloWorldHttp2Handler(decoder, encoder, initialSettings);
    frameListener(handler);
    return handler;
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:9,代码来源:HelloWorldHttp2HandlerBuilder.java

示例10: messageReceived

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected void messageReceived(ChannelHandlerContext ctx, Http2Settings msg) throws Exception {
    promise.setSuccess();

    // Only care about the first settings message
    ctx.pipeline().remove(this);
}
 
开发者ID:duchien85,项目名称:netty-cookbook,代码行数:8,代码来源:Http2SettingsHandler.java

示例11: frameWriter

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
private Http2FrameWriter frameWriter() {
    // Set initial SETTINGS
    Http2Settings settings = new Http2Settings();
    settings.pushEnabled(false);
    settings.maxConcurrentStreams(100);

    return new Http2OutboundFrameLogger(new CustomHttp2FrameWriter(settings), logger);
}
 
开发者ID:syucream,项目名称:jmeter-http2-plugin,代码行数:9,代码来源:Http2ClientInitializer.java

示例12: writeSettings

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
/**
 *  write customized SETTINGS
 */
@Override
public ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings, ChannelPromise promise) {
    if(this.settings != null) {
        return super.writeSettings(ctx, this.settings, promise);
    } else {
        return super.writeSettings(ctx, settings, promise);
    }
}
 
开发者ID:syucream,项目名称:jmeter-http2-plugin,代码行数:12,代码来源:Http2ClientInitializer.java

示例13: channelRead0

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
    if (msg instanceof Http2Settings) {
        settingsPromise.setSuccess(null);
        return;
    }

    if (msg instanceof FullHttpResponse) {
        FullHttpResponse res = (FullHttpResponse) msg;
        Integer streamId = res.headers().getInt(
                HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text());
        if (streamId == null) {
            responsePromise.tryFailure(new AssertionError("message without stream ID: " + msg));
            return;
        }

        if (streamId == 1) {
            // Response to the upgrade request, which is OK to ignore.
            return;
        }

        if (streamId != 3) {
            responsePromise.tryFailure(new AssertionError("unexpected stream ID: " + msg));
            return;
        }

        responsePromise.setSuccess(res.content().retain());
        return;
    }

    throw new IllegalStateException("unexpected message type: " + msg.getClass().getName());
}
 
开发者ID:line,项目名称:armeria,代码行数:33,代码来源:THttp2Client.java

示例14: Http2ClientConnectionHandler

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
Http2ClientConnectionHandler(
        Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder,
        Http2Settings initialSettings, Http2ResponseDecoder responseDecoder) {

    super(decoder, encoder, initialSettings);
    this.responseDecoder = responseDecoder;
    connection().addListener(responseDecoder);
    decoder().frameListener(responseDecoder);
}
 
开发者ID:line,项目名称:armeria,代码行数:10,代码来源:Http2ClientConnectionHandler.java

示例15: channelRead

import io.netty.handler.codec.http2.Http2Settings; //导入依赖的package包/类
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    isReading = true; // Cleared in channelReadComplete()

    if (msg instanceof Http2Settings) {
        handleHttp2Settings(ctx, (Http2Settings) msg);
    } else {
        handleRequest(ctx, (DecodedHttpRequest) msg);
    }
}
 
开发者ID:line,项目名称:armeria,代码行数:11,代码来源:HttpServerHandler.java


注:本文中的io.netty.handler.codec.http2.Http2Settings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。