2011-02-16 3 views
1

웹 페이지를 다운로드하는 NSURLConnection이 있습니다. Content-Length는 파일의 실제 크기보다 훨씬 작습니다. NSURLConnection 및 Content-Encoding

나는 헤더는 말했다 것으로 나타났습니다 :

Content-Encoding:gzip 

내가 콘텐츠 길이에 의해 반환되는 크기는 압축 해제 된 그러나있는 NSData가있는 NSURLConnection에 의해 반환 압축 된 크기이다 같아요.

먼저 NSURLConnection이 자동으로 압축을 푸우 시나요? 그리고 (Content-Length 대신) 압축되지 않은 파일의 길이를 얻는 방법

답변

0

진행률 표시 줄이 필요하면 ASIHTTPRequest를 시도해보십시오. 진행률 표시 줄을 관리하는 데 도움이되는 다양한 기능이 내장되어 있습니다.

0

NSURLConnection 다운로드를위한 진행률 표시기 나 진행률 표시기를 만들려는 경우 아래 코드를 시도하십시오. 그것은 내 애플 리케이션의 몇 가지 매력처럼 작동합니다.

- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { 
    // append the new data to receivedData (a global variable). 
    [receivedData appendData:data]; 
    // calculate number of kilobytes 
    int kb = [receivedData length]/1024; 
    // update a label, or some other visula thingy 
    self.downloadProgressLabel.text = [NSString stringWithFormat:@"Downloaded\n%d kB", kb]; 
}