Skip to content

Commit 3917031

Browse files
Change type of HTTPBody.Length.known from Int to Int64 (#79)
### Motivation The associated value of enum case `HTTPBody.Length.known` was `Int`, and, on watchOS, `Int = Int32`, which is not ideal for a content length. ### Modifications - (API breaking) Change type of HTTPBody.Length.known from Int to Int64. ### Result Can now express larger values for content type on 32-bit platforms. ### Test Plan Unit tests pass. ### Related Issues - Fixes apple/swift-openapi-generator#354. ### Note I have marked this PR as `semver/major` as it constitutes the first of the PRs we make in the run up to 1.0.0-alpha.1 and the release notes generator should therefore catch us from inadvertently cutting another pre-1.0 patch release.
1 parent bb2d2b3 commit 3917031

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/OpenAPIRuntime/Interface/HTTPBody.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@ public final class HTTPBody: @unchecked Sendable {
125125
/// the input sequence can be iterated.
126126
public let iterationBehavior: OpenAPIRuntime.IterationBehavior
127127

128-
/// Describes the total length of the body, if known.
128+
/// Describes the total length of the body, in bytes, if known.
129129
public enum Length: Sendable, Equatable {
130130

131131
/// Total length not known yet.
132132
case unknown
133133

134134
/// Total length is known.
135-
case known(Int)
135+
case known(Int64)
136136
}
137137

138-
/// The total length of the body, if known.
138+
/// The total length of the body, in bytes, if known.
139139
public let length: Length
140140

141141
/// The underlying type-erased async sequence.
@@ -257,7 +257,7 @@ extension HTTPBody {
257257
/// Creates a new body with the provided byte chunk.
258258
/// - Parameter bytes: A byte chunk.
259259
@inlinable public convenience init(_ bytes: ByteChunk) {
260-
self.init([bytes], length: .known(bytes.count), iterationBehavior: .multiple)
260+
self.init([bytes], length: .known(Int64(bytes.count)), iterationBehavior: .multiple)
261261
}
262262

263263
/// Creates a new body with the provided byte sequence.
@@ -283,7 +283,7 @@ extension HTTPBody {
283283
/// Creates a new body with the provided byte collection.
284284
/// - Parameter bytes: A byte chunk.
285285
@inlinable public convenience init(_ bytes: some Collection<UInt8> & Sendable) {
286-
self.init(bytes, length: .known(bytes.count))
286+
self.init(bytes, length: .known(Int64(bytes.count)))
287287
}
288288

289289
/// Creates a new body with the provided async throwing stream.

Sources/OpenAPIRuntime/Multipart/MultipartFramesToRawPartsSequence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ extension HTTPBody {
7777
let stream = AsyncThrowingStream(unfolding: bodyClosure)
7878
let length: HTTPBody.Length
7979
if let contentLengthString = headerFields[.contentLength], let contentLength = Int(contentLengthString) {
80-
length = .known(contentLength)
80+
length = .known(Int64(contentLength))
8181
} else {
8282
length = .unknown
8383
}

0 commit comments

Comments
 (0)