<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSessionDataDelegate/urlSession(_:dataTask:didBecome:)-7nqzu",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSURLSessionDataDelegate(im)URLSession:dataTask:didBecomeStreamTask:"
  },
  "title" : "urlSession(_:dataTask:didBecome:)"
}
-->

# urlSession(_:dataTask:didBecome:)

Tells the delegate that the data task was changed to a stream task.

```
optional func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didBecome streamTask: URLSessionStreamTask)
```

## Parameters

`session`

The session containing the task that was replaced by a stream task.

`dataTask`

The data task that was replaced by a stream task.

`streamTask`

The new stream task that replaced the data task.

## Discussion

When your [`urlSession(_:dataTask:didReceive:completionHandler:)`](/documentation/Foundation/URLSessionDataDelegate/urlSession(_:dataTask:didReceive:completionHandler:)) delegate method uses the [`URLSession.ResponseDisposition.becomeStream`](/documentation/Foundation/URLSession/ResponseDisposition/becomeStream) disposition to convert the request to use a stream, the session calls this delegate method to provide you with the new stream task. After this call, the session delegate receives no further delegate method 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 [`urlSession(_:writeClosedFor:)`](/documentation/Foundation/URLSessionStreamDelegate/urlSession(_:writeClosedFor:)). You can disable pipelining for all requests in a session by setting the [`httpShouldUsePipelining`](/documentation/Foundation/URLSessionConfiguration/httpShouldUsePipelining) property on its [`URLSessionConfiguration`](/documentation/Foundation/URLSessionConfiguration) object, or for individual requests  by setting the [`httpShouldUsePipelining`](/documentation/Foundation/NSURLRequest/httpShouldUsePipelining) property on an [`NSURLRequest`](/documentation/Foundation/NSURLRequest) object.

---

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)