Repository: apple/swift-nio
File: Sources/NIOHTTP1/NIOTypedHTTPServerUpgradeHandler.swift (Swift)

Code before:
                        upgradeRequest: requestHeadAndProtocol.0
                    )
                )
            }
            self.upgradeResultPromise.succeed(value)
            context.pipeline.syncOperations.removeHandler(self, promise: nil)

        case .none:
            break
        }
    }

    /// Attempt to upgrade a single protocol.
    ///
    /// Will recurse through `protocolIterator` if upgrade fails.
    private func handleUpgradeForProtocol(
        context: ChannelHandlerContext,
        protocolIterator: Array<String>.Iterator,
        request: HTTPRequestHead,
        allHeaderNames: Set<String>,
        connectionHeader: Set<String>
    )
        -> EventLoopFuture<
            (
                upgrader: any NIOTypedHTTPServerProtocolUpgrader<UpgradeResult>, responseHeaders: HTTPHeaders,
                proto: String
            )?
        >.Isolated
    {
        // We want a local copy of the protocol iterator. We'll pass it to the next invocation of the function.
        var protocolIterator = protocolIterator
        guard let proto = protocolIterator.next() else {
            // We're done! No suitable protocol for upgrade.
            return context.eventLoop.makeSucceededIsolatedFuture(nil)
        }

        guard let upgrader = self.upgraders[proto.lowercased()] else {
            return self.handleUpgradeForProtocol(
                context: context,
                protocolIterator: protocolIterator,
                request: request,
                allHeaderNames: allHeaderNames,
                connectionHeader: connectionHeader
            )
        }

        let requiredHeaders = Set(upgrader.requiredUpgradeHeaders.map { $0.lowercased() })
        guard requiredHeaders.isSubset(of: allHeaderNames) && requiredHeaders.isSubset(of: connectionHeader) else {
            return self.handleUpgradeForProtocol(
                context: context,
                protocolIterator: protocolIterator,

Review comment (suggestion):
Given the weird formatting can we do one param per line?

```suggestion
                upgrader: any NIOTypedHTTPServerProtocolUpgrader<UpgradeResult>, 
                responseHeaders: HTTPHeaders,
                proto: String
```

Code after:
                    )
                )
            }
            self.upgradeResultPromise.succeed(value)
            context.pipeline.syncOperations.removeHandler(self, promise: nil)

        case .none:
            break
        }
    }

    /// Attempt to upgrade a single protocol.
    ///
    /// Will recurse through `protocolIterator` if upgrade fails.
    private func handleUpgradeForProtocol(
        context: ChannelHandlerContext,
        protocolIterator: Array<String>.Iterator,
        request: HTTPRequestHead,
        allHeaderNames: Set<String>,
        connectionHeader: Set<String>
    )
        -> EventLoopFuture<
            (
                upgrader: any NIOTypedHTTPServerProtocolUpgrader<UpgradeResult>,
                responseHeaders: HTTPHeaders,
                proto: String
            )?
        >.Isolated
    {
        // We want a local copy of the protocol iterator. We'll pass it to the next invocation of the function.
        var protocolIterator = protocolIterator
        guard let proto = protocolIterator.next() else {
            // We're done! No suitable protocol for upgrade.
            return context.eventLoop.makeSucceededIsolatedFuture(nil)
        }

        guard let upgrader = self.upgraders[proto.lowercased()] else {
            return self.handleUpgradeForProtocol(
                context: context,
                protocolIterator: protocolIterator,
                request: request,
                allHeaderNames: allHeaderNames,
                connectionHeader: connectionHeader
            )
        }

        let requiredHeaders = Set(upgrader.requiredUpgradeHeaders.map { $0.lowercased() })
        guard requiredHeaders.isSubset(of: allHeaderNames) && requiredHeaders.isSubset(of: connectionHeader) else {
            return self.handleUpgradeForProtocol(
                context: context,
                protocolIterator: protocolIterator,