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
}
-
Errors that occur while parsing a Shalon URL.
See moreDeclaration
Swift
enum ParseError : Error -
An internal struct that keeps parameters, which will be used for establishing a connection via Shalon proxies.
See moreDeclaration
Swift
struct Parameters -
This indicates if loading should stop.
Declaration
Swift
private var loadingShouldStop: Bool -
Parse a URL and return parameters that can be used for
Shalon.Throws
Throws if there are not enough proxies specified. The amount of proxies is determined by the amount of
s‘ in the URL schema. Throws also if a proxy is invalid, e.g., with an invalid hostname.Declaration
Swift
static func parseShalonParams(from url: URL) throws -> Parameters?Parameters
urlThe URL.
Return Value
Shalon parameters,
nilif the URL does not match the specified format.
-
Implementation of the
URLProtocol.See
Declaration
Swift
override public class func canInit(with request: URLRequest) -> BoolParameters
requestA request.
-
Implementation of the
URLProtocol.Declaration
Swift
override public class func canInit(with task: URLSessionTask) -> BoolParameters
requestA task.
-
Implementation of the
URLProtocol.Declaration
Swift
override public class func canonicalRequest(for request: URLRequest) -> URLRequestParameters
requestA 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()
View on GitHub
ShalonURLProtocol Class Reference