<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSessionTask/countOfBytesClientExpectsToReceive",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLSessionTask(py)countOfBytesClientExpectsToReceive"
  },
  "title" : "countOfBytesClientExpectsToReceive"
}
-->

# countOfBytesClientExpectsToReceive

A best-guess upper bound on the number of bytes the client expects to receive.

```
var countOfBytesClientExpectsToReceive: Int64 { get set }
```

## Discussion

The value set for this property should account for the size of both HTTP response headers and the response body. If no value is specified, the system uses [`NSURLSessionTransferSizeUnknown`](/documentation/Foundation/NSURLSessionTransferSizeUnknown) instead. This property is used by the system to optimize the scheduling of URL session tasks. Developers are strongly encouraged to provide an approximate upper bound, or an exact byte count, if possible, rather than accept the default.

---

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)