- #import <Foundation/Foundation.h>
-
- #import "AFURLResponseSerialization.h"
- #import "AFURLRequestSerialization.h"
- #import "AFSecurityPolicy.h"
- #import "AFNetworkReachabilityManager.h"
-
- #ifndef NS_DESIGNATED_INITIALIZER
- #if __has_attribute(objc_designated_initializer)
- #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
- #else
- #define NS_DESIGNATED_INITIALIZER
- #endif
- #endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090)
-
- @interface AFURLSessionManager : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate, NSSecureCoding, NSCopying>
-
-
-
-
- @property (readonly, nonatomic, strong) NSURLSession *session;
-
-
-
-
- @property (readonly, nonatomic, strong) NSOperationQueue *operationQueue;
-
-
-
-
-
-
-
- @property (nonatomic, strong) id <AFURLResponseSerialization> responseSerializer;
-
-
-
-
-
-
-
-
-
- @property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
-
-
-
-
-
-
-
-
- @property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager;
-
-
-
-
-
-
-
-
- @property (readonly, nonatomic, strong) NSArray *tasks;
-
-
-
-
- @property (readonly, nonatomic, strong) NSArray *dataTasks;
-
-
-
-
-
- @property (readonly, nonatomic, strong) NSArray *uploadTasks;
-
-
-
-
- @property (readonly, nonatomic, strong) NSArray *downloadTasks;
-
-
-
-
-
-
-
-
-
- #if OS_OBJECT_HAVE_OBJC_SUPPORT
- @property (nonatomic, strong) dispatch_queue_t completionQueue;
- #else
- @property (nonatomic, assign) dispatch_queue_t completionQueue;
- #endif
-
-
-
-
-
- #if OS_OBJECT_HAVE_OBJC_SUPPORT
- @property (nonatomic, strong) dispatch_group_t completionGroup;
- #else
- @property (nonatomic, assign) dispatch_group_t completionGroup;
- #endif
-
-
-
-
-
-
-
-
-
-
-
-
- @property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions;
-
-
-
-
-
-
-
-
-
-
-
-
- - (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
-
-
-
-
-
-
- - (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks;
-
-
-
-
-
-
-
-
-
-
-
- - (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
- completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
- fromFile:(NSURL *)fileURL
- progress:(NSProgress * __autoreleasing *)progress
- completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler;
-
-
-
-
-
-
-
-
-
- - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
- fromData:(NSData *)bodyData
- progress:(NSProgress * __autoreleasing *)progress
- completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler;
-
-
-
-
-
-
-
-
- - (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request
- progress:(NSProgress * __autoreleasing *)progress
- completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request
- progress:(NSProgress * __autoreleasing *)progress
- destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
- completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler;
-
-
-
-
-
-
-
-
-
- - (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData
- progress:(NSProgress * __autoreleasing *)progress
- destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
- completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler;
-
-
-
-
-
-
-
-
-
-
-
-
- - (NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask;
-
-
-
-
-
-
-
-
- - (NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask;
-
-
-
-
-
-
-
-
-
-
- - (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block;
-
-
-
-
-
-
- - (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block;
-
-
-
-
-
-
-
-
-
-
- - (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block;
-
-
-
-
-
-
- - (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block;
-
-
-
-
-
-
- - (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block;
-
-
-
-
-
-
- - (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block;
-
-
-
-
-
-
- - (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block;
-
-
-
-
-
-
-
-
-
-
- - (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block;
-
-
-
-
-
-
- - (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block;
-
-
-
-
-
-
- - (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block;
-
-
-
-
-
-
- - (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block;
-
-
-
-
-
-
- - (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block;
-
-
-
-
-
-
-
-
-
-
- - (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block;
-
-
-
-
-
-
- - (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block;
-
-
-
-
-
-
- - (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block;
-
- @end
-
- #endif
-
-
-
-
-
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidStartNotification DEPRECATED_ATTRIBUTE;
-
-
-
-
- extern NSString * const AFNetworkingTaskDidResumeNotification;
-
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidFinishNotification DEPRECATED_ATTRIBUTE;
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidCompleteNotification;
-
-
-
-
- extern NSString * const AFNetworkingTaskDidSuspendNotification;
-
-
-
-
- extern NSString * const AFURLSessionDidInvalidateNotification;
-
-
-
-
- extern NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification;
-
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidFinishResponseDataKey DEPRECATED_ATTRIBUTE;
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidCompleteResponseDataKey;
-
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidFinishSerializedResponseKey DEPRECATED_ATTRIBUTE;
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey;
-
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidFinishResponseSerializerKey DEPRECATED_ATTRIBUTE;
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey;
-
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidFinishAssetPathKey DEPRECATED_ATTRIBUTE;
-
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidCompleteAssetPathKey;
-
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidFinishErrorKey DEPRECATED_ATTRIBUTE;
-
-
-
-
-
-
- extern NSString * const AFNetworkingTaskDidCompleteErrorKey;
AFNetworking 源码解析之“AFURLSessionManager”
原文:http://blog.csdn.net/jiang314/article/details/51879180