Platforms to show: All Mac Windows Linux Cross-Platform
Back to NSURLSessionMBS class.
NSURLSessionMBS.dataTaskDidBecomeDownloadTask(dataTask as NSURLSessionDataTaskMBS, downloadTask as NSURLSessionDownloadTaskMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| event | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
dataTask: The data task that was replaced by a download task.
downloadTask: The new download task that replaced the data task.
When your dataTaskDidReceiveResponse event uses the ResponseBecomeDownload disposition to convert the request to use a download, the session calls this event to provide you with the new download task. After this call, the session receives no further event calls related to the original data task.
Some examples using this event:
NSURLSessionMBS.dataTaskDidBecomeStreamTask(dataTask as NSURLSessionDataTaskMBS, downloadTask as NSURLSessionStreamTaskMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| event | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
dataTask: The data task that was replaced by a stream task.
streamTask: The new stream task that replaced the data task.
When your dataTaskDidReceiveResponse event uses the ResponseBecomeStream disposition to convert the request to use a stream, the session calls this event to provide you with the new stream task. After this call, the session receives no further event calls related to the original data task.
For requests that were pipelined, the stream task allows only reading, and the object immediately sends the delegate message writeClosedForStreamTask. You can disable pipelining for all requests in a session by setting the HTTPShouldUsePipelining property on its NSURLSessionConfigurationMBS object, or for individual requests by setting the HTTPShouldUsePipelining property on an NSURLRequestMBS object.
Some examples using this event:
NSURLSessionMBS.dataTaskDidReceiveData(dataTask as NSURLSessionDataTaskMBS, data as MemoryBlock)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| event | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
dataTask: The data task that provided data.
data: A data object containing the transferred data.
This event may be called more than once, and each call provides only data received since the previous call. The app is responsible for accumulating this data if needed.
Some examples using this event:
NSURLSessionMBS.dataTaskDidReceiveResponse(dataTask as NSURLSessionDataTaskMBS, response as NSURLResponseMBS) as Integer
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| event | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
dataTask:
The data task that received an initial reply.
response: A URL response object populated with headers.
Return your decision whether to continue a transfer, passing a NSURLSessionResponseDisposition constant to indicate whether the transfer should continue as a data task or should become a download task.
- If you pass ResponseAllow, the task continues as a data task.
- If you pass ResponseCancel, the task is canceled.
- If you pass ResponseBecomeDownload, your delegate’s dataTaskDidBecomeDownloadTask method is called to provide the new download task that supersedes the current task.
You also implement this method if you need to support the fairly obscure multipart/x-mixed-replace content type. With that content type, the server sends a series of parts, each of which is intended to replace the previous part. The session calls this method at the beginning of each part, followed by one or more calls to dataTaskDidReceiveData with the contents of that part.
Each time the dataTaskDidReceiveResponse method is called for a part, collect the data received for the previous part (if any) and process the data as needed for your application. This processing can include storing the data to the filesystem, parsing it into custom types, or displaying it to the user. Next, begin receiving the next part by calling the completion handler with the NSURLSessionResponseAllow constant. Finally, if you have also implemented taskDidCompleteWithError, the session will call it after sending all the data for the last part.
Some examples using this event:
NSURLSessionMBS.dataTaskWillCacheResponse(dataTask as NSURLSessionDataTaskMBS, proposedResponse as NSCachedURLResponseMBS) as NSCachedURLResponseMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| event | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
dataTask: The data (or upload) task.
proposedResponse: The default caching behavior. This behavior is determined based on the current caching policy and the values of certain received headers, such as the Pragma and Cache-Control headers.
Please return the new respnose:
Provide either the original proposed response, a modified version of that response, or nil to prevent caching the response.
The session calls this event after the task finishes receiving all of the expected data. If you don’t implement this method, the default behavior is to use the caching policy specified in the session’s configuration object. The primary purpose of this method is to prevent caching of specific URLs or to modify the userInfo dictionary associated with the URL response.
This method is called only if the NSURLProtocol handling the request decides to cache the response. As a rule, responses are cached only when all of the following are true:
- The request is for an HTTP or HTTPS URL (or your own custom networking protocol that supports caching).
- The request was successful (with a status code in the 200–299 range).
- The provided response came from the server, rather than out of the cache.
- The session configuration’s cache policy allows caching.
- The provided NSURLRequestMBS object's cache policy (if applicable) allows caching.
- The cache-related headers in the server’s response (if present) allow caching.
- The response size is small enough to reasonably fit within the cache. (For example, if you provide a disk cache, the response must be no larger than about 5% of the disk cache size.)
Some examples using this event:
NSURLSessionMBS.didBecomeInvalid(error as NSErrorMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| event | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
error: The error that caused invalidation, or nil if the invalidation was explicit.
If you invalidate a session by calling its finishTasksAndInvalidate method, the session waits until after the final task in the session finishes or fails before calling this event. If you call the invalidateAndCancel method, the session calls this event immediately.
Some examples using this event:
NSURLSessionMBS.didReceiveChallenge(challenge as NSURLAuthenticationChallengeMBS, byref disposition as Integer, byref credential as NSURLCredentialMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| event | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
session: The session containing the task that requested authentication.
challenge: An object that contains the request for authentication.
disposition—One of several constants that describes how the challenge should be handled.
credential—The credential that should be used for authentication if disposition is NSURLSessionAuthChallengeUseCredential, otherwise nil.
This method is called in two situations
- When a remote server asks for client certificates or Windows NT LAN Manager (NTLM) authentication, to allow your app to provide appropriate credentials
- When a session first establishes a connection to a remote server that uses SSL or TLS, to allow your app to verify the server’s certificate chain
Note
This method handles only the NSURLAuthenticationMethodNTLM, NSURLAuthenticationMethodNegotiate, NSURLAuthenticationMethodClientCertificate, and NSURLAuthenticationMethodServerTrust authentication types. For all other authentication schemes, the session calls only the taskDidReceiveChallenge method.
Some examples using this event:
NSURLSessionMBS.downloadTaskDidFinishDownloadingToURL(downloadTask as NSURLSessionDownloadTaskMBS, location as String, file as FolderItem)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| event | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
downloadTask: The download task that finished.
location: A file URL for the temporary file. Because the file is temporary, you must either open the file for reading or move it to a permanent location in your app’s sandbox container directory before returning from this event.
Some examples using this event:
NSURLSessionMBS.downloadTaskDidResumeAtOffset(downloadTask as NSURLSessionDownloadTaskMBS, fileOffset as Int64, expectedTotalBytes as Int64)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| event | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
downloadTask: The download task that resumed. See explanation in the discussion.
fileOffset: If the file's cache policy or last modified date prevents reuse of the existing content, then this value is zero. Otherwise, this value is an integer representing the number of bytes on disk that do not need to be retrieved again.
In some situations, it may be possible for the transfer to resume earlier in the file than where the previous transfer ended.
expectedTotalBytes: The expected length of the file, as provided by the Content-Length header. If this header was not provided, the value is NSURLSessionTransferSizeUnknown (-1).
If a resumable download task is canceled or fails, you can request a resumeData object that provides enough information to restart the download in the future. Later, you can call downloadTaskWithResumeData with that data.
When you call those methods, you get a new download task. As soon as you resume that task, the session calls this method with that new task to indicate that the download is resumed.
Some examples using this event:
NSURLSessionMBS.downloadTaskDidWriteData(downloadTask as NSURLSessionDownloadTaskMBS, bytesWritten as Int64, totalBytesWritten as Int64, totalBytesExpectedToWrite as Int64)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| event | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
downloadTask: The download task.
bytesWritten: The number of bytes transferred since the last time this event was called.
totalBytesWritten: The total number of bytes transferred so far.
totalBytesExpectedToWrite: The expected length of the file, as provided by the Content-Length header. If this header was not provided, the value is NSURLSessionTransferSizeUnknown (-1).
Some examples using this event:
The items on this page are in the following plugins: MBS MacFrameworks Plugin.