### Motivation:
We introduced a new configuration type in #3746 to make further
extensions to the server pipeline (#3745 for example) easier to
introduce.
The plan was to merge #3745 soon after #3746 was merged, because #3745
added a breaking change to the new config type.
However, #3745 needs some more consideration. We should therefore revert
the change in #3746 to unblock new releases from being made until we
come up with a better solution.
### Modifications:
A clean revert of PR #3746.
### Result:
Unblocks new releases.
### Motivation:
`NIOHTTP1.HTTPPipelineSetup` contains helper methods which add HTTP/1
client/server handlers to the provided channel pipeline.
Over time, we have had to duplicate these methods when introducing a new
configuration option in order to not break API.
As a result, there is now lots of duplication in
`NIOHTTP1.HTTPPipelineSetup` and introducing more configuration options
is very cumbersome. We should instead add a configuration type to solve
this problem.
### Modifications:
- Added new configuration types named
`NIOHTTPServerPipelineConfiguration`, and
`NIOHTTPServerPipelineSynchronousConfiguration`.
- Added a new pipeline setup helper method on `ChannelPipeline` and
`ChannelPipeline.SynchronousOperations` that requires the configuration
type as an argument.
- Deprecated all existing helper methods on `ChannelPipeline` and
`ChannelPipeline.SynchronousOperations`.
### Result:
Better API.
### Motivation
We want our tests to pass in reasonable time.
### Changes
- Disable test
`ByteBufferCrashTests.setBytesWithoutContigiousStorageMoreThanUInt32maxBytes`
- Do not initialize data in `ByteBufferCrashTests.
takingOwnershipOfPointerThatsToLarge`
### Result
Tests are faster again.
Translate `HTTPHeaderValidationTests` to Swift testing
### Motivation:
We want to add tests that use parameterized testing to
`HTTPHeaderValidationTests`. In order to allow this we first need to
translate this file to use Swift Testing instead of XCTest.
### Modifications:
- Mechanical translation of `HTTPHeaderValidationTests` from XCTest to
Swift testing.
### Result:
We can add parameterized tests to HTTPHeaderValidationTests.
Motivation:
NIOHTTPResponseHeadersValidator drops head/end response parts if they
contain invalid header fields. If a head part is dropped and the server
allows pipelining then the subsequent body/end part will reach the
pipelining handler and result in an assertion failure in debug builds.
In release builds, some parts may be incorrectly written out leading to
protocol violations.
Modifications:
- Drop all response parts after an invalid response part
Result:
- Fewer bugs
- Resolves#3326
Co-authored-by: Cory Benfield <lukasa@apple.com>
* Apply formatting
* Apply no block comments rule
* Apply OmitExplicitReturns
* Apple OnlyOneTrailingClosureArgument
* Apply NoAssignmentInExpressions
* Fix up DontRepeatTypeInStaticProperties lint errors
* Apply `OrderedImports`
* Apply `ReplaceForEachWithForLoop`
* format file
* Enable the formatting pipeline
* Adopt `AmbiguousTrailingClosureOverload`
* Fix license header
* Fix format check
* Fix `EndOfLineComment`
* Fix CI
* Adapt CI script to check if changes when running formatting
* Separate lint and format into to steps
* Fix format
* Adopt `UseEarlyExits`
* Revert "Adopt `UseEarlyExits`"
This reverts commit d1ac5bbe12.
Motivation
HTTP headers are prevented from containing certain characters that can
potentially affect parsing or interpretation. Inadequately policing this
can lead to vulnerabilities in web applications, most notably HTTP
Response Splitting.
NIO was insufficiently policing the correctness of the header fields we
emit in HTTP/1.1. We've therefore added a new handler that is
automatically added to channel pipelines that will police the validity
of header fields.
For projects that are already running the validation themselves, this
can be easily disabled. Note that by default NIO does not validate
content length is correctly calculated, so applications can have their
framing fall out of sync unless they appropriately calculate this
themselves or use chunked transfer encoding.
Modifications
- Add thorough unit testing to confirm we will not emit invalid header
fields.
- Error if a user attempts to send an invalid header field.
Result
NIO applications are no longer vulnerable to response splitting by CRLF
injection by default.