JXHTTP 是来自 tumblr 的 iOS 和 OS X 上的网络连接库。
JXHTTPOperation *op = [JXHTTPOperation withURLString:@"https://encrypted.google.com/"]; op.didFinishLoadingBlock = ^(JXHTTPOperation *op) { NSLog(@"%@", op.responseString); }; [[JXHTTPOperationQueue sharedQueue] addOperation:op];
JXHTTPOperation *op = [JXHTTPOperation withURLString:@"https://encrypted.google.com/"]; [op startAndWaitUntilFinished]; NSLog(@"%@", op.responseString);
NSURL *postURL = [NSURL URLWithString:@"https://web.site/api/POST"]; NSDictionary *postParams = @{ @"make": @"Ferrari", @"model": @"458 Italia" }; JXHTTPOperation *op = [[JXHTTPOperation alloc] initWithURL:postURL]; op.requestBody = [[JXHTTPFormEncodedBody alloc] initWithDictionary:postParams]; op.requestCachePolicy = NSURLRequestReloadIgnoringLocalAndRemoteCacheData; op.responseDataFilePath = @"/tmp/downloaded_data"; op.trustedHosts = @[ postURL.host ]; op.performsBlocksOnMainQueue = YES; op.didSendDataBlock = ^(JXHTTPOperation *op) { NSLog(@"%lld bytes uploaded so far", op.bytesUploaded); }; [[JXHTTPOperationQueue sharedQueue] addOperation:op];