"expectedContentLength"返回值的单位是什么

What is the unit of the value returned by "expectedContentLength"

我正在尝试在执行 connections.I 时设置数据限制,我正在使用以下函数来获取 NSURLResponse 的大小。

   NSURLResponse *response;
  long long size = [response expectedContentLength];

我得到的尺寸为:15219

是字节还是比特?

expectedContentLength 在服务器提供时设置,例如通过 Content-Length 响应 header.

Content-Lengthdefined 来自:

The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET.

因此,您可以假设大多数现代平台上的字节单位是 8 位长。