Skip to content

SSE client: add Linux support via URLSession delegate streaming#63

Merged
odrobnik merged 2 commits intomainfrom
feature/linux-sse-client
Mar 6, 2026
Merged

SSE client: add Linux support via URLSession delegate streaming#63
odrobnik merged 2 commits intomainfrom
feature/linux-sse-client

Conversation

@odrobnik
Copy link
Contributor

@odrobnik odrobnik commented Mar 6, 2026

On Linux, URLSession.bytes(for:) is unavailable in FoundationNetworking. This adds a URLSessionDataDelegate-based streaming approach that feeds received bytes into an AsyncStream<String> of lines, plugging into the existing SSEMessageSequence parser.

Changes:

  • New SSEStreamingDelegate — collects incoming data, splits on newlines, emits lines via AsyncStream
  • connectSSELinux() — uses dataTask + delegate instead of session.bytes(for:)
  • connectSSEApple() — extracted existing Apple path (unchanged logic)
  • Shared helpers: handleSSEResponse(), waitForEndpointIfNeeded()
  • Removes the unsupportedPlatform error for SSE on Linux

Resolves the Linux SSE client gap.

odrobnik added 2 commits March 6, 2026 11:57
On Linux, URLSession.bytes(for:) is unavailable (FoundationNetworking).
Instead, use a URLSessionDataDelegate (SSEStreamingDelegate) that feeds
received bytes into an AsyncStream<String> of lines, which plugs into
the existing SSEMessageSequence parser.

Also refactored the SSE connect path:
- Extracted connectSSEApple() and connectSSELinux() from the inline block
- Shared helpers: handleSSEResponse(), waitForEndpointIfNeeded()
- Removed the #if os(Linux) throw unsupportedPlatform guard
@odrobnik odrobnik merged commit 17812b6 into main Mar 6, 2026
5 of 6 checks passed
@odrobnik odrobnik deleted the feature/linux-sse-client branch March 6, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant