Skip to content

Commit c40e632

Browse files
committed
Remove HTTP Networking.
- URLRequest Extensions have been left. - This package no longer depends on SWCompression. - HTTP Networking API consumers should move to [CornucopiaHTTP](https://github.com/Cornucopia-Swift/CornucopiaHTTP)
1 parent f3cb498 commit c40e632

File tree

12 files changed

+13
-841
lines changed

12 files changed

+13
-841
lines changed

CLAUDE.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ The project targets Swift 5.10+ and has continuous integration via GitHub Action
1818

1919
## Dependencies
2020

21-
The project has three external dependencies:
21+
The project has two external dependencies:
2222
- `swift-crypto` (3.0.0+): Apple's cryptographic library
23-
- `SWCompression` (4.8.5+): Compression utilities
2423
- `AnyCodable` (0.6.6+): Type-erased Codable support (re-exported at module level)
2524

2625
## Code Architecture
@@ -62,10 +61,6 @@ All public APIs are nested under `Cornucopia.Core` namespace. The main entry poi
6261
- `ExtendedFileAttributes`: File metadata handling
6362
- Storage backend protocol for pluggable backends
6463

65-
6. **Networking** (`Networking/`): HTTP utilities
66-
- HTTP constants and status codes
67-
- Networking helper functions
68-
6964
### Naming Conventions
7065

7166
- Public extension methods use `CC_` prefix
@@ -95,4 +90,4 @@ Tests mirror the source structure under `Tests/CornucopiaCoreTests/` and cover:
9590
- Extensions are organized by the type they extend
9691
- Comprehensive `#if` conditions ensure cross-platform compatibility
9792
- Property wrappers follow Codable protocols where applicable
98-
- Logger uses background queue for thread safety
93+
- Logger uses background queue for thread safety

Docs/PerformanceNotes.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
Summary of November 2024 audit focusing on Swift’s resilience and ownership features.
44

55
### Current Status
6-
- `LogLevel`, `LogEntry`, `HTTPStatusCode`, `HTTPMethod` (+ nested enums), `HTTPResponse`, `HTTPRequestResponse`, `HTTPHeaderField`, `HTTPContentType`, `AnyValue` (+ `Error`), `RollingTimestamp` (+ `Mode`), `Parity`, `SysLogEntry` (+ nested enums), `JWT`, `AsyncWithTimeoutError`, `Environment`, `HexColor`, `RegularExpression`, and the stream `Exception` enums are now annotated `@frozen`. This removes the resilience cost when they’re consumed outside the defining module.
6+
- `LogLevel`, `LogEntry`, `AnyValue` (+ `Error`), `RollingTimestamp` (+ `Mode`), `Parity`, `SysLogEntry` (+ nested enums), `JWT`, `AsyncWithTimeoutError`, `Environment`, `HexColor`, `RegularExpression`, and the stream `Exception` enums are now annotated `@frozen`. This removes the resilience cost when they’re consumed outside the defining module.
77

88
### `@frozen` Candidates
99
- `Sources/CornucopiaCore/Logging/LogSink.swift:19``LogLevel` exposes a closed set of cases that map to syslog levels. Freezing lets downstream code exhaustively switch without runtime thunks; `LogEntry` (line 40) benefits similarly thanks to its immutable payload.
1010
- `Sources/CornucopiaCore/Extensions/OutputStream/OutputStream+ThrowingWrite.swift:8` and `Extensions/InputStream/InputStream+ThrowingRead.swift:8``Exception` enums cover the entire error surface (`unknown`/`eof`). Marking them frozen removes existential overhead when catching or comparing errors.
1111
- `Sources/CornucopiaCore/Types/RollingTimestamp.swift:12``RollingTimestamp.Mode` is a simple two-case enum (`absolute`/`relative`); freezing eliminates resilient-switch indirection.
1212
- `Sources/CornucopiaCore/Types/AnyValue.swift:54``AnyValue.Error` has fixed cases (`typeMismatch`, `outOfBounds`). Freezing enables better inlining for heavy generic call sites.
13-
- `Sources/CornucopiaCore/Networking/HTTPStatusCodes.swift:7``HTTPStatusCode` and nested `ResponseType` mirror the IANA registry and already enumerate all supported codes. `Networking/HTTPConstants.swift:19/29` (`HTTPMethod.WebDAV` / `.RTSP`) fall in the same bucket.
1413
- `Sources/CornucopiaCore/Features/PKCS12/PKCS12.swift:12` – the `Error` enum encapsulates every exit path from `SecPKCS12Import`. Freezing ensures exhaustive pattern matching stays ABI-stable.
1514

1615
Before tagging additional structs (e.g., the various loggers or JWT records), double-check whether you might need to add stored properties later; freezing locks their layout.

Package.resolved

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ let package = Package(
1919
dependencies: [
2020
.package(url: "https://github.com/mickeyl/FoundationBandAid", branch: "master"),
2121
.package(url: "https://github.com/apple/swift-crypto", .upToNextMajor(from: "3.11.0")),
22-
.package(url: "https://github.com/tsolomko/SWCompression", .upToNextMajor(from: "4.8.6")),
2322
// NOTE: When upgrading to Swift 6, move to zmian's fork @ https://github.com/zmian/AnyCodable
2423
.package(url: "https://github.com/mickeyl/AnyCodable", .upToNextMajor(from: "0.6.6")),
2524

@@ -30,7 +29,6 @@ let package = Package(
3029
dependencies: [
3130
.product(name: "FoundationBandAid", package: "FoundationBandAid", condition: .when(platforms: [.linux])),
3231
.product(name: "Crypto", package: "swift-crypto"),
33-
.product(name: "SWCompression", package: "SWCompression"),
3432
"AnyCodable",
3533
]
3634
),

README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Powerful extensions to Foundation and platform types:
1818
- **Array & Collection**: Dictionary conversion, hex operations, chunked sequences
1919
- **Date & Time**: Pretty printing, past/present/future checks, ISO8601 formatting
2020
- **FileManager**: Compression, path utilities, extended attributes
21-
- **Networking**: HTTP utilities, URL request enhancements, status codes
2221
- **And many more**: All extensions use the `CC_` prefix to avoid naming conflicts
2322

2423
### 📊 Data Structures
@@ -60,12 +59,8 @@ Modern async/await utilities and performance tools:
6059
- **AsyncWithTimeout**: Timeout support for async operations
6160
- **Benchmarking**: Performance measurement utilities
6261
- **Task**: Sleep utilities for async contexts
63-
64-
### 🌐 Networking
65-
HTTP utilities and networking helpers:
66-
- **HTTPConstants**: Standard status codes and headers
67-
- **URL extensions**: String interpolation, path utilities
68-
- **URLRequest**: Authorization headers, range requests
62+
63+
For higher-level HTTP networking, use the dedicated sibling package [CornucopiaHTTP](../CornucopiaHTTP).
6964

7065
## Installation
7166

@@ -214,7 +209,6 @@ print("Operation took: \(duration) seconds")
214209

215210
CornucopiaCore has minimal external dependencies:
216211
- [swift-crypto](https://github.com/apple/swift-crypto): Apple's cryptographic library
217-
- [SWCompression](https://github.com/tsolomko/SWCompression): Compression utilities
218212
- [AnyCodable](https://github.com/mickeyl/AnyCodable): Type-erased Codable support
219213

220214
## Architecture
@@ -226,7 +220,6 @@ All public APIs are organized under the `Cornucopia.Core` namespace to avoid nam
226220
- **Logging/**: Flexible logging system
227221
- **PropertyWrappers/**: Utility property wrappers
228222
- **Storage/**: Data persistence abstractions
229-
- **Networking/**: HTTP utilities and helpers
230223

231224
## Contributing
232225

Sources/CornucopiaCore/Extensions/HTTPURLResponse/HTTPURLResponse+Extensions.swift

Lines changed: 0 additions & 26 deletions
This file was deleted.

Sources/CornucopiaCore/Extensions/URLRequest/URLRequest+Authorization.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import FoundationNetworking
99

1010
fileprivate let AuthorizationBasicToken = "Basic "
1111
fileprivate let AuthorizationBearerToken = "Bearer "
12+
fileprivate let AuthorizationHeaderField = "Authorization"
1213

1314
public extension URLRequest {
1415

@@ -19,16 +20,16 @@ public extension URLRequest {
1920
return
2021
}
2122
let base64 = data.base64EncodedString()
22-
setValue(AuthorizationBasicToken + base64, forHTTPHeaderField: Cornucopia.Core.HTTPHeaderField.authorization.rawValue)
23+
setValue(AuthorizationBasicToken + base64, forHTTPHeaderField: AuthorizationHeaderField)
2324
}
2425

2526
/// Add HTTP Bearer authorization header. `base64` MUST be a base64-encoded string.
2627
mutating func CC_setBearerAuthorizationHeader(base64: String) {
27-
setValue(AuthorizationBearerToken + base64, forHTTPHeaderField: Cornucopia.Core.HTTPHeaderField.authorization.rawValue)
28+
setValue(AuthorizationBearerToken + base64, forHTTPHeaderField: AuthorizationHeaderField)
2829
}
2930

3031
/// Add JWT authorization token.
3132
mutating func CC_setBearerAuthorizationHeader(token: Cornucopia.Core.JWT.Token<Cornucopia.Core.JWT.Payload>) {
32-
setValue(AuthorizationBearerToken + token.base64, forHTTPHeaderField: Cornucopia.Core.HTTPHeaderField.authorization.rawValue)
33+
setValue(AuthorizationBearerToken + token.base64, forHTTPHeaderField: AuthorizationHeaderField)
3334
}
3435
}

Sources/CornucopiaCore/Extensions/URLRequest/URLRequest+Range.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,25 @@ import FoundationNetworking
99

1010
// Valid range values include: bytes=200-1000, 2000-6576, 19000-
1111
fileprivate let RangeBytesToken = "bytes="
12+
fileprivate let RangeHeaderField = "Range"
1213

1314
public extension URLRequest {
1415

1516
/// Add HTTP Range header using the specified range.
1617
mutating func CC_setRangeHeader(range: ClosedRange<Int>) {
1718
let value = "\(RangeBytesToken)\(range.lowerBound)-\(range.upperBound)"
18-
setValue(value, forHTTPHeaderField: Cornucopia.Core.HTTPHeaderField.range.rawValue)
19+
setValue(value, forHTTPHeaderField: RangeHeaderField)
1920
}
2021

2122
/// Add HTTP Range header using the specified range.
2223
mutating func CC_setRangeHeader(range: PartialRangeFrom<Int>) {
2324
let value = "\(RangeBytesToken)\(range.lowerBound)-"
24-
setValue(value, forHTTPHeaderField: Cornucopia.Core.HTTPHeaderField.range.rawValue)
25+
setValue(value, forHTTPHeaderField: RangeHeaderField)
2526
}
2627

2728
/// Add HTTP Range header using the specified range.
2829
mutating func CC_setRangeHeader(range: PartialRangeThrough<Int>) {
2930
let value = "\(RangeBytesToken)0-\(range.upperBound)"
30-
setValue(value, forHTTPHeaderField: Cornucopia.Core.HTTPHeaderField.range.rawValue)
31+
setValue(value, forHTTPHeaderField: RangeHeaderField)
3132
}
3233
}

Sources/CornucopiaCore/Networking/HTTPConstants.swift

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)