Class AltSvcHeaderHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.mockserver.netty.unification.AltSvcHeaderHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

@Sharable public class AltSvcHeaderHandler extends io.netty.channel.ChannelDuplexHandler
Outbound handler that adds an Alt-Svc header to responses served over the TCP (HTTP/1.1 and HTTP/2) paths when HTTP/3 is enabled.

The header advertises the HTTP/3 endpoint so HTTP/3-capable clients can auto-upgrade to QUIC on subsequent requests while falling back to HTTP/2 or HTTP/1.1 if QUIC is unavailable (RFC 7838).

The handler does NOT overwrite an alt-svc header that was explicitly set by a user expectation.

This handler is ChannelHandler.Sharable because it keeps no per-channel mutable state — the Alt-Svc header value is computed once at construction time and is immutable.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Constructor Summary

    Constructors
    Constructor
    Description
    AltSvcHeaderHandler(int http3Port, long maxAgeSeconds)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)
     

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, flush, read

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Constructor Details

    • AltSvcHeaderHandler

      public AltSvcHeaderHandler(int http3Port, long maxAgeSeconds)
      Parameters:
      http3Port - the UDP port on which the HTTP/3 (QUIC) server is listening
      maxAgeSeconds - the ma (max-age) parameter in seconds
  • Method Details

    • write

      public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception
      Specified by:
      write in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      write in class io.netty.channel.ChannelDuplexHandler
      Throws:
      Exception