ZitiUrlProtocol
@objc
public class ZitiUrlProtocol : URLProtocol, ZitiUnretained
URLProtocol
that intercepts HTTP
and HTTPS
URL requests and routes them over the Ziti overlay as configured in your Ziti controller.
ZitiUrlProtocol
should be instantiated as part of the InitCallback
of Ziti.run(_:_:)
to ensure Ziti is initialized before starting to intercept services.
-
Registers this protocol via
URLProtocol.registerClass
and subscribes for service intercept updates fromZiti
.This metod should be called during the
InitCallback
ofZiti
run(_:)
to ensureZiti
is initialized before starting to intercept services.Note that in some cases
ZitiUrlProtocol
will need to be configured in yourURLSession
‘s configuration ala:let configuration = URLSessionConfiguration.default configuration.protocolClasses?.insert(ZitiUrlProtocol.self, at: 0) urlSession = URLSession(configuration:configuration)
Declaration
Swift
@objc public class func register(_ ziti: Ziti, _ idleTime: Int = 10000)
Parameters
ziti
The
Ziti
instance we are using to route intercepted URL trafficidleTime
Time, in miliiseconds, client attempts to keep-alive an idle connection before allowing it to close. Default=10000
-
Determines whether Ziti is configured to handle the specified request.
Declaration
Swift
public override class func canInit(with request: URLRequest) -> Bool
Parameters
request
The request to be handled
Return Value
true if the request will be routed over Ziti, otherwise false
-
Returns a canonical version of the specified request.
Declaration
Swift
public override class func canonicalRequest(for request: URLRequest) -> URLRequest
Parameters
request
The request whose canonical version is desired.
Return Value
The canonical form of request.
-
Starts loading the request
Declaration
Swift
public override func startLoading()
-
Stops loading of the request
Declaration
Swift
public override func stopLoading()