ShalonURLProtocol
public class ShalonURLProtocol : URLProtocol
A URLProtocol
that adds support for Shalon by specifying URLs in the following format:
httpss://proxy:port/target:port/index.html
. To use more than one proxy
(up to three), e.g., use httpssss://proxy1/proxy2/proxy3/target/index.html
for connecting via three proxies.
In order to support the protocol, it needs to be added to the
URLSessionConfiguration
first:
let configuration = URLSessionConfiguration.ephemeral
configuration.protocolClasses?.append(ShalonURLProtocol.self)
Examples
let configuration = URLSessionConfiguration.ephemeral
configuration.protocolClasses?.append(ShalonURLProtocol.self)
let session = URLSession(configuration: configuration)
let url = URL(string: "httpss://shalon1.jondonym.net/example.com/")!
let task = session.dataTask(with: url) {
optionalUrl, optionalResponse, optionalError in
// Handle response
}
-
Implementation of the
URLProtocol
.See
Declaration
Swift
override public class func canInit(with request: URLRequest) -> Bool
Parameters
request
A request.
-
Implementation of the
URLProtocol
.Declaration
Swift
override public class func canInit(with task: URLSessionTask) -> Bool
Parameters
request
A task.
-
Implementation of the
URLProtocol
.Declaration
Swift
override public class func canonicalRequest(for request: URLRequest) -> URLRequest
Parameters
request
A request.
-
Implementation of the
URLProtocol
.See
startLoading()
Declaration
Swift
override public func startLoading()
-
Implementation of the
URLProtocol
.See
stopLoading()
Declaration
Swift
override public func stopLoading()