diff --git a/Demo/Sources/iOS/Pulse_Demo_iOSApp.swift b/Demo/Sources/iOS/Pulse_Demo_iOSApp.swift index 45ee387d6..db03fcd24 100644 --- a/Demo/Sources/iOS/Pulse_Demo_iOSApp.swift +++ b/Demo/Sources/iOS/Pulse_Demo_iOSApp.swift @@ -22,9 +22,9 @@ struct PulseDemo_iOS: App { private final class AppViewModel: ObservableObject { let log = OSLog(subsystem: "app", category: "AppViewModel") - + init() { -// URLSessionProxyDelegate.enableAutomaticRegistration() +// URLSessionProxyDelegate.enableAutomaticRegistration(logger: NetworkLogger(store: .demo)) // DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) { // sendRequest() // } diff --git a/Sources/Pulse/NetworkLogger/URLSessionMockManager.swift b/Sources/Pulse/NetworkLogger/URLSessionMockManager.swift index c4aca7544..b69d3179d 100644 --- a/Sources/Pulse/NetworkLogger/URLSessionMockManager.swift +++ b/Sources/Pulse/NetworkLogger/URLSessionMockManager.swift @@ -18,17 +18,14 @@ final class URLSessionMockManager: @unchecked Sendable { func getMock(for request: URLRequest) -> URLSessionMock? { lock.lock() defer { lock.unlock() } - - return mocks.lazy.map(\.value).first { - $0.isMatch(request) - } + return _getMock(for: request) } func shouldMock(_ request: URLRequest) -> Bool { lock.lock() defer { lock.unlock() } - guard let mock = getMock(for: request) else { + guard let mock = _getMock(for: request) else { return false } defer { numberOfHandledRequests[mock.mockID, default: 0] += 1 } @@ -42,6 +39,12 @@ final class URLSessionMockManager: @unchecked Sendable { return RemoteLogger.shared.connectionState == .connected } + private func _getMock(for request: URLRequest) -> URLSessionMock? { + mocks.lazy.map(\.value).first { + $0.isMatch(request) + } + } + func update(_ mocks: [URLSessionMock]) { lock.lock() defer { lock.unlock() }