Skip to content

Change type of HTTPBody.Length.known from Int to Int64 #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Sources/OpenAPIRuntime/Interface/HTTPBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ public final class HTTPBody: @unchecked Sendable {
/// the input sequence can be iterated.
public let iterationBehavior: OpenAPIRuntime.IterationBehavior

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

/// Total length not known yet.
case unknown

/// Total length is known.
case known(Int)
case known(Int64)
}

/// The total length of the body, if known.
/// The total length of the body, in bytes, if known.
public let length: Length

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

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

/// Creates a new body with the provided async throwing stream.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ extension HTTPBody {
let stream = AsyncThrowingStream(unfolding: bodyClosure)
let length: HTTPBody.Length
if let contentLengthString = headerFields[.contentLength], let contentLength = Int(contentLengthString) {
length = .known(contentLength)
length = .known(Int64(contentLength))
} else {
length = .unknown
}
Expand Down