相关疑难解决方法(0)

响应expectedContentLength返回-1

你好,我需要在从我的webservice加载数据时创建progressView.

实际上expectedContentLength总是返回-1.

看了很多类似的问题后,我的webservice似乎永远不会发送Content-Length:.

然后我用CURL检查,结果如下:

< HTTP/1.1 200 OK
< Date: Thu, 21 Jun 2012 10:04:39 GMT
< Server: Apache/2.2.16 (Debian)
< X-Powered-By: PHP/5.3.3-7+squeeze9
< cache-control: no-cache
< Vary: Accept-Encoding
< Content-Type: text/html; charset=UTF-8
< Content-Length: 3239  
< Connection: Keep-Alive
< Set-Cookie: PHPSESSID=u4o4i9dofdgnkfmtnf163635j6; path=/
Run Code Online (Sandbox Code Playgroud)

这是我的代码来捕捉长度

long long expectDataSize;
long long currentDataSize;

....

 - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response
{
    NSLog(@"expect content length %lld", [response expectedContentLength]);
    expectDataSize = [response expectedContentLength];
    currentDataSize = 0;
}
Run Code Online (Sandbox Code Playgroud)

任何人都已经看到了这个问题?

iphone ios5 nshttpurlresponse

3
推荐指数
1
解决办法
4616
查看次数

标签 统计

ios5 ×1

iphone ×1

nshttpurlresponse ×1