Skip to content
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
3 changes: 2 additions & 1 deletion Sources/AsyncHTTPClient/HTTPHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ public final class ResponseAccumulator: HTTPClientResponseDelegate {
let requestMethod: HTTPMethod
let requestHost: String

static let maxByteBufferSize = Int(UInt32.max)
// This is either UInt32.max, or Int.max on platforms where that value is smaller.
static let maxByteBufferSize = Int(exactly: UInt32.max) ?? Int(Int32.max)

/// Maximum size in bytes of the HTTP response body that ``ResponseAccumulator`` will accept
/// until it will abort the request and throw an ``ResponseTooBigError``.
Expand Down
10 changes: 10 additions & 0 deletions Tests/AsyncHTTPClientTests/HTTP1ClientChannelHandlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,16 @@ class HTTP1ClientChannelHandlerTests: XCTestCase {
]
)
}

func testDefaultMaxBufferSize() {
if MemoryLayout<Int>.size == 8 {
XCTAssertEqual(ResponseAccumulator.maxByteBufferSize, Int(UInt32.max))
} else if MemoryLayout<Int>.size == 4 {
XCTAssertEqual(ResponseAccumulator.maxByteBufferSize, Int(Int32.max))
} else {
XCTFail("What platform is this?")
}
}
}

final class TestBackpressureWriter: Sendable {
Expand Down
Loading