NetworkConfiguration Class

public class NetworkConfiguration : NSObject, NSCopying, Codable

Discussion: Apple uses predefined network sessions called URLSession. There is no way to create a dedicated URLSession for each Request. If ‘NetworkConfiguration’ is updated it will affect the whole URLSession, which is shared for all the HTTP/S requests in ‘NetworkEngine’.

  • A dictionary of additional headers to send with requests.

    Declaration

    Swift

    public var httpAdditionalHeaders: [String : String]
  • A Boolean value that determines whether connections should be made over a cellular network. The value is assigned on the URLSession-level and on the URLRequest-level

    Declaration

    Swift

    public var allowsCellularAccess: Bool
  • The maximum amount of time that a resource request should be allowed to take. The value is assigned on the URLSession-level and on the URLRequest-level

    Declaration

    Swift

    public var timeoutIntervalForResourceMs: Double
  • The drm license requests dedicated timeout. By default, the timeout is set to 0.0, which means that the request will not forcefully timeout.

    Declaration

    Swift

    public var timeoutIntervalForDrmAcquisitionMs: Double
  • A Boolean value that indicates whether the session should wait for connectivity to become available, or fail immediately.

    Declaration

    Swift

    public var waitsForConnectivity: Bool
  • Declaration

    Swift

    public required init(from decoder: Decoder) throws
  • Creates a network configuration with explicit values.

    Declaration

    Swift

    public init(
        httpAdditionalHeaders: [String: String] = [:],
        allowsCellularAccess: Bool = Defaults.allowsCellularAccess,
        timeoutIntervalForResourceMs: Double = Defaults.timeoutIntervalForResource,
        timeoutIntervalForDrmAcquisitionMs: Double = Defaults.timeoutIntervalForDrmAcquisition,
        waitsForConnectivity: Bool = Defaults.waitsForConnectivity
    )

    Parameters

    httpAdditionalHeaders

    Extra HTTP headers attached to all outgoing requests.

    allowsCellularAccess

    Whether requests may use cellular transport.

    timeoutIntervalForResourceMs

    Timeout for non-DRM requests in milliseconds.

    timeoutIntervalForDrmAcquisitionMs

    Timeout for DRM requests in milliseconds.

    waitsForConnectivity

    Whether requests should wait for connectivity instead of failing fast.