configureHTTP2SecureUpgrade(h2ChannelConfigurator:http1ChannelConfigurator:)
Configures a channel to perform an HTTP/2 secure upgrade.
func configureHTTP2SecureUpgrade(h2ChannelConfigurator: @escaping NIOChannelInitializer, http1ChannelConfigurator: @escaping NIOChannelInitializer) -> EventLoopFuture<Void>
Parameters
- h2ChannelConfigurator
A callback that will be invoked if HTTP/2 has been negotiated, and that should configure the channel for HTTP/2 use. Must return a future that completes when the channel has been fully mutated.
- http1ChannelConfigurator
A callback that will be invoked if HTTP/1.1 has been explicitly negotiated, or if no protocol was negotiated. Must return a future that completes when the channel has been fully mutated.
Returns
An EventLoopFuture<Void>
that completes when the channel is ready to negotiate.
HTTP/2 secure upgrade uses the Application Layer Protocol Negotiation TLS extension to negotiate the inner protocol as part of the TLS handshake. For this reason, until the TLS handshake is complete, the ultimate configuration of the channel pipeline cannot be known.
This function configures the channel with a pair of callbacks that will handle the result of the negotiation. It explicitly does not configure a TLS handler to actually attempt to negotiate ALPN. The supported ALPN protocols are provided in NIOHTTP2SupportedALPNProtocols
: please ensure that the TLS handler you are using for your pipeline is appropriately configured to perform this protocol negotiation.
If negotiation results in an unexpected protocol, the pipeline will close the connection and no callback will fire.
This configuration is acceptable for use on both client and server channel pipelines.