HttpClient
@objc
open class HttpClient : NSObject, @unchecked Sendable
HttpClient is responsible for handling HTTP requests and logging the details of those requests and responses.
-
The timeout interval for HTTP requests.
Declaration
Swift
public var timeoutIntervalForRequest: TimeInterval -
Initializes a new instance of
HttpClient.Declaration
Swift
public init(session: URLSession = URLSession(configuration: URLSessionConfiguration.default, delegate: RedirectPreventer(), delegateQueue: nil))Parameters
sessionThe URLSession instance to be used for HTTP requests. Defaults to a session with
RedirectPreventerdelegate. -
Logs the details of an HTTP request.
Declaration
Swift
public func logRequest(request: URLRequest?)Parameters
requestThe URLRequest to be logged.
-
sendRequest(request:Asynchronous) Sends an HTTP request and returns the response data and metadata.
Throws
An error if the request fails.Declaration
Swift
public func sendRequest(request: Request) async throws -> (Data, URLResponse)Parameters
requestThe Request object to be sent.
Return Value
A tuple containing the response data and metadata.
View on GitHub