- Notifications
You must be signed in to change notification settings - Fork136
Two handy extensions to work with HTTPClientResponse body#736
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Lukasa left a comment
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.
Generally these look really good! Can you add a couple of tests for them as well?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
makoni commentedAug 8, 2025
It's been a while but I updated it :) |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| /// - Parameter maxBytes: The maximum number of bytes this method is allowed to accumulate. | ||
| /// - Returns: Bytes collected over time | ||
| publicfunc bytes(upTo maxBytes:Int)asyncthrows->ByteBuffer{ | ||
| letexpectedBytes=self.headers.first(name:"content-length").flatMap(Int.init)?? maxBytes |
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 should always usemaxBytes and never the value fromcontent-length.
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.
Done
Co-authored-by: Cory Benfield <lukasa@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
Uh oh!
There was an error while loading.Please reload this page.
Two extensions for
HTTPClientResponseto avoid boilerplate code.Reading a response data currently:
With the extension:
Additionally an extension for
bytes. Currently:With the extension: