feat: add streaming HTTP client target - #16515
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
6871de1 to
c615f41
Compare
Summary of ChangesThis pull request introduces a new streaming HTTP client to the repository, designed to handle asynchronous data streams efficiently. By leveraging URLSession and modern Swift concurrency, the implementation provides a clean API for consuming byte streams and line-delimited text. The changes also include necessary infrastructure for robust testing, ensuring reliability in network communication and data parsing. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Activity
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new HTTPStreamingClient package for streaming bytes and lines of text using URLSession, complete with integration and unit tests. The review feedback identifies a platform compatibility issue where AsyncThrowingStream.makeStream() is used despite targeting older OS versions (iOS 15 and macOS 12). Additionally, the reviewer points out that the underlying network tasks are not cancelled if the consuming task is cancelled during stream iteration, recommending that the task be passed down to the iterators to support cooperative cancellation. Finally, a performance optimization is suggested for HTTPLineDecoder to avoid inefficient byte-by-byte iteration on large streaming payloads.
Add a lightweight HTTP client backed by URLSession that supports asynchronous byte and text line streaming. Key additions: - Introduce `HTTPStreamingClient` with `bytes(for:)` streaming API. - Provide `HTTPAsyncBytes` and `HTTPAsyncLineSequence` mirroring standard `URLSession.AsyncBytes` ergonomics. - Implement incremental UTF-8 line decoding supporting CRLF, LF, CR, and split multi-byte unicode characters across chunk boundaries. - Adopt Swift 6 strict concurrency with compiler-checked `Sendable` types and synchronous lock-based delegate task management. - Provide package-visible `MockHTTPURLProtocol` test transport adapter. - Add comprehensive unit test suite in `HTTPStreamingClientTests`.
c615f41 to
a13a909
Compare
Add a lightweight HTTP client backed by URLSession that supports asynchronous byte and text line streaming.
HTTPStreamingClientwithbytes(for:)streaming API.HTTPAsyncBytesandHTTPAsyncLineSequencemirroring standardURLSession.AsyncBytesergonomics.Sendabletypes and actor-coordinated task delegate management.HTTPStreamingClientTests.