Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:AFNetworking/AFNetworking

  • Loading branch information...
commit f626ced68ab741bc0a6f1ab7978d191ec7ddc900 2 parents 804fca7 + 914d2ae
@mattt mattt authored
View
1  AFNetworking.podspec
@@ -49,6 +49,7 @@ Pod::Spec.new do |s|
ss.ios.deployment_target = '6.0'
ss.dependency 'AFNetworking/NSURLConnection'
+ ss.dependency 'AFNetworking/NSURLSession'
ss.ios.public_header_files = 'UIKit+AFNetworking/*.h'
ss.ios.source_files = 'UIKit+AFNetworking'
View
20 AFNetworking/AFURLSessionManager.m
@@ -95,6 +95,7 @@ static dispatch_group_t url_session_manager_completion_group() {
@interface AFURLSessionManagerTaskDelegate : NSObject <NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate>
@property (nonatomic, weak) AFURLSessionManager *manager;
+@property (nonatomic, strong) id <AFURLResponseSerialization> responseSerializer;
@property (nonatomic, strong) NSMutableData *mutableData;
@property (nonatomic, strong) NSProgress *uploadProgress;
@property (nonatomic, strong) NSProgress *downloadProgress;
@@ -114,6 +115,7 @@ + (instancetype)delegateForManager:(AFURLSessionManager *)manager
{
AFURLSessionManagerTaskDelegate *delegate = [[self alloc] init];
delegate.manager = manager;
+ delegate.responseSerializer = manager.responseSerializer;
delegate.completionHandler = completionHandler;
return delegate;
@@ -163,7 +165,7 @@ - (void)URLSession:(__unused NSURLSession *)session
__block id responseObject = nil;
__block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
- userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer;
+ userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = self.responseSerializer;
if (self.downloadFileURL) {
userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL;
@@ -186,7 +188,7 @@ - (void)URLSession:(__unused NSURLSession *)session
} else {
dispatch_async(url_session_manager_processing_queue(), ^{
NSError *serializationError = nil;
- responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:[NSData dataWithData:self.mutableData] error:&serializationError];
+ responseObject = [self.responseSerializer responseObjectForResponse:task.response data:[NSData dataWithData:self.mutableData] error:&serializationError];
if (self.downloadFileURL) {
responseObject = self.downloadFileURL;
@@ -351,6 +353,7 @@ - (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate
NSParameterAssert(delegate);
[self.lock lock];
+ [task addObserver:self forKeyPath:NSStringFromSelector(@selector(state)) options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:AFTaskStateChangedContext];
self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate;
[self.lock unlock];
}
@@ -359,6 +362,7 @@ - (void)removeDelegateForTask:(NSURLSessionTask *)task {
NSParameterAssert(task);
[self.lock lock];
+ [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(state)) context:AFTaskStateChangedContext];
[self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)];
[self.lock unlock];
}
@@ -437,8 +441,6 @@ - (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
AFURLSessionManagerTaskDelegate *delegate = [AFURLSessionManagerTaskDelegate delegateForManager:self completionHandler:completionHandler];
[self setDelegate:delegate forTask:dataTask];
- [dataTask addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:AFTaskStateChangedContext];
-
return dataTask;
}
@@ -502,8 +504,6 @@ - (NSURLSessionUploadTask *)uploadTaskWithTask:(NSURLSessionUploadTask *)uploadT
}
[self setDelegate:delegate forTask:uploadTask];
-
- [uploadTask addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:AFTaskStateChangedContext];
return uploadTask;
}
@@ -552,8 +552,6 @@ - (NSURLSessionDownloadTask *)downloadTaskWithTask:(NSURLSessionDownloadTask *)d
[self setDelegate:delegate forTask:downloadTask];
- [downloadTask addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:AFTaskStateChangedContext];
-
return downloadTask;
}
@@ -763,8 +761,6 @@ - (void)URLSession:(NSURLSession *)session
}
[self removeDelegateForTask:task];
-
- [task removeObserver:self forKeyPath:@"state" context:AFTaskStateChangedContext];
}
}
@@ -794,12 +790,8 @@ - (void)URLSession:(NSURLSession *)session
if (delegate) {
[self removeDelegateForTask:dataTask];
[self setDelegate:delegate forTask:downloadTask];
-
- [dataTask removeObserver:self forKeyPath:@"state" context:AFTaskStateChangedContext];
}
- [downloadTask addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:AFTaskStateChangedContext];
-
if (self.dataTaskDidBecomeDownloadTask) {
self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask);
}
View
8 Example/AFNetworking iOS Example.xcodeproj/project.pbxproj
@@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
297F56CA17A9B1AB0014D95C /* AFSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = 297F56C917A9B1AB0014D95C /* AFSecurityPolicy.m */; };
2982AD3217107C0000FFF048 /* adn.cer in Resources */ = {isa = PBXBuildFile; fileRef = 2982AD3117107C0000FFF048 /* adn.cer */; };
+ E8C2E7A618970EE40097DCC8 /* root_ca.cer in Resources */ = {isa = PBXBuildFile; fileRef = E8C2E7A418970EE00097DCC8 /* root_ca.cer */; };
+ E8C2E7A718970EE40097DCC8 /* digicert_ca_3.cer in Resources */ = {isa = PBXBuildFile; fileRef = E8C2E7A518970EE00097DCC8 /* digicert_ca_3.cer */; };
F8129C7415910C37009BFE23 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C7215910C37009BFE23 /* AppDelegate.m */; };
F818101615E6A0C600EF93C2 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */; };
F8664A2018AA99F5007D8554 /* UIRefreshControl+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8664A1F18AA99F5007D8554 /* UIRefreshControl+AFNetworking.m */; };
@@ -54,6 +56,8 @@
2982AD3117107C0000FFF048 /* adn.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = adn.cer; sourceTree = SOURCE_ROOT; };
50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
55BDA27E17F5A434005DB933 /* UIKit+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIKit+AFNetworking.h"; sourceTree = "<group>"; };
+ E8C2E7A418970EE00097DCC8 /* root_ca.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = root_ca.cer; sourceTree = SOURCE_ROOT; };
+ E8C2E7A518970EE00097DCC8 /* digicert_ca_3.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = digicert_ca_3.cer; sourceTree = SOURCE_ROOT; };
F8129C3815910830009BFE23 /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = SOURCE_ROOT; };
F8129C7215910C37009BFE23 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; };
F8129C7315910C37009BFE23 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; };
@@ -303,6 +307,8 @@
F8E4696B1395739D00DB05C8 /* Supporting Files */ = {
isa = PBXGroup;
children = (
+ E8C2E7A418970EE00097DCC8 /* root_ca.cer */,
+ E8C2E7A518970EE00097DCC8 /* digicert_ca_3.cer */,
2982AD3117107C0000FFF048 /* adn.cer */,
F8DA09E31396AC040057D0CC /* main.m */,
F8129C3815910830009BFE23 /* Prefix.pch */,
@@ -417,10 +423,12 @@
files = (
F8F6E8DC1463424800AD016F /* Icon.png in Resources */,
F8F6E8DD1463424800AD016F /* Icon@2x.png in Resources */,
+ E8C2E7A718970EE40097DCC8 /* digicert_ca_3.cer in Resources */,
F8FA94D0150F094D00ED4EAD /* profile-image-placeholder.png in Resources */,
F8FA94D1150F094D00ED4EAD /* profile-image-placeholder@2x.png in Resources */,
F8A847C1161F51A300940F39 /* Default-568h@2x.png in Resources */,
F8A847C3161F523E00940F39 /* Default.png in Resources */,
+ E8C2E7A618970EE40097DCC8 /* root_ca.cer in Resources */,
F8A847C5161F524200940F39 /* Default@2x.png in Resources */,
2982AD3217107C0000FFF048 /* adn.cer in Resources */,
);
View
1  Example/Classes/AFAppDotNetAPIClient.m
@@ -31,6 +31,7 @@ + (instancetype)sharedClient {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedClient = [[AFAppDotNetAPIClient alloc] initWithBaseURL:[NSURL URLWithString:AFAppDotNetAPIBaseURLString]];
+ _sharedClient.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
});
return _sharedClient;
View
BIN  Example/digicert_ca_3.cer
Binary file not shown
View
BIN  Example/root_ca.cer
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.