configureAsyncHTTP2Pipeline(mode:streamDelegate:configuration:streamInitializer:)

Configures a ChannelPipeline to speak HTTP/2 and sets up mapping functions so that it may be interacted with from concurrent code.

HTTP2PipelineHelpers.swift:582
iOS
13.0+
macOS
10.15+
tvOS
13.0+
watchOS
6.0+
func configureAsyncHTTP2Pipeline<Output>(mode: NIOHTTP2Handler.ParserMode, streamDelegate: NIOHTTP2StreamDelegate?, configuration: NIOHTTP2Handler.Configuration = NIOHTTP2Handler.Configuration(), streamInitializer: @escaping NIOChannelInitializerWithOutput<Output>) -> EventLoopFuture<NIOHTTP2Handler.AsyncStreamMultiplexer<Output>> where Output : Sendable

Parameters

mode

The mode this pipeline will operate in, server or client.

streamDelegate

A delegate which is called when streams are created and closed.

configuration

The settings that will be used when establishing the connection and new streams.

streamInitializer

A closure that will be called whenever the remote peer initiates a new stream. The output of this closure is the element type of the returned multiplexer

Returns

An EventLoopFuture containing the AsyncStreamMultiplexer inserted into this pipeline, which can be used to initiate new streams and iterate over inbound HTTP/2 stream channels.

In general this is not entirely useful by itself, as HTTP/2 is a negotiated protocol. This helper does not handle negotiation. Instead, this simply adds the handler required to speak HTTP/2 after negotiation has completed, or when agreed by prior knowledge. Use this function to setup a HTTP/2 pipeline if you wish to use async sequence abstractions over inbound and outbound streams. Using this rather than implementing a similar function yourself allows that pipeline to evolve without breaking your code.