Instance Method


Tells the delegate that the data task received the initial reply (headers) from the server.


optional func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void)



The session containing the data task that received an initial reply.


The data task that received an initial reply.


A URL response object populated with headers.


A completion handler that your code calls to continue the transfer, passing a constant to indicate whether the transfer should continue as a data task or should become a download task.


This method is optional unless you need to support the (relatively 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, and you should then display, discard, or otherwise process the previous part, as appropriate.

If you do not provide this delegate method, the session always allows the task to continue.