1
我正在使用ASIHttpRequest庫進行並行異步Web調用。這是實際方法的代碼片段。來自ASIHttpRequest的空白響應
- (void)dataForURI:(NSString *)dataURI andTag:(NSString*)tag
{
NSLog(@"%d",_queue.requestsCount);
if (!_queue) {
_queue = [ASINetworkQueue queue];
}
ASIHTTPRequest* request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:dataURI]];
[request setTimeOutSeconds:30];
[request setDownloadProgressDelegate:self];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestFinished:)];
[request setDidFailSelector:@selector(requestFailed:)];
[request setDidReceiveResponseHeadersSelector:@selector(requsestResponseHeaderReceived:)];
[request setShouldContinueWhenAppEntersBackground:YES];
[request setTag:[tag integerValue]];
[_queue addOperation:request];
[_queue go];
}
當我'NSLog'請求的request.responseString屬性,我什麼也沒有顯示在控制檯。我使用Wireshark來檢查鏈接是否正在發送任何響應,並且似乎正在發送適當的響應。
當我'NSLog'responseHeaders它顯示正確的值。下面是代碼片段爲:
-(void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"%@",request.responseString);
NSLog(@"%@",[[request responseHeaders] objectForKey:@"Content-Type"]);
[self imageHandlerDidDownloadData:request.responseData mimeType:[request.responseHeaders objectForKey:@"Content-Type"] forMediaID:[NSString stringWithFormat:@"%d", request.tag]];
}
我也是越來越響應數據這種方法(但不是在RequestFinished:法):
-(void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data
{
NSLog(@"%@",data);
NSLog(@"%@", [[request responseHeaders] objectForKey:@"Content-Type"]);
}
請幫我把適當的反應......! !
在此先感謝。
所以你得到的HTTP報頭,但沒有內容? request.responseData在登錄時顯示什麼? – Till
我在request.responseData中也沒有得到任何東西。 –
你得到了什麼響應代碼? – atxe