【发布时间】:2011-11-30 21:02:27
【问题描述】:
#import <Foundation/Foundation.h>
main() {
NSURL *url = [NSURL URLWithString:@"http://www.google.com/"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60];
NSURLResponse *response;
NSError *error;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"Data were download below:\n%@", [[NSString alloc] initWithData:data encoding: NSASCIIStringEncoding]);
}
运行可执行文件-> 数据下载如下: [空]
为什么?
【问题讨论】:
-
显而易见的问题:
error说什么? -
if (error != nil) [error userInfo] -> 分段错误
-
现在这很有趣。即使是普通的
NSLog(@"%@", error)也会这样吗? -
是的,也导致了段错误。
-
但是,tcpdump 正确显示了 http req/resp。
标签: objective-c http gnustep