Package org.mockserver.netty.unification
Class Http2GoAwayEmitter
java.lang.Object
org.mockserver.netty.unification.Http2GoAwayEmitter
Emits an HTTP/2
GOAWAY frame on the connection carrying ctx so the client is told
to stop opening new streams and drain — the graceful "this connection is going away" signal a
server sends before a shutdown / preemption. In-flight streams are allowed to complete; GOAWAY
does not reset them.
GOAWAY is a connection-level frame, so it is always written on the connection channel's
pipeline where the Http2ConnectionHandler lives, regardless of which channel emit
was called from:
- On the connection-level (default) HTTP/2 pipeline the handler is on
ctx's own pipeline (resolved with the same lookup pattern asHttpErrorActionHandler.resetHttp2Stream—ctx.pipeline().context(Http2ConnectionHandler.class)), so it works whether called from a child handler or the connection handler's own context. - On the multiplex pipeline (per-stream child channels, used for gRPC bidi streaming)
the request handlers run on a stream child channel whose pipeline has no
Http2ConnectionHandler— theHttp2FrameCodec(whichextends Http2ConnectionHandler) lives on the parent connection channel. When the local pipeline has no connection handler,emitwalks up toctx.channel().parent().pipeline()and writes the GOAWAY there.
HTTP/1.1 has no GOAWAY concept and no Http2ConnectionHandler on any pipeline, so
emit returns false and callers degrade to Connection: close + 503 instead.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanemit(io.netty.channel.ChannelHandlerContext ctx, long lastStreamId, long errorCode) Emit a GOAWAY on the connection carryingctx, whetherctxis on a connection-level HTTP/2 pipeline or a multiplex stream child channel.
-
Method Details
-
emit
public static boolean emit(io.netty.channel.ChannelHandlerContext ctx, long lastStreamId, long errorCode) Emit a GOAWAY on the connection carryingctx, whetherctxis on a connection-level HTTP/2 pipeline or a multiplex stream child channel.- Parameters:
ctx- a context on the HTTP/2 channel's pipeline — either the connection channel or a per-stream child channellastStreamId- thelastStreamIdto advertise; when negative the connection handler's current last-stream-id is used (passing the max stream id so the handler clamps to the connection's actual last-processed stream)errorCode- the HTTP/2 error code (0 = NO_ERROR, the graceful-shutdown code)- Returns:
trueif a GOAWAY was written (an HTTP/2 connection handler was found on this pipeline or the parent connection channel's pipeline),falseotherwise (e.g. HTTP/1.1, or no HTTP/2 connection handler anywhere)
-