diff --git a/Sources/Rainmaker/Requests/Requesting.swift b/Sources/Rainmaker/Requests/Requesting.swift index 4fb3ead..2d44707 100644 --- a/Sources/Rainmaker/Requests/Requesting.swift +++ b/Sources/Rainmaker/Requests/Requesting.swift @@ -6,7 +6,7 @@ import Foundation /// /// Features of `URLSession` defined as a mockable protocol for tests. /// -protocol Requesting: Sendable { +public protocol Requesting: Sendable { func data(for request: URLRequest) async throws -> (Data, URLResponse) func download(for request: URLRequest, delegate: (any URLSessionTaskDelegate)?) async throws -> (URL, URLResponse) } diff --git a/Sources/Rainmaker/Server.swift b/Sources/Rainmaker/Server.swift index b8bfb6e..e6f8982 100644 --- a/Sources/Rainmaker/Server.swift +++ b/Sources/Rainmaker/Server.swift @@ -330,14 +330,10 @@ public final class Server { /// - address: HTTP address of the Nextcloud host. /// - password: In most cases, this is the app password and not the account password. /// - user: The Nextcloud user name used to identify as. + /// - session: A ``Requesting`` object (e.g. a `URLSession`) to use for network requests. Defaults to a new ephemeral `URLSession`. /// - userAgent: The user agent to report as in HTTP request headers. /// - public convenience init(address: URL, password: String? = nil, user: String? = nil, userAgent: String = "Rainmaker") { - let session = URLSession(configuration: .ephemeral) - self.init(address: address, password: password, user: user, session: session, userAgent: userAgent) - } - - init(address: URL, password: String? = nil, user: String? = nil, session: any Requesting, userAgent: String) { + public init(address: URL, password: String? = nil, user: String? = nil, session: any Requesting = URLSession(configuration: .ephemeral), userAgent: String = "Rainmaker") { self.address = address jsonDecoder = JSONDecoder() self.password = password