开发者

how to get the http header in asynchronous request mode using ASIHHTTP

I hope to display the download file size by reading http header.

I know there is way do this:

ASIHTTPRequest request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous]; NSString poweredBy = [[request responseHeaders] objectForKey:@"X-Powered-By"];
N开发者_运维问答SString *contentType = [[request responseHeaders] objectForKey:@"Content-Type"];

but this is Synchronous mode, in Asynchronous mode it can be done as below:

(void)requestFinished:(ASIHTTPRequest *)request { unsigned long long contentLength = [request contentLength]; }

but 'requestFinished' is at the end of download. Is there an event to get the http header info at the beginning of download?

Thank

interdev


- (void)requestDidReceiveResponseHeader:(ASIHTTPRequest *)request
{
unsigned long long contentLength = [request contentLength]; 
NSLog(@"request Bytes = %llu", contentLength);
}


Not quite sure why you want that, but hopefully, you should be able to use:

// Called when a request starts, lets the delegate know via didStartSelector
- (void)requestStarted;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜