114 Commits
Author SHA1 Message Date
Tianhao Liu 4ba1f167a7 Keep zlib streams at stable addresses (#321)
### Motivation:

zlib stores the address of `z_stream` in its internal state and expects
that
address to remain stable across calls. Storing `z_stream` inline in
movable
Swift value types does not provide that guarantee and can cause
`Z_STREAM_ERROR` during cleanup.

Fixes #308.

### Modifications:

- Make the internal compressor and decompressor reference owners of
separately
  allocated `z_stream` storage.
- Pass the stable pointer to every zlib initialization, processing, and
cleanup
  call.
- Keep lifecycle state with the pointer owner and make conditional
cleanup
  idempotent.
- Add regression tests covering failed initialization recovery, multiple
compression and decompression calls, repeated lifecycles, and
deallocation
  cleanup.

### Result:

zlib observes the same `z_stream` address for each complete lifecycle,
while
stream cleanup remains single-owner and safe against repeated shutdown.
2026-08-06 07:10:41 +00:00
Michael RusterholzandCory Benfield aedcd7e2d4 Fix HTTPResumableUploadHandler dropping responses after the first request on a connection (#319)
Fix `HTTPResumableUploadHandler` silently dropping all responses after
the first request on a connection.

### Motivation:

`HTTPResumableUploadHandler` forwards all outbound operations through
its stored `ChannelHandlerContext`, which is set only in `handlerAdded`
and cleared by `detach()` whenever an upload releases the handler. When
a second request arrives on the same channel — the normal case for
HTTP/1.1 with keep-alive — `channelRead` calls `resetUpload`, which ends
the previous upload. That synchronously detaches the handler and clears
its context, and nothing restores it before the new upload is attached.
Every response write for the second and subsequent requests then hits
`self.context?.write(...)` as a no-op: the response is silently dropped,
write promises never complete, and `read()` forwarding to the parent
channel stops, so the client hangs until it times out.

The existing tests never caught this because each test sends one request
per `EmbeddedChannel`; resumption is only exercised across separate
channels, and per-stream channels (HTTP/2) recreate the handler per
request, which also masks the bug.

### Modifications:

- Restore `self.context` in `resetUpload(context:)` after ending the
previous upload.
- Add `testNonUploadKeepAlive` and `testResumableUploadKeepAlive`, which
send a second request on the same `EmbeddedChannel` for pass-through
traffic and after a completed upload creation respectively. Both fail
without the fix.

### Result:

Connections handled by `HTTPResumableUploadHandler` can serve more than
one request: responses to the second and subsequent requests on a
keep-alive connection are delivered instead of being silently dropped.

Fixes #318

Co-authored-by: Cory Benfield <lukasa@apple.com>
2026-07-20 14:04:53 +00:00
Johannes Weiss ea000751b1 Reject too-small IPv4 packets in the PCAP parser test helper (#320)
### Motivation:

The readTCPIPv4 helper subtracted 20 from the IPv4 total length field in
UInt16 space before validating it. A total length below the header size
wraps around and traps with an arithmetic overflow.

A TCP/IPv4 packet is always at least 40 bytes (a 20 byte IPv4 header
plus a 20 byte TCP header), so a smaller total length is an illegal
packet that no further data can complete. Validate the total length
alongside the version and protocol checks and throw when it is too
small, then slice the payload. A regression test covers the lengths that
previously trapped.

These helpers only ever parse pcaps that WritePCAPHandler wrote, which
are always well formed, so the bug was dormant here. It becomes a real
crash when the helpers are reused to parse arbitrary captures.

### Modifications:

- Implement the check

### Result:

- More correct code, even though it's just a test helper
2026-07-17 10:59:41 +00:00
MichaelDRZandGeorge Barnett 88a51340f5 Make the HTTP decompressors safe against synchronous channelRead re-entry (#317)
### Motivation:

`NIOHTTPRequestDecompressor` / `NIOHTTPResponseDecompressor` keep their
state in a
stored `var decompressor` (a `struct`) and forwarded downstream
(`fireChannelRead` /
`fireErrorCaught`) from inside that struct's `mutating` `channelRead`,
i.e. while an
exclusive (modify) access to the stored property was still open. If
firing downstream
synchronously re-enters the handler's `channelRead`, a second exclusive
access is
opened and the program traps with `Fatal access conflict detected`
(SIGABRT).

This reproduces in production with AsyncHTTPClient over HTTP/2 and
`decompression = .enabled`: a compressed response is mid-decompress when
a
decompression error closes the stream, and the buffered read
re-delivered on the
stream-close path re-enters `channelRead` on the same decompressor.

### Modifications:

- The body decompression is now expressed as a
`NIOSingleStepByteToMessageDecoder`,
driven by a `NIOSingleStepByteToMessageProcessor`. The handler pulls one
decompressed
buffer at a time and forwards it only after `decode` has returned, so
the decoder
  relinquishes its exclusive access before anything is fired downstream.
- The shared driver is now a `class`, so the head/end forwarding paths
are re-entrancy
  safe for the same reason.
- The zlib stream is torn down in the decoder's `deinit`, which
additionally fixes a
  leak when a message ends without a final `.end`.
- No public API changes.

### Result:

Synchronous re-entry of `channelRead` no longer traps. Adds regression
tests covering
the forward and error re-entry paths on both decompressors; all existing
decompression
tests (limits, trailing data, truncation, multi-message reuse) continue
to pass.

Fixes #314

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2026-07-06 08:59:16 +00:00
George Barnett cff75b3d21 Throw on invalid psuedoheaders when converting between http/2 (#316)
Motivation:

The HTTPType to HTTP2 conversion functions can trip up on invalid psuedo
header fields. Prior to this change they'll loop indefinitely, instead
they should be rejected per RFC 9113 § 8.3.

Modifications:

- Throw on unrecognised psuedo header fields
- Add tests

Result:

- More spec compliant
2026-07-02 14:31:30 +00:00
George Barnett 1d691e38d0 Return 0 for malformed q-values (#313)
Motivation:

Certain malformed q-values can trigger a crash because they don't
validate that a string split results in the expected number of parts.

Modifications:

- validate that the number of split parts is as expected, return a
q-value of zero otherwise (i.e. "not acceptable")

Result:

Safer code
2026-07-01 12:07:05 +01:00
Fabian Fett d2eeec0339 Merge commit from fork
### Motivation

We want to maintain less code.

### Changes

- Unifi the request and response decompression by extracting the decompression code into a `Decompressor` struct
- `NIOHTTPRequestDecompressor` calls out to `Decompressor` internally
- `NIOHTTPResponseDecompressor` calls out to `Decompressor` internally

### Result

- Less code to maintain
- Less subtle bugs
2026-05-20 10:02:26 +01:00
Johannes WeissandJohannes Weiss fef304cebf vendor zlib instead of relying on system version (#306)
### Motivation:

Relying on the system zlib causes issues if that library (or its
headers) doesn't ship with the system.

### Modifications:

Vendor it.

### Result:

- Fewer dependencies.
- Binary size increase negligible. The _sum of the debug builds_ of all
`.o` files is less than 200kB. A linked release build will make this
even smaller:

```
$ du -k .build/arm64-apple-macosx/debug/CNIOExtrasZlib.build/*.o
12	.build/arm64-apple-macosx/debug/CNIOExtrasZlib.build/adler32.c.o
12	.build/arm64-apple-macosx/debug/CNIOExtrasZlib.build/crc32.c.o
60	.build/arm64-apple-macosx/debug/CNIOExtrasZlib.build/deflate.c.o
16	.build/arm64-apple-macosx/debug/CNIOExtrasZlib.build/inffast.c.o
40	.build/arm64-apple-macosx/debug/CNIOExtrasZlib.build/inflate.c.o
16	.build/arm64-apple-macosx/debug/CNIOExtrasZlib.build/inftrees.c.o
40	.build/arm64-apple-macosx/debug/CNIOExtrasZlib.build/trees.c.o
8	.build/arm64-apple-macosx/debug/CNIOExtrasZlib.build/zutil.c.o
```

Co-authored-by: Johannes Weiss <johannes@jweiss.io>
2026-02-26 21:39:13 +00:00
Si Beaumont 3df009d563 Fix crash in HTTPResumableUploadChannel when parent channel is closed (#304)
### Motivation:

Servers using `HTTPResumableUploadHandler` can currently crash during
channel creation if the parent channel is closed.

During channel creation, the handler will inherit the `autoRead` option
from the parent channel:

```
try! parent.syncOptions!.getOption(ChannelOptions.autoRead)
```

The force-unwrap of `syncOptions` is justified because this handler can
only be used with channels that support sync options, but the force-try
can trigger a crash with supported channels when the connection is
interrupted.

NIO's `BaseSocketChannel` will throw an error if the channel is closed,
and this presents a race window and we've observed crashes with the
following output:

```
HTTPResumableUploadChannel.swift:81: Fatal error: 'try!' expression unexpectedly raised an error: I/O on closed channel
```

### Modifications:

Replace the force-try with `try?` to prevent the crash. Given it looks
like the only reason this would throw is if the connection is closed,
the channel is not long for this world, and so the default value used is
moot. However, I've defaulted this to `false` as it's the most
conservative option.

I also wrote a test that uses new `EmbeddedChannel` API that was added
to support this fix. The PR has been structured to add the test first,
showing it failing, and then add the fix commit, which then shows the
test passing.

### Result:

The server will no longer crash when parent channels close during upload
operations.
2026-01-28 11:08:37 +00:00
hamzahrmalik 2b837f7c5b Helper to validate nio-ssl certificates using a swift-certificates Verifier (#302)
### Motivation:

Swift Certificates offers the ability to write complex verification
logic. We should be able to make use of that in a NIO application.

### Modifications:

Add a helper function to validate a swift nio chain using a Verifier.
This function could be called within a custom verification callback on a
NIOSSLServerHandler, for example.
2026-01-14 11:33:04 +00:00
George Barnett 1c90641b02 Fix sendability issue in NIOResumableUpload (#299)
Motivation:

The HTTPResumableUpload type is non-sendable and bound to a particular
event loop. It holds a ref to a HTTPResumableUploadHandler which is also
non-sendable and bound to a particular event loop which may be different
to the event loop of the upload. This should not be possible: if the
event loops aren't guaranteed to be the same then the upload can't
possibly hold a handler as it must necessarily cross an isolation
domain.

The sendable view of the uploads are also held in a dictionary protected
by a mutex but also provide access to the loop bound holding the upload.
This makes it a little too easy to accidentally use the loop bound value
from the wrong event loop which will lead to a runtime crash.

Modifications:

- Add a sendable view to the HTTPResumableUploadHandler which dispatches
work to the correct event loop
- Replace occurrences of HTTPResumableUploadHandler with its sendable
view in the HTTPResumableUpload
- Extend the sendable view of HTTPResumableUpload and audit calls using
the loop bound value
- Add a test for multi-thread multi-chunk uploads

Result:

Can do multi-chunk multi-thread uploads without runtime crashes
2025-12-09 09:24:30 +00:00
Guoye Zhang d5578e7b77 Handle absolute-form requests when converting from/to HTTPTypes (#293)
Handle absolute-form requests when converting from/to HTTPTypes.

### Motivation:

HTTPTypes represent modern HTTP/2 / HTTP/3 semantics which do not
support absolute-form requests.

### Modifications:

When converting an absolute-form request to an HTTPRequest, the request
target is converted to its path. When converting an HTTPRequest back,
the user needs to specify which form to convert to.

### Result:

HTTPRequest no longer contains invalid paths when working with cleartext
HTTP/1 proxies.
2025-11-04 12:31:24 -05:00
hamzahrmalik b87fdbf492 Add makeServerConfigurationWithMTLS (#286)
To mirror https://github.com/apple/swift-nio-ssl/pull/545

This allows users to easily create a tls configuration for servers which
want to do mtls, with reloading
2025-10-23 11:07:45 +01:00
Orhan Yigit YazicilarandCory Benfield 382b5fcd88 Drop Swift 5.10 (#289)
### Motivation:

Swift 5.10 is no longer supported, we should bump the swift-tools
version.

### Modifications:

* Update Swift tools version to 6.0
* Remove unnecessary compiler directives

### Result:

Code reflects our support window.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-10-16 15:29:09 +00:00
Cory Benfield ecd27f75b7 Workaround known runtime crash in Swift (#290) 2025-10-16 14:39:31 +00:00
hamzahrmalik a55c3dd3a8 Callback for certificate reload failures (#283)
Callback for certificate reload failures

### Motivation:

Users might want to emit a metric or log when rotation fails.

### Modifications:

Add a new callback which is called whenever a reload fails. This
callback is given an instance of CertificateLoadFailure which contains
the error. The CertificateLoadFailure type allows us to evolve this in
future
2025-07-23 15:16:42 +01:00
hamzahrmalik 614cedd4b1 Make a new variant of makeReloaderValidatingSources which takes a Configuration (#282)
In #281 we added a Configuration object. Now it's possible to create a
TimedCertificateReloader with a single configuration parameter. The
makeReloaderValidatingSources function should be updated to also take
this parameter
2025-07-22 17:14:25 +01:00
hamzahrmalik 0abfca1a17 Add callback in TimedCertificateReloader to listen for reloads (#281)
Add callback in TimedCertificateReloader to listen for reloads

### Motivation:

Adopter might want to know when a certificate was reloaded, e.g. to emit
a log or metric

### Modifications:

- Add a new callback in the reloader which is called whenever a reload
happens. The closure is passed a struct which tells us which cert and
key were read, and whether or not theyre 'new'
- Change the initializer to take a config struct to make this more
extensible going forward
2025-07-22 09:57:48 +01:00
Orhan Yigit YazicilarandGeorge Barnett 774c274789 Split RequestResponseHandlers into Sendable and non-Sendable variants (#279)
Motivation:
`RequestResponseHandler` and `RequestResponseWithIDHandler` previously
allowed non-`Sendable` Requests to move across event loops by wrapping
it in `UnsafeTransfer`, which disabled the compiler's sendability
checking. Requiring every Response to be `Sendable` would solve the
safety issue but it limits how the handlers can be used.

Modifications:
* Extracted the common logic of both handlers into a single state
machine.
* Modified the original implementations to have Request conform to
`Sendable`
* Introduced two new variants that don't care if the Request is
`Sendable` as promises moving to different event loops would be failed
with an error.
* Removed the UnsafeTransfer type as it is not used anymore.
* Added unit tests to confirm that the Sendable variants allow for
promises for different event loops and non-Sendable variants fail the
promises with an Error.

Result:
* Compiler's sendability checks are restored for the handlers.

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-07-03 13:00:21 +01:00
Raphael c6714eeaa4 Responsiveness fallback handler (#278)
### Motivation:

The SimpleResponsivenessRequestMux knows how to handle a few different
requests. For those it doesn’t know how to handle, it responds with a
404.

It would be helpful if the handler had a mode where it optionally
forwards requests it doesn’t know how to handle to a fallback channel
handler so that users can respond to these requests.

### Modifications:

The mux has a new initializer that can configure it to accept unexpected
requests, i.e., those not defined by itself. In this case it will
forward requests down the pipeline. However, its default behavior
remains the same: respond with a 404.

### Result:

When setting up the mux, users can add additional handler to the
pipeline and configure the mux to forward its requests.
2025-06-19 10:35:30 +01:00
Franz Busch 145db1962f TimedCertificateReloader prevents non-self-signed certificates from b… (#274)
…eing loaded

Fix certificate check and make sure all code paths throw an error.

### Motivation:

TimedCertificateReloader currently has an invalid check that
accidecanlly enforces self-signed certificates. Additionally some code
paths of `reload()` did not throw an error which made it hard for the
call site to judge if the reloader was initialized successfully or not.
Further, the missing errors also meant that the `run()` method would
never be able to log these.

### Modifications:

* Updated the certificate check to validate the the public key of the
private key matches the cert's public key (instead of checking the
signature).
* Added three new error cases.

### Result:

* A caller can now be sure that their certificate and private key pair
are valid after calling `reload()` the first time.
* Errors in future reloads will be surfaced using the provided logger
and do not go unnoticed.
* You can actually use the reloader with normal certificates.
2025-05-30 12:31:14 +00:00
Franz Busch 24cb15c9bc Support certificate chains from single PEM in TimedCertificateReloader (#273)
## Motivation

The new `TimedCertificateReloader` currently only supports loading PEM
files with a single cert. It is often the case that a single PEM file
contains an entire certificate chain.

## Modification

Modifies the code to support loading an entire certificate chain from a
single PEM file.

## Result

PEM based certificate chain support in our new
`TimedCertificateReloader`
2025-05-20 14:25:46 +00:00
Gus Cairo 949cf2d3c8 Add a TimedCertificateReloader (#269)
This PR adds a `CertificateReloader` protocol and a
`TimedCertificateReloader` implementation.

A `CertificateReloader` allows for certificate-key pairs to be observed
and updated. A `TimedCertificateReloader` does this every set interval
of time.

This PR also provides an extension on `TLSConfiguration` to enable this
reloading ability in NIO applications, so that updated certificates and
keys can be used during SSL handshakes; as well as conformance of the
`TimedCertificateReloader` to `swift-service-lifecycle`'s `Service`
protocol, for easy composition.
2025-05-14 13:37:05 +01:00
Rick Newton-Rogers 0fc472ba34 Drop Swift 5.9 (#270)
Motivation:

Swift 5.9 is no longer supported, we should bump the tools version and
remove it from our CI.

Modifications:

* Bump the Swift tools version to Swift 5.10
* Remove Swift 5.9 jobs where appropriate in main.yml, pull_request.yml

Result:

Code reflects our support window.
2025-05-07 05:52:53 +00:00
George Barnett a0189d045c Strict concurrency for NIOResumableUpload (#265)
HTTPResumableUpload contains the core logic. It uses an event loop to
synchronize its state internally. Some methods are safe to call from off
of that event loop and have been moved to a new sendable view. The
HTTPResumableUpload type is marked as explicitly not sendable.

As such, most other types now hold on to the sendable view and use that
as the interface to HTTPResumableUpload.

HTTPResumableUploadChannel must be sendable (it's a Channel) and now
uses safe abstractions (where possible).
2025-04-08 09:21:01 +01:00
George Barnett b6b5e1133f Strict concurrency for NIONFS3 and NIONFS3Tests (#264) 2025-04-07 15:09:17 +01:00
George Barnett c92af9d4ef Strict concurrency for HTTPTypes and friends (#259) 2025-04-01 15:44:08 +00:00
George Barnett dc6987e77e Strict concurrency for NIOSOCKS (#256) 2025-04-01 14:33:46 +00:00
George Barnett 0447b0359e Strict concurrency for NIOHTTPCompression (#257) 2025-04-01 15:29:54 +01:00
George Barnett 20c59b2d64 Strict concurrency for NIOExtras and NIOExtrasTests (#254) 2025-03-31 11:53:06 +01:00
Honza Dvorsky ae4d6b4b9a Add a missing import to CNIOLinux (#251)
### Motivation:

Stricter import rules mean that using the `sin_addr` property on Linux
requires the explicit CNIOLinux import.

### Modifications:

Added the missing import.

### Result:

Fixes a CI diagnostic.
2025-03-11 12:10:01 +00:00
Eric RosenbergandGeorge Barnett 4804de1953 Responsiveness under Working Conditions (#242)
Implementation of
https://datatracker.ietf.org/doc/draft-ietf-ippm-responsiveness/ (draft
5) with flexible download and upload handlers to suit other use cases as
well.

### Motivation:

The provided handlers are useful for measuring responsiveness and
testing things like performance of proxies

### Modifications:

Add `NIOHTTPResponsiveness` and `NIOHTTPResponsivenessServer`

### Result:

We'll now have an implementation of the Responsiveness under Working
Conditions draft

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-01-21 17:14:26 +00:00
Marc Prud'hommeauxandGeorge Barnett aa0d902637 Android support (#244)
Add Android support

### Motivation:

Support the Android platform.

### Modifications:

Add Android imports and fix the default temporary directory to be
correct for the OS.

### Result:

The package will build and test on Android.

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-01-14 16:48:42 +00:00
George Barnett 74a143a79f Fix warnings (#245)
Motivation:

The latest NIO release deprecated a number of APIs and added more
Sendable contraints.

Modifications:

- Use sync APIs where possible
- Use `_deprecated` but not `@deprecated` NIOFileHandle API
- Stop using NIOAny

Result:

No warnings
2025-01-14 11:24:08 +00:00
Eric Rosenberg 066c8e4ccd support h2 stream resets through user events (#241)
Allow applications to trigger HTTP/2 stream resets while using
NIOHTTPTypesHTTP2's codecs

### Motivation:

Resetting streams with specific error codes is required by some
applications such as those implementing the CONNECT method
(see https://datatracker.ietf.org/doc/html/rfc9113#section-8.5-8).
Unfortunately, the HTTP2ToHTTP codecs don't expose this capability to
applications.

### Modifications:

Introduce an outbound user event applications can trigger when needing
to reset an HTTP/2 stream.

### Result:

Now applications can trigger HTTP/2 stream resets while using the codecs
provided by NIOHTTPTypesHTTP2
2025-01-07 08:05:05 +00:00
fde9d65d2e Import HTTP resumable upload sample code (#203)
Support HTTP resumable upload.

### Motivation:

Supporting HTTP resumable upload protocol defined in
https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-resumable-upload-05

* Interop version 3: iOS 17.0, macOS 14.0
* Interop version 5: iOS 18.0, macOS 15.0
* Interop version 6: iOS 18.1, macOS 15.1

### Modifications:

2 new public classes, `HTTPResumableUploadHandler` and
`HTTPResumableUploadContext`, and a few other supporting objects to
manage resumable uploads and translate them into regular uploads.

---------

Co-authored-by: Jonathan Flat <jflat@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-12-11 07:39:13 +00:00
Rick Newton-Rogers 3f776e9aaf Migrate CI to use GitHub Actions. (#234)
### Motivation:

To migrate to GitHub actions and centralised infrastructure.

### Modifications:

Changes of note:
* Adopt swift-format using rules from SwiftNIO
* Remove scripts and docker files which are no longer needed

### Result:

Feature parity with old CI.
2024-10-28 14:00:57 +00:00
Rick Newton-RogersandRick Newton-Rogers 2e9746cfc5 LineBasedFrameDecoderTest cleanup (#230)
Remove extraneous `print` statement.

Co-authored-by: Rick Newton-Rogers <rnro@apple.com>
2024-09-11 17:04:50 +01:00
Rick Newton-RogersandRick Newton-Rogers 4f888611eb LineBasedFrameDecoder.decodeLast handle more frames (#229)
### Motivation:

`LineBasedFrameDecoder.decodeLast` throws an error if there is more than
one frame’s worth of bytes remaining in the buffer.

This is in violation of the `NIOSingleStepByteToMessageDecoder`protocol
requirement that this method be called in a loop until all bytes are
decoded.

### Modifications:

* The method now only throws if the decode operation could not return a
frame and there are bytes left in the buffer (previously only the latter
criterion applied).
* Method documentation is updated.
* Test added.

### Result:

`LineBasedFrameDecoder.decodeLast` can cope with more edge cases.

Co-authored-by: Rick Newton-Rogers <rnro@apple.com>
2024-09-11 16:44:42 +01:00
Dimitri Bouniol d1ead62745 Conditional Response Compression (#225)
* Added support for conditional response compression

* Updated expectations to be fulfilled via a defer

* Updated compression response predicate to return an intent enum rather than a boolean
2024-07-18 16:19:20 +01:00
Dimitri Bouniol 05c36b5745 Added a test for responding with 304 Not Modified with HTTP compression (#224) 2024-06-18 04:51:32 -07:00
Johannes Weiss efd416ee15 clean up @retroactive conformances (#222) 2024-05-09 13:02:05 +01:00
David NadobaandCory Benfield 8b9030df7c Enable automatic compression format detection (#208)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-03-26 02:57:29 -07:00
Iceman 3bbec9883a Fix NIOHTTPDecompression bug for multi-request channels (#221)
Motivation:

`NIOHTTPDecompression` erroneously accumulates decompressed data sizes across multiple requests in a single channel, leading to unwarranted `DecompressionError.limit` errors. This affects applications using persistent connections, as the decompression limits are improperly enforced. This change aims to address and rectify this issue.

Modifications:

- Add initialization of `inflated` within `Decompressor.initializeDecoder`.
- Introduced new tests to validate decompression functionality across multiple requests on the same channel

Result:

This fix ensures each request's decompression size is independently considered, eliminating incorrect limit errors, and enhancing reliability for applications using HTTP compression with persistent connections.
2024-03-20 01:58:49 -07:00
Johannes WeissandJohannes Weiss cdd1580a03 LineBasedFrameDecoder: can be a NIOSingleStepByteToMessageDecoder (#217)
Co-authored-by: Johannes Weiss <johannes@jweiss.io>
2024-02-06 16:31:09 +00:00
Si Beaumont 363da63c19 Add missing availability guards in tests (#214) 2023-12-15 08:05:29 -08:00
Cory Benfield 7264a5a0d7 Add retroactive marker to test conformances (#212)
Motivation

Nightly CI builds require annotations on retroactive conformances.
We have a few used only in tests, which are totally safe.

Modifications

Add retroactive conformance marker.

Result

Nightly CI works again
2023-11-28 17:53:58 +00:00
George Barnett df34965cd7 Don't reserve capacity for NIOPCAPRingBuffer (#209)
Motivation:

The NIOPCAPRingBuffer can limit the number of fragment or the total
number of bytes in its buffer or both. When configuring the buffer to
limit only the maximum number of bytes it sets the maximum number of
fragments allowed to `.max`. On `init` the buffer has enough capacity
reserved to store tha maximum number of fragments.

This would be a large and potentially totally unnecessary allocation.
That is, if it didn't crash at runtime. It crashes at runtime as
`CircularBuffer` converts the requested capacity to a `UInt32` which
traps if you pass it an `Int.max`.

Modifications:

- Don't reserve capacity on init
- Adjust the test which tests the byte limit to not set a capacity as
  well

Result:

- `NIOPCAPRingBuffer(maximumBytes:)` doesn't crash
2023-11-03 10:04:31 +00:00
Guoye Zhang 798c962495 Add HTTP types adapter for SwiftNIO (#202)
* Add HTTP types adapter for SwiftNIO

* swiftformat

* Guard on Swift 5.8

* Review comments

* Update swift-http-types to 0.1.1

* Update swift-http-types to 1.0.0

* Review feedback

* Review feedback

* Bump minimum Swift version to 5.7.1

* Allow Host in any order
2023-10-20 17:55:23 +01:00
Cory Benfield 9cdb93e321 Drop Swift 5.5 (#197)
Motivation

Per SwiftNIO's formal version policy, we are ready to drop support for
Swift 5.5.

Modifications

This patch removes the support for 5.5 and all supporting
infrastructure. This includes the test generation functionality, which
is no longer required, as well as the files generated by that
functionality. It updates the dockerfile for 5.8, and it removes all
conditional compilation checks that are now definitionally true.

Result

A nice, clean, 5.6+ codebase
2023-04-13 16:47:28 +01:00