“expectedContentLength"返回值的单位是什么? [英] What is the unit of the value returned by "expectedContentLength"
问题描述
我正在尝试在进行连接时设置数据限制.我正在使用以下函数来获取 NSURLResponse
的大小.
I am trying to set a data limit when doing connections.I am using the following function to get the size of the NSURLResponse
.
NSURLResponse *response;
long long size = [response expectedContentLength];
我得到的大小为:15219
是字节还是位?
推荐答案
expectedContentLength
在服务器提供时设置,例如通过 Content-Length
响应标头.
expectedContentLength
is set when the server provides it, such as by a Content-Length
response header.
Content-Length
是定义作者:
Content-Length entity-header 字段表示实体主体,以十进制数的 OCTET 发送给接收者,或者,在在 HEAD 方法的情况下,实体主体的大小如果请求是 GET,则已发送.
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 位.
So you can assume byte unit on most modern platform where a byte is 8 bits long.
这篇关于“expectedContentLength"返回值的单位是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!