Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0859ead

Browse files
Handle large payloads on 32bit platforms gracefully (#29)
Handle large payloads on 32bit platforms gracefully ### Motivation If there's a request payload with a number of bytes that can't fit into 32 bits, we'd crash. ### Modifications Use a graceful initializer and use `.unknown` (so no `content-length` will be sent) if the size exceeds the max of a 32bit int. ### Result No crash for large payloads on 32bit platforms. ### Test Plan Tests pass. Reviewed by: dnadoba Builds: ✔︎ pull request validation (5.10) - Build finished. ✔︎ pull request validation (5.9) - Build finished. ✔︎ pull request validation (nightly) - Build finished. ✔︎ pull request validation (soundness) - Build finished. #29
1 parent f5bf294 commit 0859ead

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ public struct AsyncHTTPClientTransport: ClientTransport {
181181
let length: HTTPClientRequest.Body.Length
182182
switch body.length {
183183
case .unknown: length = .unknown
184-
case .known(let count): length = .known(Int(count))
184+
case .known(let count):
185+
if let intValue = Int(exactly: count) { length = .known(intValue) } else { length = .unknown }
185186
}
186187
clientRequest.body = .stream(body.map { .init(bytes: 0ドル) }, length: length)
187188
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /