swift-nio/Sources/NIOHTTP1
George Barnett 73eb597aa3
Don't unconditionally remove the HTTPServerUpgradeHandler (#2303)
Motivation:

The `HTTPServerUpgradeHandler` removes itself from the pipeline after an
upgrade and unbuffers any unconsumed reads. If an upgrade starts but
does not complete successfully then the pipeline may be left in an
unknown state.

If, for example, the failure occurs before the user provided upgrade
handler is run then unbuffered writes may be unwrapped by the wrong
channel handler as the wrong type leading to a crash.

Modifications:

- Only remove the upgrade handler and forward buffered writes if all
  parts of the upgrade complete successfully.
- If part of the upgrade fails then fire an error into the channel
  pipeline without removing the server upgrade handler.
- Remove a few unnecessary `map`s.
- Make `httpEncoder` non-optional since and remove associated dead code
  since it can never be `nil`.

Result:

Upgrade handling is safer.
2022-10-28 07:32:43 -07:00
..
ByteCollectionUtils.swift Clean up dependencies and imports. (#1935) 2021-08-12 13:49:46 +01:00
HTTPDecoder.swift Replace `NIOSendable` with `Sendable` (#2291) 2022-10-13 15:56:27 +01:00
HTTPEncoder.swift Adopt `Sendable` for types in `NIOHTTP1` (#2213) 2022-07-04 00:37:23 -07:00
HTTPHeaderValidator.swift Merge pull request from GHSA-7fj7-39wj-c64f 2022-09-27 13:09:52 +01:00
HTTPHeaders+Validation.swift Merge pull request from GHSA-7fj7-39wj-c64f 2022-09-27 13:09:52 +01:00
HTTPPipelineSetup.swift Merge pull request from GHSA-7fj7-39wj-c64f 2022-09-27 13:09:52 +01:00
HTTPServerPipelineHandler.swift Adopt `Sendable` for types in `NIOHTTP1` (#2213) 2022-07-04 00:37:23 -07:00
HTTPServerProtocolErrorHandler.swift Adopt `Sendable` for types in `NIOHTTP1` (#2213) 2022-07-04 00:37:23 -07:00
HTTPServerUpgradeHandler.swift Don't unconditionally remove the HTTPServerUpgradeHandler (#2303) 2022-10-28 07:32:43 -07:00
HTTPTypes.swift Replace `NIOSendable` with `Sendable` (#2291) 2022-10-13 15:56:27 +01:00
NIOHTTPClientUpgradeHandler.swift Remove `#if compiler(>=5.5)` (#2292) 2022-10-13 07:17:46 -07:00
NIOHTTPObjectAggregator.swift Replace `NIOSendable` with `Sendable` (#2291) 2022-10-13 15:56:27 +01:00