HTTPClient
public class HTTPClient : NetworkClient
An HTTP client that sends URLRequests via a URLSession.
URLRequests are sent as is and are retried according to the RequestInterceptors logic when necessary.
RequestInterceptors are also notified of other events concerning the request lifecycle.
Some of these events are related to the HTTPClient logic and some are just URLSessionDelegate events being forwarded.
You should almost never create a new instance of this class but rather use the shared instance,
as it’s configured with sensible defaults and using one URLSession comes with a series of optimizations.
If you need to create a new instance make sure to start from a default configuration and only add new interceptors to the default ones.
-
The shared instance created with the default configuration
Declaration
Swift
public static let shared: HTTPClient -
Creates and returns a new client.
Declaration
Swift
convenience public init(configuration: NetworkConfiguration = .default, logger: LoggerProtocol?)Parameters
configurationthe
NetworkConfigurationused to instantiate the client. -
Declaration
Swift
public func sendRequest(_ request: URLRequest, completion: @escaping (NetworkResult) -> Void) -> Disposable -
Declaration
Swift
public func newClient(withLogger logger: LoggerProtocol) -> Self
View on GitHub