2

As Apple documentation says expectedContentLength of NSURLResponse may not return the value, if the protocol implementations does not report the content length as part of the response. So, is there any alternative to that, like executing javascript on UIWebView, that can return the content length?

Thanks for help.

san
  • 3,350
  • 1
  • 28
  • 40

1 Answers1

0

May be I do not fully understand your problem, but if you want to have a guaranteed size of the content this is not possible because of the HTML protocol. The only way to guarantee it is to fetch the content or stop retrieving content if a certain amount is read. Please bear in mind that you could download pretty much anything, even endless streams.

You might want to go the corresponding rfc sections RFC 2616 section 14.13 and RFC 2616 section 4.4.

Only if the sender and the conditions are met, the size will be transfered but please do not code according to the existence of this information.

Did this answer your question?

iOS
  • 813
  • 5
  • 14
  • I don't want the exact/guaranteed size. Even a rough estimate of it, will solve my problem. – san Feb 27 '12 at 09:12
  • As having said, if there is information you will get it otherwise there is nothing except you take actions to fetch the content. Hereby you have the opportunity to fetch a first chunk of data but you will not know how much is left. – iOS Feb 27 '12 at 09:22
  • After searching a lot, I found the same that it is not possible if protocol does not provide the information. So as far as I feel, you are correct and marking your answer right. – san Feb 28 '12 at 06:52