ChannelPipeline

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

    Declaration

    Swift

    @available(*, deprecated, message: "Please use configureHTTPServerPipeline")
    func addHTTPServerHandlers(first: Bool = false) -> EventLoopFuture<Void>

    Parameters

    first

    Whether to add the HTTP server at the head of the channel pipeline, or at the tail.

    Return Value

    An EventLoopFuture that will fire when the pipeline is configured.

  • Configure a ChannelPipeline for use as a HTTP client.

    Declaration

    Swift

    func addHTTPClientHandlers(first: Bool = false, leftOverBytesStrategy: RemoveAfterUpgradeStrategy = .dropBytes) -> EventLoopFuture<Void>

    Parameters

    first

    Whether to add the HTTP client at the head of the channel pipeline, or at the tail.

    Return Value

    An EventLoopFuture that will fire when the pipeline is configured.

  • Configure a ChannelPipeline for use as a HTTP server that can perform a HTTP upgrade to a non-HTTP protocol: that is, after upgrade the channel pipeline must have none of the handlers added by this function in it.

    Declaration

    Swift

    @available(*, deprecated, message: "Please use configureHTTPServerPipeline")
    func addHTTPServerHandlersWithUpgrader(first: Bool = false,
                                           upgraders: [HTTPProtocolUpgrader],
                                           _ upgradeCompletionHandler: @escaping (ChannelHandlerContext) -> Void) -> EventLoopFuture<Void>

    Parameters

    first

    Whether to add the HTTP server at the head of the channel pipeline, or at the tail.

    upgraders

    The HTTP protocol upgraders to offer.

    upgradeCompletionHandler

    A block that will be fired when the HTTP upgrade is complete.

    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

    func configureHTTPServerPipeline(first: Bool = false,
                                     withPipeliningAssistance pipelining: Bool = true,
                                     withServerUpgrade upgrade: HTTPUpgradeConfiguration? = nil,
                                     withErrorHandling errorHandling: Bool = false) -> EventLoopFuture<Void>

    Parameters

    first

    Whether to add the HTTP server at the head of the channel pipeline, or at the tail.

    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 HTTPProtocolUpgrader 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 false for backward-compatibility reasons.

    Return Value

    An EventLoopFuture that will fire when the pipeline is configured.