LanguageObserver

open class LanguageObserver : SAPURLSessionObserving

This observer is responsible to set the Accept-Language headers to each HTTP request of the SAPURLSession.

To enable this functionality you need to register this observer to an SAPURLSession instance.

This is an example for a typical usage of the observer:

let urlSession: SAPURLSession = <#SAPURLSession instance#>

let languageObserver = LanguageObserver()
urlSession.register(languageObserver)
  • language for Accept-Language header

    Declaration

    Swift

    public var language: String?
  • Initializes a new LanguageObserver instance

    Declaration

    Swift

    public init(language: String? = nil)

    Parameters

    language

    language for Accept-Language header, by default it is the Locale.current.identifier value

  • Invoked before a request is sent. An observer can modify the request, or cancel it.

    Declaration

    Swift

    public func sapURLSession(_ session: SAPURLSession, task: SAPURLSessionTask, willSend request: URLRequest, completionHandler: @escaping (SAPURLSession.RequestDisposition) -> Swift.Void)

    Parameters

    session

    The session which will contain the task after creation.

    task

    The task which is about to be created.

    request

    The request with which the task will be created.

    completionHandler

    A completion handler that your delegate method must call.

  • Undocumented

    Declaration

    Swift

    public func copy() -> Any?