Skip to content

Forward streaming authentication challenges to URLProtocolClient#14

Open
kikeenrique wants to merge 5 commits into
mattt:mainfrom
kikeenrique:fix/playback-urlprotocol-auth-challenges
Open

Forward streaming authentication challenges to URLProtocolClient#14
kikeenrique wants to merge 5 commits into
mattt:mainfrom
kikeenrique:fix/playback-urlprotocol-auth-challenges

Conversation

@kikeenrique
Copy link
Copy Markdown

This PR was AI assisted.
This fixes authentication challenge handling for Replay’s live/passthrough streaming path.

When PlaybackURLProtocol falls through to the network, it creates an internal URLSession with StreamingDelegate so responses can be streamed incrementally. That delegate previously did not forward URLSessionTask authentication challenges back to the original URLProtocolClient, so callers had no chance to handle credentials, cancellation, trust decisions, or custom auth behavior during streamed requests.

The PR fixes this by:

  • Giving StreamingDelegate a weak reference to the active PlaybackURLProtocol
  • Implementing urlSession(_:task:didReceive:completionHandler:)
  • Rebuilding the challenge with a URLAuthenticationChallengeSender bridge
  • Translating client decisions back into the URLSession completion handler
  • Adding a regression test for challenge forwarding
  • Marking PlaybackTests with .playbackIsolated because the suite touches global URLProtocol / PlaybackStore state

fix: Bridge URLSession authentication challenge callbacks through PlaybackURLProtocol
     so clients can handle trust and credential decisions during streamed live playback requests.
fix: Make the URLProtocolClient test helper explicitly Sendable and use a
  cross-platform authentication method for synthetic challenges.
test: fix. PlaybackTests touches process-wide URLProtocol registration and shared
  PlaybackStore state directly. Use playback isolation in addition to serialized
  execution so these tests cannot race with other suites using .replay(...).
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