本文整理汇总了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);
}
示例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;
}