ChannelPipeline

final class ChannelPipeline : ChannelInvoker
  • Configure a ChannelPipeline for use as a HTTP client.

    Declaration

    Swift

    public func addHTTPClientHandlers(position: Position = .last,
                                      leftOverBytesStrategy: RemoveAfterUpgradeStrategy = .dropBytes) -> EventLoopFuture<Void>

    Parameters

    position

    The position in the ChannelPipeline where to add the HTTP client handlers. Defaults to .last.

    Return Value

    An EventLoopFuture that will fire when the pipeline is configured.

  • Configure a ChannelPipeline for use as a HTTP server.

    This function knows how to set up all first-party HTTP channel handlers appropriately for server use. It supports the following features:

    1. Providing assistance handling clients that pipeline HTTP requests, using the HTTPServerPipelineHandler.
    2. Supporting HTTP upgrade, using the HTTPServerUpgradeHandler.

    This method will likely be extended in future with more support for other first-party features.

    Declaration

    Swift

    public func configureHTTPServerPipeline(position: ChannelPipeline.Position = .last,
                                            withPipeliningAssistance pipelining: Bool = true,
                                            withServerUpgrade upgrade: HTTPUpgradeConfiguration? = nil,
                                            withErrorHandling errorHandling: Bool = true) -> EventLoopFuture<Void>

    Parameters

    position

    Where in the pipeline to add the HTTP server handlers, defaults to .last.

    pipelining

    Whether to provide assistance handling HTTP clients that pipeline their requests. Defaults to true. If false, users will need to handle clients that pipeline themselves.

    upgrade

    Whether to add a HTTPServerUpgradeHandler to the pipeline, configured for HTTP upgrade. Defaults to nil, which will not add the handler to the pipeline. If provided should be a tuple of an array of HTTPServerProtocolUpgrader and the upgrade completion handler. See the documentation on HTTPServerUpgradeHandler for more details.

    errorHandling

    Whether to provide assistance handling protocol errors (e.g. failure to parse the HTTP request) by sending 400 errors. Defaults to true.

    Return Value

    An EventLoopFuture that will fire when the pipeline is configured.