<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSessionTaskDelegate/urlSession(_:task:needNewBodyStreamFrom:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSURLSessionTaskDelegate(im)URLSession:task:needNewBodyStreamFromOffset:completionHandler:"
  },
  "title" : "urlSession(_:task:needNewBodyStreamFrom:completionHandler:)"
}
-->

# urlSession(_:task:needNewBodyStreamFrom:completionHandler:)

Tells the delegate if a task requires a new body stream starting from the given offset. This may be
necessary when resuming a failed upload task.

```
optional func urlSession(_ session: URLSession, task: URLSessionTask, needNewBodyStreamFrom offset: Int64, completionHandler: @escaping @Sendable (InputStream?) -> Void)
```

## Parameters

`session`

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

`task`

The task that needs a new body stream.

`offset`

The starting offset required for the body stream.

`completionHandler`

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)