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


Java Http2Stream.close方法代码示例

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


在下文中一共展示了Http2Stream.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newHandler

import io.netty.handler.codec.http2.Http2Stream; //导入方法依赖的package包/类
@Override
protected NettyClientHandler newHandler() throws Http2Exception {
  Http2Connection connection = new DefaultHttp2Connection(false);

  // Create and close a stream previous to the nextStreamId.
  Http2Stream stream = connection.local().createStream(streamId - 2, true);
  stream.close();

  final Ticker ticker = new Ticker() {
    @Override
    public long read() {
      return nanoTime;
    }
  };
  Supplier<Stopwatch> stopwatchSupplier = new Supplier<Stopwatch>() {
    @Override
    public Stopwatch get() {
      return Stopwatch.createUnstarted(ticker);
    }
  };
  return NettyClientHandler.newHandler(
      connection,
      frameReader(),
      frameWriter(),
      lifecycleManager,
      mockKeepAliveManager,
      flowControlWindow,
      maxHeaderListSize,
      stopwatchSupplier,
      tooManyPingsRunnable,
      transportTracer);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:33,代码来源:NettyClientHandlerTest.java

示例2: onDataRead

import io.netty.handler.codec.http2.Http2Stream; //导入方法依赖的package包/类
@Override
public int onDataRead(
        ChannelHandlerContext ctx, int streamId, ByteBuf data,
        int padding, boolean endOfStream) throws Http2Exception {

    final DecodedHttpRequest req = requests.get(streamId);
    if (req == null) {
        throw connectionError(PROTOCOL_ERROR, "received a DATA Frame for an unknown stream: %d",
                              streamId);
    }

    final int dataLength = data.readableBytes();
    if (dataLength == 0) {
        // Received an empty DATA frame
        if (endOfStream) {
            req.close();
        }
        return padding;
    }

    req.increaseTransferredBytes(dataLength);

    final long maxContentLength = req.maxRequestLength();
    if (maxContentLength > 0 && req.transferredBytes() > maxContentLength) {
        if (req.isOpen()) {
            req.close(ContentTooLargeException.get());
        }

        if (isWritable(streamId)) {
            writeErrorResponse(ctx, streamId, HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE);
        } else {
            // Cannot write to the stream. Just close it.
            final Http2Stream stream = writer.connection().stream(streamId);
            stream.close();
        }
    } else if (req.isOpen()) {
        try {
            req.write(new ByteBufHttpData(data.retain(), endOfStream));
        } catch (Throwable t) {
            req.close(t);
            throw connectionError(INTERNAL_ERROR, t, "failed to consume a DATA frame");
        }

        if (endOfStream) {
            req.close();
        }
    }

    // All bytes have been processed.
    return dataLength + padding;
}
 
开发者ID:line,项目名称:armeria,代码行数:52,代码来源:Http2RequestDecoder.java


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