Skip to content

Commit bad39b4

Browse files
authored
Increased maxResponseBytes to avoid NIOTooManyBytesError (#1)
* Increased maxBytes to avoid NIOTooManyBytesError Calling getPrinterAttributes to request "printer-description", "job-template" and "media-col-database" (as per example at https://www.pwg.org/ipp/ippguide.html#querying-the-printer-attributes ) on Simulated InkJet results in an NIOTooManyBytesError. Raised the hardcoded max value to 1 MB instead of 20 KB and made it an optional param. * Renamed maxBytes Renamed maxBytes to maxResponseBytes
1 parent 649f5de commit bad39b4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/IppClient/HttpClient+Ipp.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public extension HTTPClient {
1313
_ request: IppRequest,
1414
authentication: IppAuthentication? = nil,
1515
data: consuming HTTPClientRequest.Body? = nil,
16-
timeout: TimeAmount = .seconds(10)
16+
timeout: TimeAmount = .seconds(10),
17+
maxResponseBytes: Int = 1024 * 1024
1718
) async throws -> IppResponse {
1819
let httpRequest = try HTTPClientRequest(ippRequest: request, authentication: authentication, data: data)
1920
let httpResponse = try await execute(httpRequest, timeout: timeout)
@@ -22,7 +23,7 @@ public extension HTTPClient {
2223
throw IppHttpResponseError(response: httpResponse)
2324
}
2425

25-
var buffer = try await httpResponse.body.collect(upTo: 20 * 1024)
26+
var buffer = try await httpResponse.body.collect(upTo: maxResponseBytes)
2627
return try IppResponse(buffer: &buffer)
2728
}
2829
}

0 commit comments

Comments
 (0)