Set request attribution to user
This commit is contained in:
parent
13462d2307
commit
8c53685d21
|
@ -201,6 +201,9 @@ class BrowserWebViewController: UIViewController {
|
|||
}
|
||||
}
|
||||
}
|
||||
if #available(iOS 15.0, *) {
|
||||
task!.attribution = .user
|
||||
}
|
||||
task!.resume()
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,17 @@ public class GeminiDataTask {
|
|||
private let completion: Completion
|
||||
private var state = State.unstarted
|
||||
private let connection: NWConnection
|
||||
// todo: remove stupid hack when deployment target is >= iOS 15/macOS 12
|
||||
private var _attribution: Any? = nil
|
||||
@available(iOS 15.0, *)
|
||||
public var attribution: NWParameters.Attribution {
|
||||
get {
|
||||
_attribution as? NWParameters.Attribution ?? .developer
|
||||
}
|
||||
set {
|
||||
_attribution = newValue
|
||||
}
|
||||
}
|
||||
|
||||
public init(request: GeminiRequest, completion: @escaping Completion) {
|
||||
self.request = request
|
||||
|
@ -25,6 +36,10 @@ public class GeminiDataTask {
|
|||
let endpoint: NWEndpoint = .hostPort(host: NWEndpoint.Host(request.url.host!), port: NWEndpoint.Port(rawValue: port)!)
|
||||
self.connection = NWConnection(to: endpoint, using: .gemini)
|
||||
|
||||
if #available(iOS 15.0, *) {
|
||||
connection.parameters.attribution = attribution
|
||||
}
|
||||
|
||||
self.connection.stateUpdateHandler = { (newState) in
|
||||
switch newState {
|
||||
case .ready:
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
import Network
|
||||
|
||||
extension NWParameters {
|
||||
/// An NWParameters configured with the GeminiProtocol and appropriate TLS options.
|
||||
/// This property always returns a new NWParameters instance.
|
||||
static var gemini: NWParameters {
|
||||
let tlsOptions = geminiTLSOptions
|
||||
let tcpOptions = NWProtocolTCP.Options()
|
||||
|
|
Loading…
Reference in New Issue