-
Notifications
You must be signed in to change notification settings - Fork 128
Collect function fix #672
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
Collect function fix #672
Changes from 2 commits
668b33a
6276e51
104eff5
2ad4a6b
e919181
df627a5
8156844
9b63815
e8d8f85
0de9e27
045a063
9dc6f33
ecbcd90
ae17940
483a3f2
14cfdd4
e60d65b
2fbef23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,15 @@ extension HTTPClientResponse { | |
@inlinable public func makeAsyncIterator() -> AsyncIterator { | ||
.init(storage: self.storage.makeAsyncIterator()) | ||
} | ||
|
||
/// Accumulates an ``Swift/AsyncSequence`` of ``ByteBuffer``s into a single ``ByteBuffer``. | ||
/// - Parameters: | ||
/// - maxBytes: The maximum number of bytes this method is allowed to accumulate | ||
/// - Throws: `NIOTooManyBytesError` if the the sequence contains more than `maxBytes`. | ||
/// - Returns: the number of bytes collected over time | ||
func collect(maxBytes: Int) async throws -> ByteBuffer { | ||
return try await self.collect(upTo: maxBytes) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the response head already announces the body size we can check that size before downloading anything. This is e.g. the case if the response contains a Be careful though, there are edge cases where we don't expect a body even if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think this is appropriate for helper functions to check the |
||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can be clearer here: this accumulates
Body
.