nsurlconnection - response.expectedContentLength allway return -1 -
i have connection use nsurlconnection, want draw progress connection when try print current received data , total data length, went wrong ,response.expectedcontentlength allway return -1, why , happen connection, how can fix
- (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data { receiveddatabytes += [data length]; nslog(@"data: %f",receiveddatabytes); [responsedata appenddata:data]; } - (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response { self.httpstatuscode = [(nshttpurlresponse *)response statuscode]; totalfilesize = response.expectedcontentlength; nslog(@"total: %lf",totalfilesize); }
output:
total: -1.000000 data: 1256.000000 total: -1.000000 data: 1034.000000 total: -1.000000 data: 1127.000000
Comments
Post a Comment