KtorNSURLSessionDelegate

class KtorNSURLSessionDelegate(challengeHandler: ChallengeHandler?) : NSObject, NSURLSessionDataDelegateProtocol, NSURLSessionWebSocketDelegateProtocol

A delegate for NSURLSession that bridges it to Ktor. If users set custom session in DarwinClientEngineConfig.sessionAndDelegate, they need to register this delegate in their session. This can be done by registering it directly, extending their custom delegate from it or by calling required methods from their custom delegate.

For HTTP requests to work property, it's important that users call these functions:

  • URLSession:dataTask:didReceiveData:

  • URLSession:task:didCompleteWithError:

  • URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:

For WebSockets to work, it's important that users call these functions:

  • URLSession:webSocketTask:didOpenWithProtocol:

  • URLSession:webSocketTask:didCloseWithCode:reason:

Constructors

Link copied to clipboard
constructor(challengeHandler: ChallengeHandler?)

Properties

Link copied to clipboard
Link copied to clipboard
expect val description: String?
Link copied to clipboard
expect val hash: NSUInteger
Link copied to clipboard
expect val superclass: ObjCClass?

Functions

Link copied to clipboard
expect open override fun class(): ObjCClass?
Link copied to clipboard
expect open override fun conformsToProtocol(aProtocol: Protocol?): Boolean
Link copied to clipboard
expect open fun copy(): Any?
Link copied to clipboard
expect open fun debugDescription(): String?
Link copied to clipboard
expect open override fun description(): String?
Link copied to clipboard
expect open fun doesNotRecognizeSelector(aSelector: COpaquePointer?)
Link copied to clipboard
expect open fun finalize()
Link copied to clipboard
expect open fun forwardingTargetForSelector(aSelector: COpaquePointer?): Any?
Link copied to clipboard
expect open fun forwardInvocation(anInvocation: NSInvocation?)
Link copied to clipboard
expect open override fun hash(): NSUInteger
Link copied to clipboard
expect open fun init(): NSObject?
Link copied to clipboard
expect open override fun isEqual(object: Any?): Boolean
Link copied to clipboard
expect open override fun isKindOfClass(aClass: ObjCClass?): Boolean
Link copied to clipboard
expect open override fun isMemberOfClass(aClass: ObjCClass?): Boolean
Link copied to clipboard
expect open override fun isProxy(): Boolean
Link copied to clipboard
expect open fun methodForSelector(aSelector: COpaquePointer?): IMP?
Link copied to clipboard
expect open fun methodSignatureForSelector(aSelector: COpaquePointer?): NSMethodSignature?
Link copied to clipboard
expect open fun mutableCopy(): Any?
Link copied to clipboard
expect open override fun performSelector(aSelector: COpaquePointer?): Any?
expect open override fun performSelector(aSelector: COpaquePointer?, withObject: Any?): Any?
expect open override fun performSelector(aSelector: COpaquePointer?, withObject: Any?, _withObject: Any?): Any?
Link copied to clipboard
expect open override fun respondsToSelector(aSelector: COpaquePointer?): Boolean
Link copied to clipboard
expect open override fun superclass(): ObjCClass?
Link copied to clipboard
open override fun URLSession(session: NSURLSession, taskIsWaitingForConnectivity: NSURLSessionTask)
open override fun URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData: NSData)
open override fun URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError: NSError?)
open override fun URLSession(session: NSURLSession, webSocketTask: NSURLSessionWebSocketTask, didOpenWithProtocol: String?)
open override fun URLSession(session: NSURLSession, webSocketTask: NSURLSessionWebSocketTask, didCloseWithCode: NSURLSessionWebSocketCloseCode, reason: NSData?)
expect open fun URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didBecomeDownloadTask: NSURLSessionDownloadTask)
expect open fun URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didBecomeStreamTask: NSURLSessionStreamTask)
expect open fun URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, willCacheResponse: NSCachedURLResponse, completionHandler: (NSCachedURLResponse?) -> Unit)
expect open fun URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse: NSURLResponse, completionHandler: (NSURLSessionResponseDisposition) -> Unit)
expect open fun URLSession(session: NSURLSession, didBecomeInvalidWithError: NSError?)
expect open fun URLSession(session: NSURLSession, didReceiveChallenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Unit)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, needNewBodyStream: (NSInputStream?) -> Unit)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, didReceiveInformationalResponse: NSHTTPURLResponse)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, didFinishCollectingMetrics: NSURLSessionTaskMetrics)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, needNewBodyStreamFromOffset: int64_t, completionHandler: (NSInputStream?) -> Unit)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, willBeginDelayedRequest: NSURLRequest, completionHandler: (NSURLSessionDelayedRequestDisposition, NSURLRequest?) -> Unit)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, didSendBodyData: int64_t, totalBytesSent: int64_t, totalBytesExpectedToSend: int64_t)

open override fun URLSession(session: NSURLSession, task: NSURLSessionTask, didReceiveChallenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Unit)

Handle challenge.

open override fun URLSession(session: NSURLSession, task: NSURLSessionTask, willPerformHTTPRedirection: NSHTTPURLResponse, newRequest: NSURLRequest, completionHandler: (NSURLRequest?) -> Unit)

Disable embedded redirects.

expect open fun URLSessionDidFinishEventsForBackgroundURLSession(session: NSURLSession)