Skip to content

Feature/intercept custom sessions - #6

Merged
Rev0212 merged 3 commits into
mainfrom
feature/intercept-custom-sessions
Sep 10, 2026
Merged

Rev0212 merged 3 commits into
mainfrom
feature/intercept-custom-sessions

Conversation

@Rev0212

@Rev0212 Rev0212 commented Sep 10, 2026

Copy link
Copy Markdown
Owner

No description provided.

Revanth and others added 3 commits September 10, 2026 11:15
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Merge pull request #4 from Rev0212/feature/intercept-custom-sessions
Copilot AI lite review requested due to automatic review settings September 10, 2026 12:47
@Rev0212
Rev0212 merged commit 20553c0 into main Sep 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The forwarding session sets protocolClasses to an empty array, which can disable request loading by removing the default protocol stack.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR extends NetworkInspector’s interception coverage to URLSessions created from their own URLSessionConfiguration (e.g., third-party SDKs) by injecting InspectorURLProtocol into freshly created default/ephemeral configurations via class-method swizzling.

Changes:

  • Swizzles URLSessionConfiguration.default and .ephemeral factory getters to ensure returned configurations include InspectorURLProtocol.
  • Updates InspectorURLProtocol’s internal forwarding session configuration to avoid self-interception.
  • Adds tests to verify protocol injection and idempotent installation.
File summaries
File Description
Tests/NetworkInspectorTests/NetworkInspectorTests.swift Adds tests asserting injected protocol classes and idempotent swizzle installation.
Sources/NetworkInspector/URLSessionConfigurationSwizzle.swift Implements thread-safe, once-only swizzle of default/ephemeral factory getters to seed protocolClasses.
Sources/NetworkInspector/InspectorURLProtocol.swift Adjusts the forwarding session configuration to avoid replay loops after the new injection behavior.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +21 to +24
// `default` is swizzled to seed InspectorURLProtocol; leaving it in place here would point
// this forwarding session back at ourselves. The handled-request flag already breaks that
// loop, but keeping it off the replay session means we never rely on it.
config.protocolClasses = []
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.

2 participants