47 Commits
Author SHA1 Message Date
Rick Newton-Rogers 933538faa4 Drop Swift 6.0 (#78)
Motivation:

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

Modifications:

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

Result:

Code reflects our support window.
2026-04-01 21:19:32 +01:00
Joannis Orlandos 76d7627bd8 Add support for Windows (#73) 2025-11-04 14:52:31 -05:00
Orhan Yigit Yazicilar a9f3c352f4 Drop Swift 5.10 (#71)
### Motivation:

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

### Modifications:

* Update Swift tools version to 6.0

### Result:

Code reflects our support window.
2025-09-25 13:46:50 +01:00
Rafael Cepeda 64af0a5003 Fixed sendability warnings when -require-explict-sendable flag is enabled (#68)
Fixed sendability warnings when -require-explict-sendable flag is
enabled. Added -Xswiftc -Xfrontend to fix GA workflow.
2025-06-20 12:57:43 +01:00
Rick Newton-Rogers db6eea3692 Update StructuredFieldValueParser to add missing visionOS guard (#67)
Update StructuredFieldValueParser to add missing visionOS guard matching
the guards on the called API. This was causing failures to compile for
visionOS
2025-05-13 13:30:24 +01:00
Rick Newton-RogersandCory Benfield 3d33634532 Add static SDK CI workflow (#61)
Add static SDK CI workflow which runs on commits to PRs, merges to main
and daily on main.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-04-02 13:35:42 +00:00
Rick Newton-Rogers 8e769facea Update FieldParser.swift availability guard (#63)
Update FieldParser.swift availability guard for 
```
String(unsafeUninitializedCapacity: unescapedBytes.count)
```
which is only available on Mac Catalyst 14.0 or later
2025-03-28 16:02:59 +00:00
Marc Prud'hommeaux ceae3ec5a4 Android support (#57)
This PR adds the single import needed to build and test on Android.
2025-01-14 14:49:23 +00:00
Clinton NkwochaandCory Benfield 847a630908 Update documentation (#55)
Motivation:

swift-http-structured-headers has been updated to [RFC
9651](https://www.ietf.org/rfc/rfc9651.html).

Modifications:

- Update documentation.

Result:

An up-to-date documentation.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-12-12 14:35:43 +00:00
Clinton Nkwocha 1a14678249 Integer serialization fix for 32 bit platform compatibility (#52)
Motivation:

[RFC 9651](https://www.ietf.org/rfc/rfc9651.html) permits serializing an
integer in the range of -999,999,999,999,999 to 999,999,999,999,999
inclusive ([Section
4.1.4-2.1.1](https://www.ietf.org/rfc/rfc9651.html#section-4.1.4-2.1.1)).
As `RFC9651BareItem` takes values `integer` or `date` with an associated
value of type `Int`, that range is implicitly more constrained on 32-bit
platforms to a subset range of `Int32.min` to `Int32.max` inclusive.

Modifications:

- Adjust `RFC9651BareItem` to take values `integer` or `date` with an
associated value of type `Int64` instead, which is sufficient for the
permitted range.

Result:

Compatibility for the Integer and Date Structured Types on 32-bit
platforms.
2024-12-12 14:16:50 +00:00
Clinton NkwochaandCory Benfield be84570e9f Add support for Display String type to StructuredFieldValues (#51)
Motivation:

The parser and serializer for the Display String type have been
implemented. The high-level encoder and decoder should follow.

Modifications:

Implement the encoder and decoder for Display String.

Result:

The StructuredFieldValues module will support the Display String type.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-12-10 07:56:51 +00:00
Clinton Nkwocha 0d92bf6b08 Enable strict concurrency (#53)
Motivation:

To catch potential data races at build time.

Modifications:

- Enable strict concurrency in Package.swift.
- Add `Sendable` conformance to `StructuredFieldType`.
- Swap
[concurrency-unsafe](https://github.com/swiftlang/swift/issues/66213)
`CommandLine.arguments` for `ProcessInfo.processInfo.arguments`.

Result:

Strict concurrency adoption.
2024-12-05 12:16:11 +01:00
Clinton Nkwocha 6e527aa16a Add support for Date type to StructuredFieldValues (#49)
Motivation:

The parser and serializer for the Date type has been implemented. The high-level encoder and decoder should follow.

Modifications:

- Implement the encoder and decoder for Date.

Result:

The StructuredFieldValues module will support the Date type.
2024-11-26 16:04:41 +00:00
Clinton Nkwocha c2e79ce44c [RFC 9651] Add support for Display String type to RawStructuredFieldValues (#43)
Motivation:

RFC 9651 added the Display String Structured Type.

Modifications:

Implement the parser and serializer for Display String in the RawStructuredFieldValues module.

Result:

The RawStructuredFieldValues module will support the Display String type.
2024-11-22 18:11:50 +00:00
Rick Newton-Rogers 8b35bf45bf Migrate to GitHub Actions (#42)
Migrate CI to use GitHub Actions.

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-30 13:20:20 +00:00
Clinton Nkwocha b0bf94fb2d [RFC 9651] Add support for Date type to RawStructuredFieldValues (#41)
Motivation:

[RFC 9651](https://www.ietf.org/rfc/rfc9651.html) added the Date Structured Type.

Modifications:

- Implement the parser and serializer for Date in the RawStructuredFieldValues module.

Result:

The RawStructuredFieldValues module will support the Date type.
2024-10-28 14:01:46 +00:00
Clinton Nkwocha f069b10a87 [RFC 9651] Implement adjustments for backward compatible update (#40)
Motivation:

`swift-http-structured-headers` has to be updated to [RFC 9651](https://www.ietf.org/rfc/rfc9651.html). And it will be convenient for users to have this update as a SemVer minor.

Modifications:

- Deprecate the `BareItem` type and replace it with `RFC9651BareItem`, retaining existing behaviours. Updates for the new RFC will be based on `RFC9651BareItem`.

Result:

The library can be updated to the new RFC in a backward-compatible manner.
2024-10-23 10:56:35 +01:00
Cory Benfield 9055e7c729 Remove unneeded compiler guard. (#35)
Motivation:

We no longer support compilers older than 5.3 (or indeed older than
5.6), so we don't need compiler guards for old ones.

Modifications:

Remove fallback for old compilers.

Result:

Easier to understand code
2023-08-01 15:15:17 +01:00
Peter AdamsandCory Benfield ef88c2245f Remove Swift 5.5 Dockerfile (#34)
* Remove Swift 5.5 Dockerfile

Motivation:

Swift 5.5 is no longer supported.

Modifications:

Remove Swift 5.5 Dockerfile

Result:

Swift 5.5 support fully removed

* Remove SHSendable

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2023-04-14 03:21:10 -07:00
Cory Benfield d95a83fac7 Fix documentation and add infrastructure for CI-ing it (#31) 2023-04-11 13:35:28 +01:00
Cory Benfield 76a75874dd Use Docc for documentation (#25)
Motivation

Documentation is nice, and we can help support users by providing useful
clear docs.

Modifications

Add Docc to 5.6 and later builds
Make sure symbol references work
Add overview docs

Result

Nice rendering docs
2022-07-29 10:43:34 +01:00
David EvansandCory Benfield 522c301c0f Adopt Sendable (#23)
* Make RawStructuredFieldValues sendable

* Make StructuredFieldValues Sendable

* Rename _Sendable to SHSendable

* Fix date checking

* Fix warning

* Soundness

* Update date

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

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-05-13 17:11:50 +01:00
Cory Benfield a3c50a9c10 Remove redundant conformance constraints (#22) 2022-04-22 09:46:54 +01:00
Xiaodi WuandCory Benfield 8c5c9aa00d Update for open-source Decimal fixes (#16)
* Update to future-proof usage of Decimal.significand

* Update all remaining uses of Decimal.significand

* Update usage of `Decimal(sign:exponent:significand:)`

* Apply suggestions from code review

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

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-01-04 16:24:20 +00:00
Cory Benfield 27e163f96a Rename a number of types and modules. (#13)
Motivation:

In general we should try to be specific about what we're referring to.
"Structured headers" is not really an accurate description of what this
module works with: "Structured Header Field Values", or "Structured
Field Value" is usually better. To that end this change adjusts our
naming to be closer to what we want. It also changes our module names to
prioritise the use of the Codable-based one.

Modifications:

- Renamed CodableStructuredHeaders to StructuredFieldValues.
- Renamed StructuredHeaders to RawStructuredFieldValues.
- Renamed a number of types from Field to FieldValue.
- Renamed a number of types from Header to Field or FieldValue.
- Renamed some functions along the above lines.

Result:

Better and more consistent terminology will be used.
2021-07-02 11:48:41 +01:00
Cory Benfield 4b5603c912 Structured Fields is RFC 8941 now! (#10) 2021-02-09 17:55:55 +00:00
tomer doron dd9aca3533 fix formatting so that sanity script passes (#7)
* fix formatting so that sanity script passes

motivation: consistent formatting as prep for OSS

changes: run swiftformat to align formatting

* dont use TSAN on 18.04
2021-01-15 08:11:21 +00:00
Cory Benfield b2ea94c173 Remove unnecessary genericism and generic constraints.
Motivation:

Early on in the design of Structured Headers I made a conscious effort
to try to avoid transforming types in the low-level API. This design was
built on the assumption that strings, tokens, and some other data types
could be built entirely as slices of the backing data.

Unfortunately, this isn't true: because of the need to escape chars in
Strings, it became necessary to start using more complex types in Item.
Eventually, we ended up in a place where the only field in Item that
actually stored backing data was `.undecodedByteSequence`.

This field forced almost the entire set of types in the
StructuredHeaders module to be generic, just for the sake of carrying
this one slice type around. This prevented powerful optimisations,
bloated code size, and forced additional unnecessary heap allocations.
It also forced us to constrain the types used in the parser to those
where the subsequence type was Hashable, which excluded some really
important types (like `String.UTF8View`).

Fundamentally, this genericism was hurting more than it helped at this
point, so I bit the bullet and replaced the slice type with `String` for
`undecodedByteSequence`. This led to a huge cascading removal of generic
type parameters for a wide range of types, as well as the removal of the
"must have hashable subsequence" constraints on the parser data type.
This lifts an enormous amount of complexity out of the module at the
extremely minor cost of forcing an allocation whenever we have a lot of
undecoded binary data: not a huge cost, in my view, and well worth what
we got back in return.

Modifications:

- Remove generic type parameter in BaseItem.
- Remove generic types everywhere else.
- Remove hashable constraint.

Result:

Better, faster, simpler code.
2020-08-28 16:42:42 +01:00
Cory Benfield 246d886cf7 Use a higher-level protocol for encoding/decoding.
Motivation:

Right now we disambiguate the multiple top-level SH types by using three
separate entry points on the encoder/decoder. This isn't great: it
forces that information to be known statically at compile time, making
it much harder to write generic APIs that use structured header fields.

Modifications:

- Provide a new protocol, `StructuredHeaderField`, that must be used for
  the top-level `Codable` object.
- Provide `StructuredHeaderFieldType` to communicate the types of
  structured header fields.
- Remove the multiple entry points.
- Update the tests.

Result:

Types will encode what kind of structured header field they are.
2020-07-27 08:07:46 +01:00
Cory Benfield 101dec0a99 Introduce StructuredHeaderField protocol.
Motivation:

We had a proliferation of decode/encode methods that required users to
tell us how to encode their structured header field. This is a bit
annoying for two reasons: firstly, it requires users to encode this
piece of information separately from their header field; secondly, it
makes it very hard to offer a generic interface to load something as a
structured header field!

Modifications:

- Add a new StructuredHeaderField protocol that refines Codable and
  expresses what type of header field is used.
- Remove the fancy encode/decode methods.

Result:

Simpler interfaces.
2020-07-24 17:44:06 +01:00
Cory Benfield 6a2b13e370 Fix the build on Linux
Motivation:

A number of the changes in the code for running on Linux
were not validated ahead of time, and broke the build.

Modifications:

- Correct the spelling of Glibc
- Modified string initialization on non-Darwin platforms

Results:

Builds and passes tests on Linux
2020-07-20 12:44:21 +01:00
Cory Benfield 3f73125a0d Apply formatting 2020-07-17 10:06:44 +01:00
Cory Benfield 141f102bd0 Support Decimal as well 2020-07-16 17:28:47 +01:00
Cory Benfield e12def54da Add docs and license 2020-07-16 16:34:38 +01:00
Cory Benfield b797a6ff50 Add support for encoding/decoding binary data 2020-07-16 13:16:20 +01:00
Cory Benfield 5aaca631da Split Codable to its own module 2020-07-16 11:22:30 +01:00
Cory Benfield 8cd792800c Remove foundation from core 2020-07-16 10:55:55 +01:00
Cory Benfield 31a8b1658f Define simple example CLI tool 2020-07-16 10:25:52 +01:00
Cory Benfield ea7969a4c6 Support Encoder 2020-07-15 16:20:26 +01:00
Cory Benfield 882cb88c87 Make dictionary/parameter keys strings too 2020-07-10 14:11:36 +01:00
Cory Benfield f07f69282d Make tokens strings (it's easier) 2020-07-10 13:49:05 +01:00
Cory Benfield cf08d29cb0 Implement the Serializer. 2020-07-09 14:53:15 +01:00
Cory Benfield e6e0c68caf Additional testing 2020-07-05 17:11:02 +01:00
Cory Benfield 49370cd8db Initial basic Decoder implementation 2020-07-05 13:21:16 +01:00
Cory Benfield 68a2409ef9 Remove duplicate character checks 2020-07-01 17:01:07 +01:00
Cory Benfield 03fa905bed Initial Structured Headers decoder. 2020-07-01 16:41:52 +01:00
Cory Benfield fa8c1e771c Initial commit 2020-06-19 17:17:12 +01:00