Commit Graph
10 Commits
Author SHA1 Message Date
Fabian Fett 979f431f1f Optimize HTTP2ToHTTP1 client codec to reduce empty data frames (#535)
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
2026-02-10 10:16:27 +00:00
George BarnettandRick Newton-Rogers 159ef997b2 Strict concurrency for tests (#507)
Co-authored-by: Rick Newton-Rogers <rnro@apple.com>
2025-03-31 13:38:26 +01:00
Peter Adams 1118370ec4 Apply swift-format changes and CI (#472)
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
2024-10-29 13:09:54 +00:00
Fabian FettandCory Benfield 1aba7771c8 Add Transfer-Encoding chunked to HTTP1 requests and responses. (#316)
* Add Transfer-Encoding chunked to HTTP1 requests and responses.

* Apply suggestions from code review

Co-authored-by: Cory Benfield <lukasa@apple.com>

* Code review II

* Fixed deprecated tests

Co-authored-by: Cory Benfield <lukasa@apple.com>
2021-11-30 10:25:05 +00:00
Fabian Fett deca1c3227 Remove forbidden HTTP1 headers even if no connection header is present (#311) 2021-11-24 10:19:21 +00:00
Cory Benfield dbfc8fcd1a Clean up imports and dependencies. (#300)
Motivation:

With NIO 2.32.0 we broke the core NIO module up into modules that split
apart the POSIX layer and the core abstractions. As a result, this
package no longer needs to express a hard dependency on the POSIX layer.

Modifications:

- Rewrote imports of NIO to NIOCore.
- Added NIOEmbedded imports where necessary in tests.
- Note that the main modules still depend on NIO, which is necessary
    for backwards-compatibility reasons. This dependency is unused.

Result:

No need to use NIOPosix.
2021-09-14 11:30:04 +01:00
Fabian Fett 1f64743098 Fix receiving empty body byte buffer before .end (#295) 2021-08-12 11:29:39 +01:00
George Barnett 440d64d99a Add a location to each of 'NIOHTTP2Errors' (#247)
Motivation:

Without knowing where an error was thrown it can be unnecessarily
difficult to work out the reasons an application ended up in an error
state.

Modifications:

- Add a 'file' string to each of the 'NIOHTTP2Errors' denoting the file
  and line where an error was created
- Add static methods to create errors to 'NIOHTTP2Errors' defaulting
  file and line, this is unfortunately necessary as defaulting file and
  line in the `init` makes the defaulted and non-defaulted errors
  indistinguishable, and the compiler will pick the one with fewest
  defaulted values.
- Add equatable conformance manually so as to ignore 'file'
- Add backing storage to errors which no longer be stored in an existential
  container
- Add 'CustomStringConvertible' conformance to the errors using backing
  storage so that the 'file' is actually visible when converting the
  error
- Deprecate the old `init`s
- Fix all deprecation warnings

Result:

- NIOHTTP2Errors carry a 'file' with them indicating where they were
  created
2020-09-24 15:21:58 +01:00
George Barnett 20d2069a4e Add test utilities for FramePayloads (#224)
Motivation:

We have many test utilities for `HTTP2Frame` which predominantly make
assertions about the payload. As part of the work done for #214 we'll
need to make these assertions on the payload rather than the frame.

Modifications:

- Refactor `HTTP2Frame` test utilities to pull the payload assertions
  into separate assertions on `FramePayload`
- `HTTP2Frame` assertions call through to the payload assertions

Result:

We can make assertions about payloads.
2020-08-03 07:44:54 +01:00
George Barnett 3c668f5c7e Add HTTP2Frame.FramePayload codecs (#222)
Motivation:

As part of the work for #214 we need new codecs which transform
`HTTP2Frame.FramePayload` to and from the appropriate request and
response parts.

Modifications:

- Add `HTTP2FramePayloadToHTTP1ClientCodec`
- Add `HTTP2FramePayloadToHTTP1ServerCodec`
- Duplicate the HTTP2ToHTTP1CodecTests and update the relevant parts to
  use payloads instead of frames.
- Add relevant test helpers.
- Note: the HTTP2 to HTTP1 (frame based) codecs haven't been deprecated:
  doing so without warnings depends on #221.

Result:

- We can transform `HTTP2Frame.FramePayload` types to the relevant HTTP
  client and server request and response types.
2020-07-31 10:29:42 +01:00