Skip to content

Feature: Let user configure/provide session for passthrough networking#11

Merged
bstien merged 6 commits intomainfrom
feature/configure-passthrough-session
Sep 13, 2025
Merged

Feature: Let user configure/provide session for passthrough networking#11
bstien merged 6 commits intomainfrom
feature/configure-passthrough-session

Conversation

@bstien
Copy link
Owner

@bstien bstien commented Sep 13, 2025

Why?

Currently we're using a static/hardcoded URLSession for passthrough networking. Configuring this session should be allowed by the user, if they need to customize the URLSessionConfiguration.

This PR allows for each HTTPMock instance to have their own URLSession for passthrough networking.

What?

  • Move passthroughSession to HTTPMock.
  • Add methods to set/get sessions on HTTPMockURLProtocol.
  • Add tests.
  • Update README.

Show me

// Create a custom configuration for passthrough requests
let configuration = URLSessionConfiguration.default
let passthroughSession = URLSession(configuration: configuration)

// Pass it when creating HTTPMock instance
let httpMock = HTTPMock(passthroughSession: passthroughSession)
httpMock.unmockedPolicy = .passthrough

// Any unmocked requests will be sent via the provided `passthroughSession`

@bstien bstien merged commit 567a970 into main Sep 13, 2025
1 check passed
@bstien bstien deleted the feature/configure-passthrough-session branch September 13, 2025 18:46
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