`isValidFieldName` validates a field name with `allSatisfy` over the
tchar set. `allSatisfy` returns `true` for an empty collection, so the
empty field name passes.
The file already states the rule it is implementing. The doc comment at
line 312 quotes:
```
token = 1*tchar
```
The derivation that follows is correct — I expanded `0x21, 0x23...0x27,
0x2a, 0x2b, 0x2d, 0x2e, 0x30...0x39, 0x5e...0x7a, 0x7c, 0x7e` byte by
byte against tchar minus `A-Z` and every one of the four rewriting steps
in lines 315-341 holds, including the `%x5E-60 / %x61-7A` → `%x5E-7A`
collapse. It is the `1*` quantifier that is missing: the code implements
`*tchar`.
### Scope
All three block types accept an empty name today, since they share
`HeaderFieldName.init`:
```
request: empty name -> accepted
response: empty name -> accepted
trailers: empty name -> accepted
```
An empty name serialises as `: value`, and RFC 9113 § 8.2.1 lists field
names as something a recipient is required to validate and treat as
malformed when the generic syntax is violated. This is a conformance gap
in a validator that already does the rest of that section — the
uppercase check, the CR/LF/NUL value check and the connection-specific
header check are all there.
(`":"` alone is already rejected, though as `unknownPseudoHeader` rather
than a name error, since `dropFirst()` leaves an empty base name that
matches no known pseudo-header. That path is unchanged here.)
### The change
An explicit early return, mirroring the shape swift-http-types uses for
the same production in `tokenValidity`:
```swift
if buffer.isEmpty {
return .invalid
}
```
### Tests
Added to `HTTP2FramePayloadToHTTP1CodecCRLFTests.swift`, which already
exercises `validateRequestBlock`, `validateResponseBlock` and
`validateTrailersBlock` directly for the § 8.2.1 value rules. Five
cases: the empty name in each of the three block types, plus `"a b"` and
an ordinary `x-custom-header` to keep the surrounding behaviour pinned.
### Verification
**I could not run `swift test` here**: this machine has Command Line
Tools without XCTest, so the test targets fail at `import XCTest` with
`no such module`. Pre-existing and unrelated — it reproduces on an
unmodified checkout (18 occurrences). **CI should be the authority;
treat my local run as unverified.**
`swift build` succeeds. I linked a throwaway executable against
`NIOHTTP2` to exercise the change directly:
```
PASS request: empty name -> rejected
PASS response: empty name -> rejected
PASS trailers: empty name -> rejected
PASS request: "a b" -> rejected
PASS request: "Host" (uppercase) -> rejected
PASS request: valid name -> accepted
PASS request: pseudo-headers only -> accepted
```
Before the change the first three were accepted.
### Conflicts
No open PR touches `HPACKHeaders+Validation.swift`. #531 and #562 touch
NIOHPACK, and #531 (`+ Fix a bug`) is about `isASCII` in
`HPACKHeader.swift` — no overlap with `isValidFieldName`.
### Motivation
We currently mitigate against receiving an excessive numbers of
RST_STREAM frames, empty DATA frames, or encountering stream errors in a
given time window.
Receiving excessive numbers of PING, SETTINGS, PRIORITY, ALTSVC, or
ORIGIN frames also results in the endpoint performing unnecessary work.
As such, this PR adds these five frames to the current rate-limiting
mechanism.
### Modifications
- Updated `DOSHeuristics` to also rate-limit PING, SETTINGS, PRIORITY,
ALTSVC, and ORIGIN frames.
- Added a new `controlFrameRateLimit` property to
`NIOHTTP2Handler.ConnectionConfiguration`.
- Plumbed the configuration argument to `NIOHTTP2Handler` initializers.
### Result
Mechanism in place to avoid endpoints from being overwhelmed by
excessive PING, SETTINGS, PRIORITY, ALTSVC, or ORIGIN frames.
Motivation:
`nextStreamToSend()` returned `self.flushableStreams.first`, and since `Set.first` always yields the same stable element, under load the buffer kept handing the whole connection window to one stream while the rest starved to near-zero.
Modifiations:
Rotate through the flushable streams instead of always picking the same one. `flushableStreams` stays the source of truth for membership, and alongside it we keep a queue of those streams (`sendQueue`) in the order to serve them. We pop the front to pick the next stream, and append it to the back once it's been served, so every flushable stream gets a turn per sweep and none can be starved. Both the pop and the append are O(1). Removing a stream from the middle of the queue would be O(n), so we avoid this. A stream that stops being flushable is left as a stale entry and simply skipped when it reaches the front (lazy deletion), with a `queuedStreams` set to stop us ever enqueuing a duplicate.
Stacks on #554 — the diff will show that commit too until it merges.
## Motivation
`isValidPseudoHeaderValue` rejects CR, LF and NUL, which is narrower
than the HTTP/1.1 request line actually needs.
`:path` ends up as the request-target in:
```
METHOD SP request-target SP HTTP-version CRLF
```
so `:path = "/a HTTP/1.1"` serializes to `GET /a HTTP/1.1 HTTP/1.1`.
Whether a recipient reads the first or the last SP-delimited token as
the version decides what the request-target actually is, which is the
usual parser-differential setup. RFC 9112 § 3.2 wants SP in a
request-target percent-encoded, and bare HTAB and the other CTLs aren't
valid there either.
None of the HTTP/2 pseudo-headers have a grammar that allows SP or a
CTL: `:method` and `:protocol` are tokens, `:scheme` is a URI scheme,
`:authority` is host[:port], `:path` is a request-target, `:status` is
3DIGIT. So rejecting them doesn't reject anything well-formed.
Same severity caveat as #554: NIOHTTP1's
`uriOnlyContainsAllowedCharacters` already rejects SP in a
request-target by default, so this is hardening rather than something
exploitable on a stock pipeline.
## Modifications
`isValidPseudoHeaderValue` goes from `{0x00, 0x0A, 0x0D}` to `<= 0x20 ||
== 0x7F`, so the whole CTL range plus SP and DEL.
Bytes >= 0x80 stay allowed on purpose. They aren't delimiters in a
request line or header block, and rejecting them would break anyone
sending unencoded UTF-8 in `:path`.
### One behaviour change worth flagging
`validateRequestBlock` runs on send as well as receive, so a client
passing a URI with a raw space in it will now throw where it didn't
before. I'd argue that's the right outcome, since NIOHTTP1's validator
already rejects that URI by default and this makes the two layers agree,
but it is a behaviour change and it's the bit most likely to need
discussion. That's why I split it out of #554 instead of bundling them.
## Result
Pseudo-header values containing SP or any control character are
rejected.
## Testing
Added to `HTTP2FramePayloadToHTTP1CodecCRLFTests.swift`:
- `:path` with SP (`/a HTTP/1.1`), HTAB, VT, FF, DEL, SOH
- SP in `:authority`, `:method`, `:scheme`
- covered at the predicate, request-validation and server-codec levels
The existing positive cases in that file still pass untouched — `/`,
`/foo/bar`, `/foo?q=1&r=2`, `/foo#fragment`, `*`, `/foo%20bar`, `200` —
which is the check that this doesn't reject anything legitimate.
Built and ran on Linux, Swift 6.1 aarch64. `swift test -Xswiftc
-warnings-as-errors` is clean with no new warnings, the new tests pass,
and `swift format lint --strict Sources/ Tests/` is clean.
---------
Co-authored-by: George Barnett <gbarnett@apple.com>
## Motivation
RFC 9113 § 8.2.1 requires that a field value must not contain NUL, LF or
CR at any position, and that a message carrying one is treated as
malformed. That applies to every field value, not just pseudo-headers.
`legalHeaderField(value:)` only enforces it for pseudo-headers. The
regular-header branch checks the forbidden-name list and then returns
without looking at the value:
```swift
switch self.baseName {
case "connection", "transfer-encoding", "proxy-connection", "keep-alive", "upgrade":
throw NIOHTTP2Errors.forbiddenHeaderField(name: String(self.baseName), value: value)
default:
return
}
```
Nothing else on the inbound path picks it up either. HPACK values are
length-prefixed octet strings, and I couldn't find any charset
validation of values anywhere in NIOHPACK.
Where it bites is `HTTP2ToHTTP1Codec`. Serializing `name: value CRLF`
with an embedded CR or LF terminates the field early and injects header
lines into the HTTP/1.1 message downstream. Same sink as the `:path`
validation added for GHSA-4px2-pw77-vc85, just reached through a regular
field instead.
To be clear about severity: I don't think this is exploitable on a
default pipeline and I don't have a PoC. NIOHTTP1's
`NIOHTTPRequestHeadersValidator` rejects 0x00...0x1F and 0x7F on write,
and the pipeline helpers insert it by default
(`enableOutboundHeaderValidation` defaults to true). So this is
hardening.
I still think it's worth doing here. It's a MUST that NIOHTTP2 is in the
right place to enforce; `HTTPEncoder` itself doesn't validate, so a
hand-built pipeline has no check at all; and anyone reading
`HTTPRequestHead.headers` and passing values on elsewhere is inheriting
a check they'd probably assume the HTTP/2 layer had already done.
## Modifications
`isValidFieldValue(_:)` rejects 0x00, 0x0A and 0x0D, and
`legalHeaderField(value:)` now calls it for regular headers, throwing a
new `NIOHTTP2Errors.invalidHTTP2HeaderFieldValue`. The state machine
already turns a throw here into the right stream/connection error, so
nothing else needed changing.
SP, HTAB and obs-text stay legal (RFC 9110 § 5.5). It sits behind the
existing `headerBlockValidation` flag. The new error type mirrors
`ForbiddenHeaderField`'s storage pattern and is additive public API.
Two things I left out on purpose, both easy to add if you'd rather have
them:
- § 8.2.1 also forbids a value starting or ending with SP/HTAB. Not
smuggling-relevant, and rejecting it seemed likely to break peers
sending harmless padding.
- No check in the codec itself.
`HTTPRequestHead(http2HeaderBlock:isEndStream:)` validates
pseudo-headers inline via `peekPseudoHeader`, but
`appendRegularHeaders(from:)` just copies. I didn't add one there
because it's per-request and you have allocation thresholds. It does
leave the two asymmetric if `headerBlockValidation` is `.disabled`.
## Result
Regular field values containing NUL, CR or LF are treated as malformed.
Well-formed values are unaffected.
## Testing
Added to `HTTP2FramePayloadToHTTP1CodecCRLFTests.swift`, the regression
file from GHSA-4px2-pw77-vc85, which currently has no coverage for
regular field values.
- `isValidFieldValue` against CRLF, lone CR, lone LF, NUL, a full
smuggling payload, a TE desync payload
- values that must still pass: `with spaces inside`, `with\ttab`,
`text/html; charset=utf-8`, bearer tokens, non-ASCII
- request, response and trailers validation
Built and ran on Linux, Swift 6.1 aarch64. `swift test -Xswiftc
-warnings-as-errors` is clean with no new warnings, the new tests pass,
and `swift format lint --strict Sources/ Tests/` is clean.
RFC 9113 § 8.2.2 enumerates five connection-specific header fields that
a conformant HTTP/2 endpoint must treat as malformed: Connection,
Proxy-Connection, Keep-Alive, Transfer-Encoding, and Upgrade.
HeaderFieldName .legalHeaderField(value:) only rejected three of them,
so keep-alive and upgrade passed validation and were translated verbatim
into HTTP/1.1 messages by the H2->H1 codecs. This is a conformance gap
and a defence-in-depth issue, since downstream HTTP/1.1 parsers may act
on those fields independently.
Modifications:
- Add keep-alive and upgrade to the forbidden connection-specific header
switch in legalHeaderField(value:).
- Update the surrounding comment to cite RFC 9113 § 8.2.2 and its
explicit enumeration in place of the obsoleted RFC 7540 § 8.1.2.2
reference.
- Add request- and response-block validation tests covering all five
connection-specific fields.
Result:
All five connection-specific header fields named by RFC 9113 § 8.2.2 are
rejected during header-block validation.
Resolves#549
Co-authored-by: George Barnett <gbarnett@apple.com>
RFC 7541 § 4.2 specifies that an encoder emits at most two dynamic table
size updates between two header blocks (the smallest size reached, then
the final size). The decoder enforced placement - updates must precede
the first header - but put no upper bound on their count, so a block of
arbitrarily many 0x20 bytes followed by a header was accepted. This is a
conformance gap. It is not a DoS: setting an already-empty table to 0 is
O(1).
Modifications:
- Count consecutive table size updates in decodeHeaders(from:) and throw
IllegalDynamicTableSizeChange once a third is seen.
- Extend the existing § 4.2 comment to cite the at-most-two rule.
- Add tests covering the two-accepted and three-rejected cases.
Result:
Header blocks with more than two dynamic table size updates are rejected
as malformed, matching RFC 7541 § 4.2.
Co-authored-by: George Barnett <gbarnett@apple.com>
Motivation:
61d1b44 was merged in from a private security fork and didn't have the
formatter run on it.
Modifications:
- Run the formatter
Result:
Format check passes
Motivation:
At the moment users can only set a target window size which applies to
both the connection and to streams. It should be possible to set these
separately so that one stream can't stall other streams by consuming the
whole flow control window.
Modifications:
- Add target window size to the connection config
- Plumb through the values
Result:
Users can set target flow control window sizes separately
As it turns out our `isEqualCaseInsensitiveASCIIBytes` implementation
isn't super fast. So instead of hitting this 60 times for each header
(once for every entry in the static list), we may just want to compute
the hash of our new header candidate once and do a dict lookup.
The codec now caches the most recent outbound frame and only writes it
on flush or when receiving `.end`. This lets us set `endStream=true` on
the final data or headers frame instead of sending a separate empty data
frame.
Changes:
- Introduced `PendingFrameWrite` to cache frame payload and promise
- Modified `processOutboundData` to return optional frames instead of
writing immediately
- Added `flush()` method to both client codecs to handle cached writes
- Promise merging ensures correct completion notification when combining
frames
Motivation:
Frames written from a child channel may not be written immediately by
the connection channel. For example, a DATA frame written on a stream
may be larger than the max frame size imposed on the connection and so
the connection channel will have to slice it into multiple frames. Or
the connection may not be writable and may delay the transmission of the
frame. This behaviour isn't currently observable but is useful to know
about.
Modifications:
- Add a frame delegate which is notified when certain frames are written
by the connection channel.
Result:
Users can observer when headers and data frames are written into the
connection channel.
Motivation:
The maximum number of recently reset stream frames to track is limited
to a fixed value of 32. This should be configurable.
Modifications:
- Add it to the connection config and propagate it through
Result:
- Resolves#493
Motivation:
When the server is in the locally quiescing state and a client attempts
to open a new stream, the connection state machine treats receiving the
headers as a connection error. This results in the connection being
closed and in-flight requests being failed.
This can happen because of the inherent race between the server sending
a GOAWAY frame and the client receiving it, during which time the client
can open a stream not knowing it's doomed to failure.
Rather than the server treating this as a connection error, it should
reject the stream with a RST_STREAM frame and emit a stream error.
Modifications:
- Emit a stream error when receiving HEADERS in the locally quiesced
state
Result:
Better handling of new streams when the server is quiescing
Strictly speaking, a `close` operation can't really fail (except when
the closing mode isn't supported or the channel is already closed). Even
if an error is encountered while closing a channel, or if an error
caused the channel to be closed, the end result is the same: the channel
will be closed.
In this case in particular, when streams are closed from the client
(i.e. by sending a RST_STREAM frame) the `HTTP2StreamChannel` would fail
the channel's `closeFuture`. This isn't appropriate however, as the
channel is successfully closed.
This change stops failing the stream channel's `closeFuture`. Instead,
if the close happens uncleanly, the error will be fired down the
pipeline and the `close` method's promise will be failed.
Enable MemberImportVisibility check on all targets. Use a standard
string header and footer to bracket the new block for ease of updating
in the future with scripts.
## Motivation
Currently, the multiplexer's inbound streams stream is finished only
when the channel becomes inactive.
There are some scenarios in which the channel may be closed before it
has a chance to become active, and the stream will never be finished.
This can cause any users iterating over the stream to hang.
## Modifications
This PR finishes the inbound streams stream when a connection error is
fired, and when the handler is removed.
## Result
Fewer bugs.
In the async HTTP2 pipeline there is no way to account for the opening
and closing of streams. This PR adds a variant of
`configureAsyncHTTPServerPipeline` (HTTP2 upgrade channel) that allows
the user to pass in a `NIOHTTP2StreamDelegate` to be applied to the
HTTP2 channel if the upgrade occurs.
This is similar to #439 which did the same HTTP2 only channels.
I added the `Bionic` import this summer in #448 and the compiler
accepted it then, but it started erroring a couple months later without
this full Android overlay, so add that instead.
Motivation:
Standardised formatting makes the project cleaner to look at and work
on.
Modifications:
Setup swift-format with the same settings as Swift-NIO
Result:
Common formatting throughout
Motivation:
Only the last 3 versions of Swift are supported.
Modifications:
Update the Swift tools version in Package.swift.
Remove code which can now never be compiled.
Remove legacy docker configuration.
Result:
Only Swift 5.9+ supported.
Motivation:
NIO has a 'ChannelShouldQuiesceEvent' which channels can listen for in
order to know when they should quiesce. This is typically used to
initiate a graceful shutdown of an HTTP/2 server. However, child
channels aren't notified of this event so HTTP/2 servers must keep track
of streams separately in order to notify them when the server is
quiescing.
Modifications:
- Propagate the `ChannelShouldQuiesceEvent` to child channels
Result:
Child channels can watch for `ChannelShouldQuiesceEvent`s
Motivation:
A potential race exists between a server sending a GOAWAY frame and a
client opening a new stream (i.e., sending a HEADERS frame before
receiving an already sent GOAWAY frame). If there are no open streams
when the server sends the GOAWAY frame, the connection state on the
server transitions to being fully quiesced, which throws a connection
error on receipt of a HEADERS frame.
Modifications:
- Adjust the connection state machine on the server to throw a stream
error (instead of a connection error), and consequently, send a
RST_STREAM frame to the client.
Result:
This condition will be treated as a stream-level error instead.
Motivation:
When the connection is fully quiesced, an endpoint responds with a
connection error when it receives or tries to respond to a PING frame.
This behaviour is unnecessary.
Modifications:
- Adjust `HTTP2ConnectionStateMachine` to successfully receive and send
PING frames even when the connection is fully quiesced.
Result:
When the connection is fully quiesced, an endpoint will treat receipt
and sending of a PING frame as it would when the connection is active.
Motivation:
Currently, HEADERS frames are ignored by the client on a client-initiated stream after the client sends a GOAWAY.
As per [Section 6.8 (GOAWAY) in RFC 9113](https://httpwg.org/specs/rfc9113#GOAWAY):
_"Once the GOAWAY is sent, the sender will ignore frames sent on streams **initiated by the receiver** if the stream has an identifier higher than the included last stream identifier."_
In this case, the client (sender) should **not** ignore the HEADERS frame as the stream is initiated by the _client_, not the receiver.
Modifications:
Fixed the condition in the `receiveHeaders` function (given `LocallyQuiescingState`) in `ReceivingHeadersState.swift` to work for _both_ the client and server roles -- before this change, the condition is only correct when `self.role == ConnectionRole.server`
Result:
HEADERS frames are not ignored by the client on a client-initiated stream when locally quiescing.
* Make HEADERS frame payload non-indirect
Motivation:
In previous patches we shrank the size of HTTP2Frame by
making various data types indirect in the frame payload.
This included HEADERS, which is unfortunte as HEADERS frames
are quite common.
This patch changes the layout of the HEADERS frame to remove the
indirect case.
Modifications:
- Move END_STREAM into an OptionSet.
- Turn the two optional bits into flags in the aforementioned
OptionSet
- Replace the properties with computed properties.
- Remove the indirect case
Result:
HEADERS frames are cheaper.
* Update alloc limits
---------
Co-authored-by: George Barnett <gbarnett@apple.com>
Co-authored-by: Gustavo Cairo <gus.cairo@apple.com>
* Reject long sequences of CONTINUATION frames
Motivation:
Long sequences of CONTINUATION frames can be used to mount attacks by attempting to get a remote peer to consume large amounts of memory.
Modifications:
- Add a limit to the number of sequential CONTINUATION frames that can be received. This limit is configurable by users at the NIOHTTP2Handler level and has a default value of 5. When this limit is exceeded, the recipient responds with a GOAWAY frame and an "Enhance Your Calm" error of a newly created type `ExcessiveContinuationFrames`.
Result:
Long sequences of CONTINUATION frames are now rejected by the recipient.
* Refactor implementation
* Minor adjustments
* Implement adjustments
- Refactor implementation
- Revert unnecessary diffs
* Implement adjustments
- Change `public let maximumSequentialContinuationFrames` to `public var`.
- Refactor implementation.
* Implement minor adjustments
* Store the default `maximumSequentialContinuationFrames` in a `private static let`
---------
Co-authored-by: George Barnett <gbarnett@apple.com>
Motivation:
`configureAsyncHTTP2Pipeline` doesn't allow a stream delegate to be
specified. As the async pipeline uses the "inline" stream multiplexer
there's no way to account for streams within the connection channel.
Modifications:
- Add a sync and async variants of `configureAsyncHTTP2Pipeline` which
accepts an optional stream delegate
- Rewrite the existing helpers in terms of the new one
Result:
Users can configure an async http pipeline with a stream delegate.
Motivation:
If a task iterating over inbound streams using the new async API is
cancelled then it can lead to the process crashing as we hit a
precondition which guards against yielding to a terminated
NIOHTTP2AsyncSequence.
Modifications:
Remove the precondition.
Result:
The code no longer crashes, instead it silently drops the yielded value.
Doing more than this such as closing the connection requires rethinking
more of the API.
---------
Co-authored-by: Cory Benfield <lukasa@apple.com>
## Motivation
Some of the test code was missing availability guards for Apple platforms, resulting in build failures for these platforms, e.g.
```
error: 'NIOAsyncTestingChannel' is only available in iOS 13.0 or newer
var clientChannel: NIOAsyncTestingChannel!
```
## Modifications
Add missing availability guards. I've tried to keep them as scoped as possible. Some test suites used these as class properties, so these got a guard at suite level.
## Result
Tests can now build and run on iOS and other Apple platforms.
Motivation:
To address warnings revealed with
`.enableExperimentalFeature("StrictConcurrency=complete"),` in Swift 5.8
Modifications:
* Numerous protections of state in tests
* Make the multiplexer instances explicitly loop bound
* Update channel initializers to be marked as Sendable
* Mark error backing storage types as unchecked sendable
Result:
Better thread safety
# Motivation
We had a retroactive `CustomDebugStringConvertible` conformance to `ByteBufferView` in one of our tests harnesses which caused compiler errors in the latest nightlies.
# Modification
This PR removes the retroactive conformance.
# Result
No more compiler errors.
We previously developed an async API for NIO HTTP/2 which was guarded under SPI. Now that the swift-nio async API is released we can reintroduce this code promoted to SPI.
This change introduces:
* `AsyncStreamMultiplexer` - an async variant of the HTTP/2 stream multiplexer which can be used to create outbound streams and provide access to an async sequence (`NIOHTTP2AsyncSequence`) of inbound streams
* New pipeline configuration functions (e.g. `configureAsyncHTTP2Pipeline`) to support the new async mode
* Limit rate of permitted RST frames
Motivation:
Large number of stream reset frames may be used as a DoS (Denial of
Service) vector in an attempt to overload the CPU of the handling server.
Modifications:
Introduce an additional DoS heuristic which evaluates the rate of
incoming stream reset frames. If the rate exceeds that which is
permitted then the connection is closed and a `GOAWAY` issued.
The allowed rate is configurable but defaults to 200 resets within 30
seconds. This should be acceptable for most applications.
Result:
Excessive reset frames result in the connection being closed.
* review comments
* further review comments
* add integration test
Motivation:
Remove dependency on SPI so that we can cut a release without
introducing dependency on code subject to change.
Modifications:
Remove all code which introduces a dependency on the NIOAsyncChannel SPI
Result:
Code inside SPI is removed
Motivation:
When adding in the SPI methods for exposing async sequences of HTTP/2
streams we moved the stream initialization to a subtly different
location so that it was easier to exfiltrate the outputs of those
initialization functions (such as protocol negotiation outputs).
In some cases this broke ordering expectations.
Modifications:
Yield the (optionally wrapped) channels as initializer outputs to the async stream
Result:
Changes only exist within SPI. Async inbound stream channel
initialization now matches previous behavior.
Motivation:
A recent change allowed stream creation to run immediately if the caller
was on the correct event loop. Normally that's fine, however, it opens
up a code path where streams can become activated twice which leads to a
crash.
Modifications:
- Delay stream creation until the next loop tick
- Add a loop tick to tests which now require it
Result:
Avoid re-entrantly activating streams twice.
* Update to latest NIO with updated protocol negotiation API
Signed-off-by: Si Beaumont <beaumont@apple.com>
* fixup: Also replace deprecated get().waitForFinalResult()
Signed-off-by: Si Beaumont <beaumont@apple.com>
---------
Signed-off-by: Si Beaumont <beaumont@apple.com>
Motivation:
Make sure the order of `HTTP2Frame`s that are fired through the pipeline of a `HTTP2StreamChannel` by `HTTP2CommonInboundStreamMultiplexer` is correct when a `read()` call on the parent channel synchronously causes further frames to be processed.
Modifications:
Reorder calls in `HTTP2CommonInboundStreamMultiplexer.receivedFrame(frame:context:multiplexer)` so that initial header frame is buffered and processed first.
Result:
Resolves#410 and makes newly added test case `HTTP2StreamMultiplexerTests.testMultiplexerFiresInitialFramesInCorrectOrder()` pass.
# Motivation
In my latest PR in NIO, I removed a bunch of API from the bootstrap methods to make the API easier to digest and reduce a number of duplicated code issues.
# Modification
This PR adopts the latest NIO changes and adapts the APIs in H2. More specifically, it removes the `NIOAsyncChannel` convenience methods and makes sure that everything aligns nicely with the proposes bootstrap APIs.
# Result
We now have the APIs in place to bootstrap a protocol negotiated H1/H2 server.
Motivation:
This continues the work to expose functionality which allows users to interact
with HTTP/2 connections via async abstractions and using structured
concurrency.
This work enables protocol negotiation between HTTP/1.1 and HTTP/2 in its most generic form.
Modifications:
Enable protocol negotiation between HTTP/1.1 and HTTP/2 using typed
negotiation results (`NIOProtocolNegotiationResult`) from the
`NIOTypedApplicationProtocolNegotiationHandler`.
In the HTTP/2 case the negotiation result will return the HTTP/2 connection
channel and the `NIOHTTP2Handler.AsyncStreamMultiplexer` which exposes
inbound streams as an iterable async stream.
Result:
Users will be able to set up negotiated HTTP/1.1 / HTTP/2 connections and
iterate over inbound streams.