DefaultHTTPClient

public class DefaultHTTPClient : HTTPClient

A simple implementation of an HTTP client using the interceptor concept.

  • Declaration

    Swift

    public let interceptors: [Interceptor]
  • Initializer for the lightweight HTTP client

    Declaration

    Swift

    public init(
        urlSessionConfiguration: URLSessionConfiguration,
        interceptors: [Interceptor] = [],
        delegateQueue: OperationQueue? = nil
    )

    Parameters

    urlSession

    URLSessionConfiguration that is used to create the URLSession.

    interceptors

    list of Interceptors that may modify the request and/or response before sending.

    delegateQueue

    An operation queue for scheduling the delegate calls and completion handlers.

  • Send the given request. The request will be processed by the list of Interceptors.

    Declaration

    Swift

    public func send(
        request: URLRequest,
        interceptors requestInterceptors: [Interceptor],
        redirect handler: RedirectHandler?
    ) -> AnyPublisher<HTTPResponse, HTTPClientError>

    Parameters

    request

    The request to be (modified and) sent.

    Return Value

    AnyPublisher that emits a response as URLSessionResponse