Instance Method


Tells the delegate when a task requires a new request body stream to send to the remote server.


- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler;



The session containing the task that needs a new body stream.


The task that needs a new body stream.


A completion handler that your delegate method should call with the new body stream.


The task calls this delegate method under two circumstances:

  • To provide the initial request body stream if the task was created with uploadTaskWithStreamedRequest:

  • To provide a replacement request body stream if the task needs to resend a request that has a body stream because of an authentication challenge or other recoverable server error.

See Also

Working with Upload Tasks

- URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:

Periodically informs the delegate of the progress of sending body content to the server.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software