Class Http3ConnectUdpHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
This handler intercepts HTTP/3 extended CONNECT requests with
:protocol = connect-udp when the http3ConnectUdpEnabled
configuration flag is set to true. It is inserted into the QUIC
stream pipeline before the regular Http3MockServerHandler
so that CONNECT-UDP requests are handled here and non-CONNECT requests pass
through to the normal mock pipeline.
Relay design:
- The handler recognises an extended CONNECT request by checking
:method = CONNECTand:protocol = connect-udp. - The target authority is parsed from the
:authoritypseudo-header (host:port). - A UDP
NioDatagramChannelis opened and connected to the target address. - The handler responds with
200 OKto indicate the tunnel is established. - Subsequent HTTP/3 DATA frames received on the QUIC stream are forwarded as UDP datagrams to the target. Each DATA frame payload is sent as one UDP datagram (simple 1:1 mapping without capsule framing -- suitable for testing).
- UDP datagrams received from the target are forwarded back to the client as HTTP/3 DATA frames on the same QUIC stream.
- When the QUIC stream is closed (input closed, error, or handler removal), the UDP channel is closed to release resources.
Plain CONNECT requests (without :protocol) are passed through to
the next handler in the pipeline (the mock handler) -- MockServer is not a
TCP forward proxy.
Framing note: a production MASQUE proxy would use the HTTP Datagram / Capsule Protocol (RFC 9297) framing. This implementation uses a simplified 1:1 DATA-frame-to-UDP-datagram mapping which is sufficient for testing and mock-server usage. The Capsule Protocol adds a context ID varint prefix; clients that require it should be adapted accordingly.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) voidhandlerRemoved(io.netty.channel.ChannelHandlerContext ctx) Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded
-
Constructor Details
-
Http3ConnectUdpHandler
public Http3ConnectUdpHandler()
-
-
Method Details
-
channelRead
- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
handlerRemoved
- Specified by:
handlerRemovedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerRemovedin classio.netty.channel.ChannelHandlerAdapter- Throws:
Exception
-
exceptionCaught
- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter
-