Search code examples
objective-cnsurl

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


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];

I get the size as :15219

Is it in bytes or bits?


Solution

  • expectedContentLength is set when the server provides it, such as by a Content-Length response header.

    Content-Length is defined by:

    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.

    So you can assume byte unit on most modern platform where a byte is 8 bits long.