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
languagelanguage 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
sessionThe session which will contain the task after creation.
taskThe task which is about to be created.
requestThe request with which the task will be created.
completionHandlerA completion handler that your delegate method must call.
-
Declaration
Swift
public func copy() -> Any?