mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-01-31 00:00:03 +08:00
Merge pull request #422 from meiram-tr/master
Replacing AFNewtworking files and classes names to prevent conflicts with the real pod library
This commit is contained in:
26
plugin.xml
26
plugin.xml
@@ -36,25 +36,25 @@
|
|||||||
<header-file src="src/ios/BinaryResponseSerializer.h"/>
|
<header-file src="src/ios/BinaryResponseSerializer.h"/>
|
||||||
<header-file src="src/ios/TextResponseSerializer.h"/>
|
<header-file src="src/ios/TextResponseSerializer.h"/>
|
||||||
<header-file src="src/ios/TextRequestSerializer.h"/>
|
<header-file src="src/ios/TextRequestSerializer.h"/>
|
||||||
<header-file src="src/ios/AFNetworking/AFHTTPSessionManager.h"/>
|
<header-file src="src/ios/SM_AFNetworking/SM_AFHTTPSessionManager.h"/>
|
||||||
<header-file src="src/ios/AFNetworking/AFNetworking.h"/>
|
<header-file src="src/ios/SM_AFNetworking/SM_AFNetworking.h"/>
|
||||||
<header-file src="src/ios/AFNetworking/AFNetworkReachabilityManager.h"/>
|
<header-file src="src/ios/SM_AFNetworking/SM_AFNetworkReachabilityManager.h"/>
|
||||||
<header-file src="src/ios/AFNetworking/AFSecurityPolicy.h"/>
|
<header-file src="src/ios/SM_AFNetworking/SM_AFSecurityPolicy.h"/>
|
||||||
<header-file src="src/ios/AFNetworking/AFURLRequestSerialization.h"/>
|
<header-file src="src/ios/SM_AFNetworking/SM_AFURLRequestSerialization.h"/>
|
||||||
<header-file src="src/ios/AFNetworking/AFURLResponseSerialization.h"/>
|
<header-file src="src/ios/SM_AFNetworking/SM_AFURLResponseSerialization.h"/>
|
||||||
<header-file src="src/ios/AFNetworking/AFURLSessionManager.h"/>
|
<header-file src="src/ios/SM_AFNetworking/SM_AFURLSessionManager.h"/>
|
||||||
<header-file src="src/ios/SDNetworkActivityIndicator/SDNetworkActivityIndicator.h"/>
|
<header-file src="src/ios/SDNetworkActivityIndicator/SDNetworkActivityIndicator.h"/>
|
||||||
<source-file src="src/ios/CordovaHttpPlugin.m"/>
|
<source-file src="src/ios/CordovaHttpPlugin.m"/>
|
||||||
<source-file src="src/ios/BinaryRequestSerializer.m"/>
|
<source-file src="src/ios/BinaryRequestSerializer.m"/>
|
||||||
<source-file src="src/ios/BinaryResponseSerializer.m"/>
|
<source-file src="src/ios/BinaryResponseSerializer.m"/>
|
||||||
<source-file src="src/ios/TextResponseSerializer.m"/>
|
<source-file src="src/ios/TextResponseSerializer.m"/>
|
||||||
<source-file src="src/ios/TextRequestSerializer.m"/>
|
<source-file src="src/ios/TextRequestSerializer.m"/>
|
||||||
<source-file src="src/ios/AFNetworking/AFHTTPSessionManager.m"/>
|
<source-file src="src/ios/SM_AFNetworking/SM_AFHTTPSessionManager.m"/>
|
||||||
<source-file src="src/ios/AFNetworking/AFNetworkReachabilityManager.m"/>
|
<source-file src="src/ios/SM_AFNetworking/SM_AFNetworkReachabilityManager.m"/>
|
||||||
<source-file src="src/ios/AFNetworking/AFSecurityPolicy.m"/>
|
<source-file src="src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m"/>
|
||||||
<source-file src="src/ios/AFNetworking/AFURLRequestSerialization.m"/>
|
<source-file src="src/ios/SM_AFNetworking/SM_AFURLRequestSerialization.m"/>
|
||||||
<source-file src="src/ios/AFNetworking/AFURLResponseSerialization.m"/>
|
<source-file src="src/ios/SM_AFNetworking/SM_AFURLResponseSerialization.m"/>
|
||||||
<source-file src="src/ios/AFNetworking/AFURLSessionManager.m"/>
|
<source-file src="src/ios/SM_AFNetworking/SM_AFURLSessionManager.m"/>
|
||||||
<source-file src="src/ios/SDNetworkActivityIndicator/SDNetworkActivityIndicator.m"/>
|
<source-file src="src/ios/SDNetworkActivityIndicator/SDNetworkActivityIndicator.m"/>
|
||||||
<framework src="Security.framework"/>
|
<framework src="Security.framework"/>
|
||||||
<framework src="SystemConfiguration.framework"/>
|
<framework src="SystemConfiguration.framework"/>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "AFURLRequestSerialization.h"
|
#import "SM_AFURLRequestSerialization.h"
|
||||||
|
|
||||||
@interface BinaryRequestSerializer : AFHTTPRequestSerializer
|
@interface BinaryRequestSerializer : AFHTTPRequestSerializer
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
return serializer;
|
return serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLRequestSerialization
|
#pragma mark - SM_AFURLRequestSerialization
|
||||||
|
|
||||||
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||||
withParameters:(id)parameters
|
withParameters:(id)parameters
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "AFURLResponseSerialization.h"
|
#import "SM_AFURLResponseSerialization.h"
|
||||||
|
|
||||||
@interface BinaryResponseSerializer : AFHTTPResponseSerializer
|
@interface BinaryResponseSerializer : AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
|||||||
@@ -85,20 +85,20 @@ static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger co
|
|||||||
if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
|
if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||||
if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
|
if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
|
||||||
NSMutableDictionary *mutableUserInfo = [@{
|
NSMutableDictionary *mutableUserInfo = [@{
|
||||||
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
|
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"SM_AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
|
||||||
NSURLErrorFailingURLErrorKey: [response URL],
|
NSURLErrorFailingURLErrorKey: [response URL],
|
||||||
AFNetworkingOperationFailingURLResponseErrorKey: response,
|
SM_AFNetworkingOperationFailingURLResponseErrorKey: response,
|
||||||
} mutableCopy];
|
} mutableCopy];
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
mutableUserInfo[SM_AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
||||||
|
|
||||||
// trying to decode error message in body
|
// trying to decode error message in body
|
||||||
mutableUserInfo[AFNetworkingOperationFailingURLResponseBodyErrorKey] = [self decodeResponseData:data withEncoding:[self getEncoding:response]];
|
mutableUserInfo[SM_AFNetworkingOperationFailingURLResponseBodyErrorKey] = [self decodeResponseData:data withEncoding:[self getEncoding:response]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = [NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo];
|
*error = [NSError errorWithDomain:SM_AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
@@ -108,14 +108,14 @@ static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger co
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLResponseSerialization
|
#pragma mark - SM_AFURLResponseSerialization
|
||||||
|
|
||||||
- (id)responseObjectForResponse:(NSURLResponse *)response
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
data:(NSData *)data
|
data:(NSData *)data
|
||||||
error:(NSError *__autoreleasing *)error
|
error:(NSError *__autoreleasing *)error
|
||||||
{
|
{
|
||||||
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, SM_AFURLResponseSerializationErrorDomain)) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,31 +4,31 @@
|
|||||||
#import "BinaryResponseSerializer.h"
|
#import "BinaryResponseSerializer.h"
|
||||||
#import "TextResponseSerializer.h"
|
#import "TextResponseSerializer.h"
|
||||||
#import "TextRequestSerializer.h"
|
#import "TextRequestSerializer.h"
|
||||||
#import "AFHTTPSessionManager.h"
|
#import "SM_AFHTTPSessionManager.h"
|
||||||
#import "SDNetworkActivityIndicator.h"
|
#import "SDNetworkActivityIndicator.h"
|
||||||
|
|
||||||
@interface CordovaHttpPlugin()
|
@interface CordovaHttpPlugin()
|
||||||
|
|
||||||
- (void)addRequest:(NSNumber*)reqId forTask:(NSURLSessionDataTask*)task;
|
- (void)addRequest:(NSNumber*)reqId forTask:(NSURLSessionDataTask*)task;
|
||||||
- (void)removeRequest:(NSNumber*)reqId;
|
- (void)removeRequest:(NSNumber*)reqId;
|
||||||
- (void)setRequestHeaders:(NSDictionary*)headers forManager:(AFHTTPSessionManager*)manager;
|
- (void)setRequestHeaders:(NSDictionary*)headers forManager:(SM_AFHTTPSessionManager*)manager;
|
||||||
- (void)handleSuccess:(NSMutableDictionary*)dictionary withResponse:(NSHTTPURLResponse*)response andData:(id)data;
|
- (void)handleSuccess:(NSMutableDictionary*)dictionary withResponse:(NSHTTPURLResponse*)response andData:(id)data;
|
||||||
- (void)handleError:(NSMutableDictionary*)dictionary withResponse:(NSHTTPURLResponse*)response error:(NSError*)error;
|
- (void)handleError:(NSMutableDictionary*)dictionary withResponse:(NSHTTPURLResponse*)response error:(NSError*)error;
|
||||||
- (NSNumber*)getStatusCode:(NSError*) error;
|
- (NSNumber*)getStatusCode:(NSError*) error;
|
||||||
- (NSMutableDictionary*)copyHeaderFields:(NSDictionary*)headerFields;
|
- (NSMutableDictionary*)copyHeaderFields:(NSDictionary*)headerFields;
|
||||||
- (void)setTimeout:(NSTimeInterval)timeout forManager:(AFHTTPSessionManager*)manager;
|
- (void)setTimeout:(NSTimeInterval)timeout forManager:(SM_AFHTTPSessionManager*)manager;
|
||||||
- (void)setRedirect:(bool)redirect forManager:(AFHTTPSessionManager*)manager;
|
- (void)setRedirect:(bool)redirect forManager:(SM_AFHTTPSessionManager*)manager;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation CordovaHttpPlugin {
|
@implementation CordovaHttpPlugin {
|
||||||
AFSecurityPolicy *securityPolicy;
|
SM_AFSecurityPolicy *securityPolicy;
|
||||||
NSURLCredential *x509Credential;
|
NSURLCredential *x509Credential;
|
||||||
NSMutableDictionary *reqDict;
|
NSMutableDictionary *reqDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)pluginInitialize {
|
- (void)pluginInitialize {
|
||||||
securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
|
securityPolicy = [SM_AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
|
||||||
reqDict = [NSMutableDictionary dictionary];
|
reqDict = [NSMutableDictionary dictionary];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
[reqDict removeObjectForKey:reqId];
|
[reqDict removeObjectForKey:reqId];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setRequestSerializer:(NSString*)serializerName forManager:(AFHTTPSessionManager*)manager {
|
- (void)setRequestSerializer:(NSString*)serializerName forManager:(SM_AFHTTPSessionManager*)manager {
|
||||||
if ([serializerName isEqualToString:@"json"]) {
|
if ([serializerName isEqualToString:@"json"]) {
|
||||||
manager.requestSerializer = [AFJSONRequestSerializer serializer];
|
manager.requestSerializer = [AFJSONRequestSerializer serializer];
|
||||||
} else if ([serializerName isEqualToString:@"utf8"]) {
|
} else if ([serializerName isEqualToString:@"utf8"]) {
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setupAuthChallengeBlock:(AFHTTPSessionManager*)manager {
|
- (void)setupAuthChallengeBlock:(SM_AFHTTPSessionManager*)manager {
|
||||||
[manager setSessionDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition(
|
[manager setSessionDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition(
|
||||||
NSURLSession * _Nonnull session,
|
NSURLSession * _Nonnull session,
|
||||||
NSURLAuthenticationChallenge * _Nonnull challenge,
|
NSURLAuthenticationChallenge * _Nonnull challenge,
|
||||||
@@ -79,13 +79,13 @@
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setRequestHeaders:(NSDictionary*)headers forManager:(AFHTTPSessionManager*)manager {
|
- (void)setRequestHeaders:(NSDictionary*)headers forManager:(SM_AFHTTPSessionManager*)manager {
|
||||||
[headers enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
[headers enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
[manager.requestSerializer setValue:obj forHTTPHeaderField:key];
|
[manager.requestSerializer setValue:obj forHTTPHeaderField:key];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setRedirect:(bool)followRedirect forManager:(AFHTTPSessionManager*)manager {
|
- (void)setRedirect:(bool)followRedirect forManager:(SM_AFHTTPSessionManager*)manager {
|
||||||
[manager setTaskWillPerformHTTPRedirectionBlock:^NSURLRequest * _Nonnull(NSURLSession * _Nonnull session,
|
[manager setTaskWillPerformHTTPRedirectionBlock:^NSURLRequest * _Nonnull(NSURLSession * _Nonnull session,
|
||||||
NSURLSessionTask * _Nonnull task, NSURLResponse * _Nonnull response, NSURLRequest * _Nonnull request) {
|
NSURLSessionTask * _Nonnull task, NSURLResponse * _Nonnull response, NSURLRequest * _Nonnull request) {
|
||||||
|
|
||||||
@@ -97,11 +97,11 @@
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTimeout:(NSTimeInterval)timeout forManager:(AFHTTPSessionManager*)manager {
|
- (void)setTimeout:(NSTimeInterval)timeout forManager:(SM_AFHTTPSessionManager*)manager {
|
||||||
[manager.requestSerializer setTimeoutInterval:timeout];
|
[manager.requestSerializer setTimeoutInterval:timeout];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setResponseSerializer:(NSString*)responseType forManager:(AFHTTPSessionManager*)manager {
|
- (void)setResponseSerializer:(NSString*)responseType forManager:(SM_AFHTTPSessionManager*)manager {
|
||||||
if ([responseType isEqualToString: @"text"] || [responseType isEqualToString: @"json"]) {
|
if ([responseType isEqualToString: @"text"] || [responseType isEqualToString: @"json"]) {
|
||||||
manager.responseSerializer = [TextResponseSerializer serializer];
|
manager.responseSerializer = [TextResponseSerializer serializer];
|
||||||
} else {
|
} else {
|
||||||
@@ -133,8 +133,8 @@
|
|||||||
[dictionary setObject:[self copyHeaderFields:response.allHeaderFields] forKey:@"headers"];
|
[dictionary setObject:[self copyHeaderFields:response.allHeaderFields] forKey:@"headers"];
|
||||||
if(!aborted){
|
if(!aborted){
|
||||||
[dictionary setObject:[NSNumber numberWithInt:(int)response.statusCode] forKey:@"status"];
|
[dictionary setObject:[NSNumber numberWithInt:(int)response.statusCode] forKey:@"status"];
|
||||||
if (error.userInfo[AFNetworkingOperationFailingURLResponseBodyErrorKey]) {
|
if (error.userInfo[SM_AFNetworkingOperationFailingURLResponseBodyErrorKey]) {
|
||||||
[dictionary setObject:error.userInfo[AFNetworkingOperationFailingURLResponseBodyErrorKey] forKey:@"error"];
|
[dictionary setObject:error.userInfo[SM_AFNetworkingOperationFailingURLResponseBodyErrorKey] forKey:@"error"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(!aborted) {
|
} else if(!aborted) {
|
||||||
@@ -193,7 +193,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)executeRequestWithoutData:(CDVInvokedUrlCommand*)command withMethod:(NSString*) method {
|
- (void)executeRequestWithoutData:(CDVInvokedUrlCommand*)command withMethod:(NSString*) method {
|
||||||
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
SM_AFHTTPSessionManager *manager = [SM_AFHTTPSessionManager manager];
|
||||||
|
|
||||||
NSString *url = [command.arguments objectAtIndex:0];
|
NSString *url = [command.arguments objectAtIndex:0];
|
||||||
NSDictionary *headers = [command.arguments objectAtIndex:1];
|
NSDictionary *headers = [command.arguments objectAtIndex:1];
|
||||||
@@ -253,7 +253,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)executeRequestWithData:(CDVInvokedUrlCommand*)command withMethod:(NSString*)method {
|
- (void)executeRequestWithData:(CDVInvokedUrlCommand*)command withMethod:(NSString*)method {
|
||||||
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
SM_AFHTTPSessionManager *manager = [SM_AFHTTPSessionManager manager];
|
||||||
|
|
||||||
NSString *url = [command.arguments objectAtIndex:0];
|
NSString *url = [command.arguments objectAtIndex:0];
|
||||||
NSDictionary *data = [command.arguments objectAtIndex:1];
|
NSDictionary *data = [command.arguments objectAtIndex:1];
|
||||||
@@ -351,15 +351,15 @@
|
|||||||
NSString *certMode = [command.arguments objectAtIndex:0];
|
NSString *certMode = [command.arguments objectAtIndex:0];
|
||||||
|
|
||||||
if ([certMode isEqualToString: @"default"] || [certMode isEqualToString: @"legacy"]) {
|
if ([certMode isEqualToString: @"default"] || [certMode isEqualToString: @"legacy"]) {
|
||||||
securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
|
securityPolicy = [SM_AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
|
||||||
securityPolicy.allowInvalidCertificates = NO;
|
securityPolicy.allowInvalidCertificates = NO;
|
||||||
securityPolicy.validatesDomainName = YES;
|
securityPolicy.validatesDomainName = YES;
|
||||||
} else if ([certMode isEqualToString: @"nocheck"]) {
|
} else if ([certMode isEqualToString: @"nocheck"]) {
|
||||||
securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
|
securityPolicy = [SM_AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
|
||||||
securityPolicy.allowInvalidCertificates = YES;
|
securityPolicy.allowInvalidCertificates = YES;
|
||||||
securityPolicy.validatesDomainName = NO;
|
securityPolicy.validatesDomainName = NO;
|
||||||
} else if ([certMode isEqualToString: @"pinned"]) {
|
} else if ([certMode isEqualToString: @"pinned"]) {
|
||||||
securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
|
securityPolicy = [SM_AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
|
||||||
securityPolicy.allowInvalidCertificates = NO;
|
securityPolicy.allowInvalidCertificates = NO;
|
||||||
securityPolicy.validatesDomainName = YES;
|
securityPolicy.validatesDomainName = YES;
|
||||||
}
|
}
|
||||||
@@ -442,7 +442,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)uploadFiles:(CDVInvokedUrlCommand*)command {
|
- (void)uploadFiles:(CDVInvokedUrlCommand*)command {
|
||||||
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
SM_AFHTTPSessionManager *manager = [SM_AFHTTPSessionManager manager];
|
||||||
|
|
||||||
NSString *url = [command.arguments objectAtIndex:0];
|
NSString *url = [command.arguments objectAtIndex:0];
|
||||||
NSDictionary *headers = [command.arguments objectAtIndex:1];
|
NSDictionary *headers = [command.arguments objectAtIndex:1];
|
||||||
@@ -510,7 +510,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)downloadFile:(CDVInvokedUrlCommand*)command {
|
- (void)downloadFile:(CDVInvokedUrlCommand*)command {
|
||||||
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
SM_AFHTTPSessionManager *manager = [SM_AFHTTPSessionManager manager];
|
||||||
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
|
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
|
||||||
|
|
||||||
NSString *url = [command.arguments objectAtIndex:0];
|
NSString *url = [command.arguments objectAtIndex:0];
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFHTTPSessionManager.h
|
// SM_AFHTTPSessionManager.h
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -31,14 +31,14 @@
|
|||||||
#import <CoreServices/CoreServices.h>
|
#import <CoreServices/CoreServices.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#import "AFURLSessionManager.h"
|
#import "SM_AFURLSessionManager.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
`AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths.
|
`SM_AFHTTPSessionManager` is a subclass of `SM_AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths.
|
||||||
|
|
||||||
## Subclassing Notes
|
## Subclassing Notes
|
||||||
|
|
||||||
Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application.
|
Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `SM_AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application.
|
||||||
|
|
||||||
For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect.
|
For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect.
|
||||||
|
|
||||||
@@ -48,9 +48,9 @@
|
|||||||
|
|
||||||
## Serialization
|
## Serialization
|
||||||
|
|
||||||
Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to `<AFURLRequestSerialization>`.
|
Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to `<SM_AFURLRequestSerialization>`.
|
||||||
|
|
||||||
Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `<AFURLResponseSerialization>`
|
Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `<SM_AFURLResponseSerialization>`
|
||||||
|
|
||||||
## URL Construction Using Relative Paths
|
## URL Construction Using Relative Paths
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface AFHTTPSessionManager : AFURLSessionManager <NSSecureCoding, NSCopying>
|
@interface SM_AFHTTPSessionManager : SM_AFURLSessionManager <NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods.
|
The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods.
|
||||||
@@ -85,26 +85,26 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@warning `requestSerializer` must not be `nil`.
|
@warning `requestSerializer` must not be `nil`.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, strong) AFHTTPRequestSerializer <AFURLRequestSerialization> * requestSerializer;
|
@property (nonatomic, strong) AFHTTPRequestSerializer <SM_AFURLRequestSerialization> * requestSerializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`.
|
Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`.
|
||||||
|
|
||||||
@warning `responseSerializer` must not be `nil`.
|
@warning `responseSerializer` must not be `nil`.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * responseSerializer;
|
@property (nonatomic, strong) AFHTTPResponseSerializer <SM_AFURLResponseSerialization> * responseSerializer;
|
||||||
|
|
||||||
///---------------------
|
///---------------------
|
||||||
/// @name Initialization
|
/// @name Initialization
|
||||||
///---------------------
|
///---------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates and returns an `AFHTTPSessionManager` object.
|
Creates and returns an `SM_AFHTTPSessionManager` object.
|
||||||
*/
|
*/
|
||||||
+ (instancetype)manager;
|
+ (instancetype)manager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes an `AFHTTPSessionManager` object with the specified base URL.
|
Initializes an `SM_AFHTTPSessionManager` object with the specified base URL.
|
||||||
|
|
||||||
@param url The base URL for the HTTP client.
|
@param url The base URL for the HTTP client.
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
- (instancetype)initWithBaseURL:(nullable NSURL *)url;
|
- (instancetype)initWithBaseURL:(nullable NSURL *)url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes an `AFHTTPSessionManager` object with the specified base URL.
|
Initializes an `SM_AFHTTPSessionManager` object with the specified base URL.
|
||||||
|
|
||||||
This is the designated initializer.
|
This is the designated initializer.
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFHTTPSessionManager.m
|
// SM_AFHTTPSessionManager.m
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -19,10 +19,10 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#import "AFHTTPSessionManager.h"
|
#import "SM_AFHTTPSessionManager.h"
|
||||||
|
|
||||||
#import "AFURLRequestSerialization.h"
|
#import "SM_AFURLRequestSerialization.h"
|
||||||
#import "AFURLResponseSerialization.h"
|
#import "SM_AFURLResponseSerialization.h"
|
||||||
|
|
||||||
#import <Availability.h>
|
#import <Availability.h>
|
||||||
#import <TargetConditionals.h>
|
#import <TargetConditionals.h>
|
||||||
@@ -40,11 +40,11 @@
|
|||||||
#import <WatchKit/WatchKit.h>
|
#import <WatchKit/WatchKit.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@interface AFHTTPSessionManager ()
|
@interface SM_AFHTTPSessionManager ()
|
||||||
@property (readwrite, nonatomic, strong) NSURL *baseURL;
|
@property (readwrite, nonatomic, strong) NSURL *baseURL;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AFHTTPSessionManager
|
@implementation SM_AFHTTPSessionManager
|
||||||
@dynamic responseSerializer;
|
@dynamic responseSerializer;
|
||||||
|
|
||||||
+ (instancetype)manager {
|
+ (instancetype)manager {
|
||||||
@@ -86,13 +86,13 @@
|
|||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
- (void)setRequestSerializer:(AFHTTPRequestSerializer <AFURLRequestSerialization> *)requestSerializer {
|
- (void)setRequestSerializer:(AFHTTPRequestSerializer <SM_AFURLRequestSerialization> *)requestSerializer {
|
||||||
NSParameterAssert(requestSerializer);
|
NSParameterAssert(requestSerializer);
|
||||||
|
|
||||||
_requestSerializer = requestSerializer;
|
_requestSerializer = requestSerializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setResponseSerializer:(AFHTTPResponseSerializer <AFURLResponseSerialization> *)responseSerializer {
|
- (void)setResponseSerializer:(AFHTTPResponseSerializer <SM_AFURLResponseSerialization> *)responseSerializer {
|
||||||
NSParameterAssert(responseSerializer);
|
NSParameterAssert(responseSerializer);
|
||||||
|
|
||||||
[super setResponseSerializer:responseSerializer];
|
[super setResponseSerializer:responseSerializer];
|
||||||
@@ -428,7 +428,7 @@
|
|||||||
|
|
||||||
self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))];
|
self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))];
|
||||||
self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];
|
self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];
|
||||||
AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))];
|
SM_AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[SM_AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))];
|
||||||
if (decodedPolicy) {
|
if (decodedPolicy) {
|
||||||
self.securityPolicy = decodedPolicy;
|
self.securityPolicy = decodedPolicy;
|
||||||
}
|
}
|
||||||
@@ -453,7 +453,7 @@
|
|||||||
#pragma mark - NSCopying
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
- (instancetype)copyWithZone:(NSZone *)zone {
|
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||||
AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration];
|
SM_AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration];
|
||||||
|
|
||||||
HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone];
|
HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone];
|
||||||
HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone];
|
HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone];
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFNetworkReachabilityManager.h
|
// SM_AFNetworkReachabilityManager.h
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -34,15 +34,15 @@ typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
|
|||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
`AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
|
`SM_AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
|
||||||
|
|
||||||
Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability.
|
Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability.
|
||||||
|
|
||||||
See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ )
|
See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ )
|
||||||
|
|
||||||
@warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
|
@warning Instances of `SM_AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
|
||||||
*/
|
*/
|
||||||
@interface AFNetworkReachabilityManager : NSObject
|
@interface SM_AFNetworkReachabilityManager : NSObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The current network reachability status.
|
The current network reachability status.
|
||||||
@@ -150,7 +150,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/**
|
/**
|
||||||
## Network Reachability
|
## Network Reachability
|
||||||
|
|
||||||
The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
|
The following constants are provided by `SM_AFNetworkReachabilityManager` as possible network reachability statuses.
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
AFNetworkReachabilityStatusUnknown,
|
AFNetworkReachabilityStatusUnknown,
|
||||||
@@ -175,8 +175,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
|
Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
|
||||||
|
|
||||||
`AFNetworkingReachabilityNotificationStatusItem`
|
`SM_AFNetworkingReachabilityNotificationStatusItem`
|
||||||
A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
|
A key in the userInfo dictionary in a `SM_AFNetworkingReachabilityDidChangeNotification` notification.
|
||||||
The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
|
The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -186,12 +186,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Posted when network reachability changes.
|
Posted when network reachability changes.
|
||||||
This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
|
This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `SM_AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
|
||||||
|
|
||||||
@warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
|
@warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingReachabilityDidChangeNotification;
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingReachabilityNotificationStatusItem;
|
||||||
|
|
||||||
///--------------------
|
///--------------------
|
||||||
/// @name Functions
|
/// @name Functions
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFNetworkReachabilityManager.m
|
// SM_AFNetworkReachabilityManager.m
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#import "AFNetworkReachabilityManager.h"
|
#import "SM_AFNetworkReachabilityManager.h"
|
||||||
#if !TARGET_OS_WATCH
|
#if !TARGET_OS_WATCH
|
||||||
|
|
||||||
#import <netinet/in.h>
|
#import <netinet/in.h>
|
||||||
@@ -28,22 +28,22 @@
|
|||||||
#import <ifaddrs.h>
|
#import <ifaddrs.h>
|
||||||
#import <netdb.h>
|
#import <netdb.h>
|
||||||
|
|
||||||
NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
|
NSString * const SM_AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
|
||||||
NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem";
|
NSString * const SM_AFNetworkingReachabilityNotificationStatusItem = @"SM_AFNetworkingReachabilityNotificationStatusItem";
|
||||||
|
|
||||||
typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
|
typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
|
||||||
|
|
||||||
NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) {
|
NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case AFNetworkReachabilityStatusNotReachable:
|
case AFNetworkReachabilityStatusNotReachable:
|
||||||
return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil);
|
return NSLocalizedStringFromTable(@"Not Reachable", @"SM_AFNetworking", nil);
|
||||||
case AFNetworkReachabilityStatusReachableViaWWAN:
|
case AFNetworkReachabilityStatusReachableViaWWAN:
|
||||||
return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil);
|
return NSLocalizedStringFromTable(@"Reachable via WWAN", @"SM_AFNetworking", nil);
|
||||||
case AFNetworkReachabilityStatusReachableViaWiFi:
|
case AFNetworkReachabilityStatusReachableViaWiFi:
|
||||||
return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil);
|
return NSLocalizedStringFromTable(@"Reachable via WiFi", @"SM_AFNetworking", nil);
|
||||||
case AFNetworkReachabilityStatusUnknown:
|
case AFNetworkReachabilityStatusUnknown:
|
||||||
default:
|
default:
|
||||||
return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil);
|
return NSLocalizedStringFromTable(@"Unknown", @"SM_AFNetworking", nil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,8 +85,8 @@ static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFN
|
|||||||
block(status);
|
block(status);
|
||||||
}
|
}
|
||||||
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||||
NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) };
|
NSDictionary *userInfo = @{ SM_AFNetworkingReachabilityNotificationStatusItem: @(status) };
|
||||||
[notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo];
|
[notificationCenter postNotificationName:SM_AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,16 +105,16 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface AFNetworkReachabilityManager ()
|
@interface SM_AFNetworkReachabilityManager ()
|
||||||
@property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability;
|
@property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability;
|
||||||
@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
|
@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
|
||||||
@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
|
@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AFNetworkReachabilityManager
|
@implementation SM_AFNetworkReachabilityManager
|
||||||
|
|
||||||
+ (instancetype)sharedManager {
|
+ (instancetype)sharedManager {
|
||||||
static AFNetworkReachabilityManager *_sharedManager = nil;
|
static SM_AFNetworkReachabilityManager *_sharedManager = nil;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
_sharedManager = [self manager];
|
_sharedManager = [self manager];
|
||||||
@@ -126,7 +126,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
|
|||||||
+ (instancetype)managerForDomain:(NSString *)domain {
|
+ (instancetype)managerForDomain:(NSString *)domain {
|
||||||
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]);
|
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]);
|
||||||
|
|
||||||
AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
|
SM_AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
|
||||||
|
|
||||||
CFRelease(reachability);
|
CFRelease(reachability);
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
|
|||||||
|
|
||||||
+ (instancetype)managerForAddress:(const void *)address {
|
+ (instancetype)managerForAddress:(const void *)address {
|
||||||
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address);
|
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address);
|
||||||
AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
|
SM_AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
|
||||||
|
|
||||||
CFRelease(reachability);
|
CFRelease(reachability);
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// AFNetworking.h
|
// SM_AFNetworking.h
|
||||||
//
|
//
|
||||||
// Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
|
// Copyright (c) 2013 SM_AFNetworking (http://afnetworking.com/)
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -27,15 +27,15 @@
|
|||||||
#ifndef _AFNETWORKING_
|
#ifndef _AFNETWORKING_
|
||||||
#define _AFNETWORKING_
|
#define _AFNETWORKING_
|
||||||
|
|
||||||
#import "AFURLRequestSerialization.h"
|
#import "SM_AFURLRequestSerialization.h"
|
||||||
#import "AFURLResponseSerialization.h"
|
#import "SM_AFURLResponseSerialization.h"
|
||||||
#import "AFSecurityPolicy.h"
|
#import "SM_AFSecurityPolicy.h"
|
||||||
|
|
||||||
#if !TARGET_OS_WATCH
|
#if !TARGET_OS_WATCH
|
||||||
#import "AFNetworkReachabilityManager.h"
|
#import "SM_AFNetworkReachabilityManager.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#import "AFURLSessionManager.h"
|
#import "SM_AFURLSessionManager.h"
|
||||||
#import "AFHTTPSessionManager.h"
|
#import "SM_AFHTTPSessionManager.h"
|
||||||
|
|
||||||
#endif /* _AFNETWORKING_ */
|
#endif /* _AFNETWORKING_ */
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFSecurityPolicy.h
|
// SM_AFSecurityPolicy.h
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -29,14 +29,14 @@ typedef NS_ENUM(NSUInteger, AFSSLPinningMode) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
`AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
|
`SM_AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
|
||||||
|
|
||||||
Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.
|
Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface AFSecurityPolicy : NSObject <NSSecureCoding, NSCopying>
|
@interface SM_AFSecurityPolicy : NSObject <NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`.
|
The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`.
|
||||||
@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/**
|
/**
|
||||||
The certificates used to evaluate server trust according to the SSL pinning mode.
|
The certificates used to evaluate server trust according to the SSL pinning mode.
|
||||||
|
|
||||||
By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`.
|
By default, this property is set to any (`.cer`) certificates included in the target compiling SM_AFNetworking. Note that if you are using SM_AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`.
|
||||||
|
|
||||||
Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
|
Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
|
||||||
*/
|
*/
|
||||||
@@ -67,7 +67,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
///-----------------------------------------
|
///-----------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`.
|
Returns any certificates included in the bundle. If you are using SM_AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`.
|
||||||
|
|
||||||
@return The certificates included in the given bundle.
|
@return The certificates included in the given bundle.
|
||||||
*/
|
*/
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFSecurityPolicy.m
|
// SM_AFSecurityPolicy.m
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#import "AFSecurityPolicy.h"
|
#import "SM_AFSecurityPolicy.h"
|
||||||
|
|
||||||
#import <AssertMacros.h>
|
#import <AssertMacros.h>
|
||||||
|
|
||||||
@@ -148,12 +148,12 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
|||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
@interface AFSecurityPolicy()
|
@interface SM_AFSecurityPolicy()
|
||||||
@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
|
@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
|
||||||
@property (readwrite, nonatomic, strong) NSSet *pinnedPublicKeys;
|
@property (readwrite, nonatomic, strong) NSSet *pinnedPublicKeys;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AFSecurityPolicy
|
@implementation SM_AFSecurityPolicy
|
||||||
|
|
||||||
+ (NSSet *)certificatesInBundle:(NSBundle *)bundle {
|
+ (NSSet *)certificatesInBundle:(NSBundle *)bundle {
|
||||||
NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"www/certificates"];
|
NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"www/certificates"];
|
||||||
@@ -179,7 +179,7 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ (instancetype)defaultPolicy {
|
+ (instancetype)defaultPolicy {
|
||||||
AFSecurityPolicy *securityPolicy = [[self alloc] init];
|
SM_AFSecurityPolicy *securityPolicy = [[self alloc] init];
|
||||||
securityPolicy.SSLPinningMode = AFSSLPinningModeNone;
|
securityPolicy.SSLPinningMode = AFSSLPinningModeNone;
|
||||||
|
|
||||||
return securityPolicy;
|
return securityPolicy;
|
||||||
@@ -190,7 +190,7 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates {
|
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates {
|
||||||
AFSecurityPolicy *securityPolicy = [[self alloc] init];
|
SM_AFSecurityPolicy *securityPolicy = [[self alloc] init];
|
||||||
securityPolicy.SSLPinningMode = pinningMode;
|
securityPolicy.SSLPinningMode = pinningMode;
|
||||||
|
|
||||||
[securityPolicy setPinnedCertificates:pinnedCertificates];
|
[securityPolicy setPinnedCertificates:pinnedCertificates];
|
||||||
@@ -341,7 +341,7 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
|||||||
#pragma mark - NSCopying
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
- (instancetype)copyWithZone:(NSZone *)zone {
|
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||||
AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init];
|
SM_AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init];
|
||||||
securityPolicy.SSLPinningMode = self.SSLPinningMode;
|
securityPolicy.SSLPinningMode = self.SSLPinningMode;
|
||||||
securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates;
|
securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates;
|
||||||
securityPolicy.validatesDomainName = self.validatesDomainName;
|
securityPolicy.validatesDomainName = self.validatesDomainName;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFURLRequestSerialization.h
|
// SM_AFURLRequestSerialization.h
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -56,11 +56,11 @@ FOUNDATION_EXPORT NSString * AFPercentEscapedStringFromString(NSString *string);
|
|||||||
FOUNDATION_EXPORT NSString * AFQueryStringFromParameters(NSDictionary *parameters);
|
FOUNDATION_EXPORT NSString * AFQueryStringFromParameters(NSDictionary *parameters);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary.
|
The `SM_AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary.
|
||||||
|
|
||||||
For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`.
|
For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`.
|
||||||
*/
|
*/
|
||||||
@protocol AFURLRequestSerialization <NSObject, NSSecureCoding, NSCopying>
|
@protocol SM_AFURLRequestSerialization <NSObject, NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a request with the specified parameters encoded into a copy of the original request.
|
Returns a request with the specified parameters encoded into a copy of the original request.
|
||||||
@@ -89,11 +89,11 @@ typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) {
|
|||||||
@protocol AFMultipartFormData;
|
@protocol AFMultipartFormData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
`AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
|
`AFHTTPRequestSerializer` conforms to the `SM_AFURLRequestSerialization` & `SM_AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
|
||||||
|
|
||||||
Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior.
|
Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior.
|
||||||
*/
|
*/
|
||||||
@interface AFHTTPRequestSerializer : NSObject <AFURLRequestSerialization>
|
@interface AFHTTPRequestSerializer : NSObject <SM_AFURLRequestSerialization>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default.
|
The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default.
|
||||||
@@ -265,7 +265,7 @@ forHTTPHeaderField:(NSString *)field;
|
|||||||
@param fileURL The file URL to write multipart form contents to.
|
@param fileURL The file URL to write multipart form contents to.
|
||||||
@param handler A handler block to execute.
|
@param handler A handler block to execute.
|
||||||
|
|
||||||
@discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request.
|
@discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `SM_AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request.
|
||||||
|
|
||||||
@see https://github.com/AFNetworking/AFNetworking/issues/1398
|
@see https://github.com/AFNetworking/AFNetworking/issues/1398
|
||||||
*/
|
*/
|
||||||
@@ -437,28 +437,28 @@ forHTTPHeaderField:(NSString *)field;
|
|||||||
|
|
||||||
The following error domain is predefined.
|
The following error domain is predefined.
|
||||||
|
|
||||||
- `NSString * const AFURLRequestSerializationErrorDomain`
|
- `NSString * const SM_AFURLRequestSerializationErrorDomain`
|
||||||
|
|
||||||
### Constants
|
### Constants
|
||||||
|
|
||||||
`AFURLRequestSerializationErrorDomain`
|
`SM_AFURLRequestSerializationErrorDomain`
|
||||||
AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
|
AFURLRequestSerializer errors. Error codes for `SM_AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain;
|
FOUNDATION_EXPORT NSString * const SM_AFURLRequestSerializationErrorDomain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
## User info dictionary keys
|
## User info dictionary keys
|
||||||
|
|
||||||
These keys may exist in the user info dictionary, in addition to those defined for NSError.
|
These keys may exist in the user info dictionary, in addition to those defined for NSError.
|
||||||
|
|
||||||
- `NSString * const AFNetworkingOperationFailingURLRequestErrorKey`
|
- `NSString * const SM_AFNetworkingOperationFailingURLRequestErrorKey`
|
||||||
|
|
||||||
### Constants
|
### Constants
|
||||||
|
|
||||||
`AFNetworkingOperationFailingURLRequestErrorKey`
|
`SM_AFNetworkingOperationFailingURLRequestErrorKey`
|
||||||
The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`.
|
The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `SM_AFURLRequestSerializationErrorDomain`.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingOperationFailingURLRequestErrorKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
## Throttling Bandwidth for HTTP Request Input Streams
|
## Throttling Bandwidth for HTTP Request Input Streams
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFURLRequestSerialization.m
|
// SM_AFURLRequestSerialization.m
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#import "AFURLRequestSerialization.h"
|
#import "SM_AFURLRequestSerialization.h"
|
||||||
|
|
||||||
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
|
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
|
||||||
#import <MobileCoreServices/MobileCoreServices.h>
|
#import <MobileCoreServices/MobileCoreServices.h>
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
#import <CoreServices/CoreServices.h>
|
#import <CoreServices/CoreServices.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request";
|
NSString * const SM_AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request";
|
||||||
NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response";
|
NSString * const SM_AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response";
|
||||||
|
|
||||||
typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, id parameters, NSError *__autoreleasing *error);
|
typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, id parameters, NSError *__autoreleasing *error);
|
||||||
|
|
||||||
@@ -455,7 +455,7 @@ forHTTPHeaderField:(NSString *)field
|
|||||||
return mutableRequest;
|
return mutableRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLRequestSerialization
|
#pragma mark - SM_AFURLRequestSerialization
|
||||||
|
|
||||||
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||||
withParameters:(id)parameters
|
withParameters:(id)parameters
|
||||||
@@ -686,16 +686,16 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
|
|||||||
NSParameterAssert(mimeType);
|
NSParameterAssert(mimeType);
|
||||||
|
|
||||||
if (![fileURL isFileURL]) {
|
if (![fileURL isFileURL]) {
|
||||||
NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)};
|
NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"SM_AFNetworking", nil)};
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo];
|
*error = [[NSError alloc] initWithDomain:SM_AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
} else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) {
|
} else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) {
|
||||||
NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)};
|
NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"SM_AFNetworking", nil)};
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo];
|
*error = [[NSError alloc] initWithDomain:SM_AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
@@ -1211,7 +1211,7 @@ typedef enum {
|
|||||||
return serializer;
|
return serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLRequestSerialization
|
#pragma mark - SM_AFURLRequestSerialization
|
||||||
|
|
||||||
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||||
withParameters:(id)parameters
|
withParameters:(id)parameters
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFURLResponseSerialization.h
|
// SM_AFURLResponseSerialization.h
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -25,11 +25,11 @@
|
|||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data.
|
The `SM_AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data.
|
||||||
|
|
||||||
For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object.
|
For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object.
|
||||||
*/
|
*/
|
||||||
@protocol AFURLResponseSerialization <NSObject, NSSecureCoding, NSCopying>
|
@protocol SM_AFURLResponseSerialization <NSObject, NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The response object decoded from the data associated with a specified response.
|
The response object decoded from the data associated with a specified response.
|
||||||
@@ -49,11 +49,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
/**
|
/**
|
||||||
`AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
|
`AFHTTPResponseSerializer` conforms to the `SM_AFURLRequestSerialization` & `SM_AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
|
||||||
|
|
||||||
Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior.
|
Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior.
|
||||||
*/
|
*/
|
||||||
@interface AFHTTPResponseSerializer : NSObject <AFURLResponseSerialization>
|
@interface AFHTTPResponseSerializer : NSObject <SM_AFURLResponseSerialization>
|
||||||
|
|
||||||
- (instancetype)init;
|
- (instancetype)init;
|
||||||
|
|
||||||
@@ -259,14 +259,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/**
|
/**
|
||||||
The component response serializers.
|
The component response serializers.
|
||||||
*/
|
*/
|
||||||
@property (readonly, nonatomic, copy) NSArray <id<AFURLResponseSerialization>> *responseSerializers;
|
@property (readonly, nonatomic, copy) NSArray <id<SM_AFURLResponseSerialization>> *responseSerializers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates and returns a compound serializer comprised of the specified response serializers.
|
Creates and returns a compound serializer comprised of the specified response serializers.
|
||||||
|
|
||||||
@warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`.
|
@warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`.
|
||||||
*/
|
*/
|
||||||
+ (instancetype)compoundSerializerWithResponseSerializers:(NSArray <id<AFURLResponseSerialization>> *)responseSerializers;
|
+ (instancetype)compoundSerializerWithResponseSerializers:(NSArray <id<SM_AFURLResponseSerialization>> *)responseSerializers;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -279,40 +279,40 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
The following error domain is predefined.
|
The following error domain is predefined.
|
||||||
|
|
||||||
- `NSString * const AFURLResponseSerializationErrorDomain`
|
- `NSString * const SM_AFURLResponseSerializationErrorDomain`
|
||||||
|
|
||||||
### Constants
|
### Constants
|
||||||
|
|
||||||
`AFURLResponseSerializationErrorDomain`
|
`SM_AFURLResponseSerializationErrorDomain`
|
||||||
AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
|
AFURLResponseSerializer errors. Error codes for `SM_AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain;
|
FOUNDATION_EXPORT NSString * const SM_AFURLResponseSerializationErrorDomain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
## User info dictionary keys
|
## User info dictionary keys
|
||||||
|
|
||||||
These keys may exist in the user info dictionary, in addition to those defined for NSError.
|
These keys may exist in the user info dictionary, in addition to those defined for NSError.
|
||||||
|
|
||||||
- `NSString * const AFNetworkingOperationFailingURLResponseErrorKey`
|
- `NSString * const SM_AFNetworkingOperationFailingURLResponseErrorKey`
|
||||||
- `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey`
|
- `NSString * const SM_AFNetworkingOperationFailingURLResponseDataErrorKey`
|
||||||
|
|
||||||
### Constants
|
### Constants
|
||||||
|
|
||||||
`AFNetworkingOperationFailingURLResponseErrorKey`
|
`SM_AFNetworkingOperationFailingURLResponseErrorKey`
|
||||||
The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
|
The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `SM_AFURLResponseSerializationErrorDomain`.
|
||||||
|
|
||||||
`AFNetworkingOperationFailingURLResponseDataErrorKey`
|
`SM_AFNetworkingOperationFailingURLResponseDataErrorKey`
|
||||||
The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
|
The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `SM_AFURLResponseSerializationErrorDomain`.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingOperationFailingURLResponseErrorKey;
|
||||||
|
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingOperationFailingURLResponseDataErrorKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
`AFNetworkingOperationFailingURLResponseBodyErrorKey`
|
`SM_AFNetworkingOperationFailingURLResponseBodyErrorKey`
|
||||||
The corresponding value is an `NSString` containing the decoded error message.
|
The corresponding value is an `NSString` containing the decoded error message.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseBodyErrorKey;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingOperationFailingURLResponseBodyErrorKey;
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFURLResponseSerialization.m
|
// SM_AFURLResponseSerialization.m
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#import "AFURLResponseSerialization.h"
|
#import "SM_AFURLResponseSerialization.h"
|
||||||
|
|
||||||
#import <TargetConditionals.h>
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
@@ -31,10 +31,10 @@
|
|||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response";
|
NSString * const SM_AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response";
|
||||||
NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response";
|
NSString * const SM_AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response";
|
||||||
NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data";
|
NSString * const SM_AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data";
|
||||||
NSString * const AFNetworkingOperationFailingURLResponseBodyErrorKey = @"com.alamofire.serialization.response.error.body";
|
NSString * const SM_AFNetworkingOperationFailingURLResponseBodyErrorKey = @"com.alamofire.serialization.response.error.body";
|
||||||
|
|
||||||
static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) {
|
static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@@ -121,15 +121,15 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
|
|||||||
|
|
||||||
if ([data length] > 0 && [response URL]) {
|
if ([data length] > 0 && [response URL]) {
|
||||||
NSMutableDictionary *mutableUserInfo = [@{
|
NSMutableDictionary *mutableUserInfo = [@{
|
||||||
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]],
|
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"SM_AFNetworking", nil), [response MIMEType]],
|
||||||
NSURLErrorFailingURLErrorKey:[response URL],
|
NSURLErrorFailingURLErrorKey:[response URL],
|
||||||
AFNetworkingOperationFailingURLResponseErrorKey: response,
|
SM_AFNetworkingOperationFailingURLResponseErrorKey: response,
|
||||||
} mutableCopy];
|
} mutableCopy];
|
||||||
if (data) {
|
if (data) {
|
||||||
mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
mutableUserInfo[SM_AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError);
|
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:SM_AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError);
|
||||||
}
|
}
|
||||||
|
|
||||||
responseIsValid = NO;
|
responseIsValid = NO;
|
||||||
@@ -137,16 +137,16 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
|
|||||||
|
|
||||||
if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
|
if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
|
||||||
NSMutableDictionary *mutableUserInfo = [@{
|
NSMutableDictionary *mutableUserInfo = [@{
|
||||||
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
|
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"SM_AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
|
||||||
NSURLErrorFailingURLErrorKey:[response URL],
|
NSURLErrorFailingURLErrorKey:[response URL],
|
||||||
AFNetworkingOperationFailingURLResponseErrorKey: response,
|
SM_AFNetworkingOperationFailingURLResponseErrorKey: response,
|
||||||
} mutableCopy];
|
} mutableCopy];
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
mutableUserInfo[SM_AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
|
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:SM_AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
|
||||||
|
|
||||||
responseIsValid = NO;
|
responseIsValid = NO;
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
|
|||||||
return responseIsValid;
|
return responseIsValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLResponseSerialization
|
#pragma mark - SM_AFURLResponseSerialization
|
||||||
|
|
||||||
- (id)responseObjectForResponse:(NSURLResponse *)response
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
data:(NSData *)data
|
data:(NSData *)data
|
||||||
@@ -231,14 +231,14 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLResponseSerialization
|
#pragma mark - SM_AFURLResponseSerialization
|
||||||
|
|
||||||
- (id)responseObjectForResponse:(NSURLResponse *)response
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
data:(NSData *)data
|
data:(NSData *)data
|
||||||
error:(NSError *__autoreleasing *)error
|
error:(NSError *__autoreleasing *)error
|
||||||
{
|
{
|
||||||
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, SM_AFURLResponseSerializationErrorDomain)) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -319,14 +319,14 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLResponseSerialization
|
#pragma mark - SM_AFURLResponseSerialization
|
||||||
|
|
||||||
- (id)responseObjectForResponse:(NSHTTPURLResponse *)response
|
- (id)responseObjectForResponse:(NSHTTPURLResponse *)response
|
||||||
data:(NSData *)data
|
data:(NSData *)data
|
||||||
error:(NSError *__autoreleasing *)error
|
error:(NSError *__autoreleasing *)error
|
||||||
{
|
{
|
||||||
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, SM_AFURLResponseSerializationErrorDomain)) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,14 +364,14 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLResponseSerialization
|
#pragma mark - SM_AFURLResponseSerialization
|
||||||
|
|
||||||
- (id)responseObjectForResponse:(NSURLResponse *)response
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
data:(NSData *)data
|
data:(NSData *)data
|
||||||
error:(NSError *__autoreleasing *)error
|
error:(NSError *__autoreleasing *)error
|
||||||
{
|
{
|
||||||
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, SM_AFURLResponseSerializationErrorDomain)) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -447,14 +447,14 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLResponseSerialization
|
#pragma mark - SM_AFURLResponseSerialization
|
||||||
|
|
||||||
- (id)responseObjectForResponse:(NSURLResponse *)response
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
data:(NSData *)data
|
data:(NSData *)data
|
||||||
error:(NSError *__autoreleasing *)error
|
error:(NSError *__autoreleasing *)error
|
||||||
{
|
{
|
||||||
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, SM_AFURLResponseSerializationErrorDomain)) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -512,13 +512,13 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
|
|||||||
#import <CoreGraphics/CoreGraphics.h>
|
#import <CoreGraphics/CoreGraphics.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@interface UIImage (AFNetworkingSafeImageLoading)
|
@interface UIImage (SM_AFNetworkingSafeImageLoading)
|
||||||
+ (UIImage *)af_safeImageWithData:(NSData *)data;
|
+ (UIImage *)af_safeImageWithData:(NSData *)data;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static NSLock* imageLock = nil;
|
static NSLock* imageLock = nil;
|
||||||
|
|
||||||
@implementation UIImage (AFNetworkingSafeImageLoading)
|
@implementation UIImage (SM_AFNetworkingSafeImageLoading)
|
||||||
|
|
||||||
+ (UIImage *)af_safeImageWithData:(NSData *)data {
|
+ (UIImage *)af_safeImageWithData:(NSData *)data {
|
||||||
UIImage* image = nil;
|
UIImage* image = nil;
|
||||||
@@ -666,7 +666,7 @@ static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *r
|
|||||||
error:(NSError *__autoreleasing *)error
|
error:(NSError *__autoreleasing *)error
|
||||||
{
|
{
|
||||||
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, SM_AFURLResponseSerializationErrorDomain)) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -750,13 +750,13 @@ static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *r
|
|||||||
return serializer;
|
return serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLResponseSerialization
|
#pragma mark - SM_AFURLResponseSerialization
|
||||||
|
|
||||||
- (id)responseObjectForResponse:(NSURLResponse *)response
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
data:(NSData *)data
|
data:(NSData *)data
|
||||||
error:(NSError *__autoreleasing *)error
|
error:(NSError *__autoreleasing *)error
|
||||||
{
|
{
|
||||||
for (id <AFURLResponseSerialization> serializer in self.responseSerializers) {
|
for (id <SM_AFURLResponseSerialization> serializer in self.responseSerializers) {
|
||||||
if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) {
|
if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFURLSessionManager.h
|
// SM_AFURLSessionManager.h
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -22,23 +22,23 @@
|
|||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#import "AFURLResponseSerialization.h"
|
#import "SM_AFURLResponseSerialization.h"
|
||||||
#import "AFURLRequestSerialization.h"
|
#import "SM_AFURLRequestSerialization.h"
|
||||||
#import "AFSecurityPolicy.h"
|
#import "SM_AFSecurityPolicy.h"
|
||||||
#if !TARGET_OS_WATCH
|
#if !TARGET_OS_WATCH
|
||||||
#import "AFNetworkReachabilityManager.h"
|
#import "SM_AFNetworkReachabilityManager.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
|
`SM_AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
|
||||||
|
|
||||||
## Subclassing Notes
|
## Subclassing Notes
|
||||||
|
|
||||||
This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead.
|
This is the base class for `SM_AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `SM_AFURLSessionManager` specifically for HTTP, consider subclassing `SM_AFHTTPSessionManager` instead.
|
||||||
|
|
||||||
## NSURLSession & NSURLSessionTask Delegate Methods
|
## NSURLSession & NSURLSessionTask Delegate Methods
|
||||||
|
|
||||||
`AFURLSessionManager` implements the following delegate methods:
|
`SM_AFURLSessionManager` implements the following delegate methods:
|
||||||
|
|
||||||
### `NSURLSessionDelegate`
|
### `NSURLSessionDelegate`
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
|
|
||||||
## Network Reachability Monitoring
|
## Network Reachability Monitoring
|
||||||
|
|
||||||
Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details.
|
Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `SM_AFNetworkReachabilityManager` for more details.
|
||||||
|
|
||||||
## NSCoding Caveats
|
## NSCoding Caveats
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface AFURLSessionManager : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate, NSSecureCoding, NSCopying>
|
@interface SM_AFURLSessionManager : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate, NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The managed session.
|
The managed session.
|
||||||
@@ -104,16 +104,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@warning `responseSerializer` must not be `nil`.
|
@warning `responseSerializer` must not be `nil`.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, strong) id <AFURLResponseSerialization> responseSerializer;
|
@property (nonatomic, strong) id <SM_AFURLResponseSerialization> responseSerializer;
|
||||||
|
|
||||||
///-------------------------------
|
///-------------------------------
|
||||||
/// @name Managing Security Policy
|
/// @name Managing Security Policy
|
||||||
///-------------------------------
|
///-------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified.
|
The security policy used by created session to evaluate server trust for secure connections. `SM_AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
|
@property (nonatomic, strong) SM_AFSecurityPolicy *securityPolicy;
|
||||||
|
|
||||||
#if !TARGET_OS_WATCH
|
#if !TARGET_OS_WATCH
|
||||||
///--------------------------------------
|
///--------------------------------------
|
||||||
@@ -121,9 +121,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
///--------------------------------------
|
///--------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default.
|
The network reachability manager. `SM_AFURLSessionManager` uses the `sharedManager` by default.
|
||||||
*/
|
*/
|
||||||
@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager;
|
@property (readwrite, nonatomic, strong) SM_AFNetworkReachabilityManager *reachabilityManager;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
///----------------------------
|
///----------------------------
|
||||||
@@ -450,17 +450,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/**
|
/**
|
||||||
Posted when a task resumes.
|
Posted when a task resumes.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidResumeNotification;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingTaskDidResumeNotification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task.
|
Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteNotification;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingTaskDidCompleteNotification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Posted when a task suspends its execution.
|
Posted when a task suspends its execution.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidSuspendNotification;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingTaskDidSuspendNotification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Posted when a session is invalidated.
|
Posted when a session is invalidated.
|
||||||
@@ -473,28 +473,28 @@ FOUNDATION_EXPORT NSString * const AFURLSessionDidInvalidateNotification;
|
|||||||
FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification;
|
FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if response data exists for the task.
|
The raw response data of the task. Included in the userInfo dictionary of the `SM_AFNetworkingTaskDidCompleteNotification` if response data exists for the task.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseDataKey;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingTaskDidCompleteResponseDataKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the response was serialized.
|
The serialized response object of the task. Included in the userInfo dictionary of the `SM_AFNetworkingTaskDidCompleteNotification` if the response was serialized.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingTaskDidCompleteSerializedResponseKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the task has an associated response serializer.
|
The response serializer used to serialize the response. Included in the userInfo dictionary of the `SM_AFNetworkingTaskDidCompleteNotification` if the task has an associated response serializer.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingTaskDidCompleteResponseSerializerKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an the response data has been stored directly to disk.
|
The file path associated with the download task. Included in the userInfo dictionary of the `SM_AFNetworkingTaskDidCompleteNotification` if an the response data has been stored directly to disk.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingTaskDidCompleteAssetPathKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an error exists.
|
Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `SM_AFNetworkingTaskDidCompleteNotification` if an error exists.
|
||||||
*/
|
*/
|
||||||
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey;
|
FOUNDATION_EXPORT NSString * const SM_AFNetworkingTaskDidCompleteErrorKey;
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// AFURLSessionManager.m
|
// SM_AFURLSessionManager.m
|
||||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#import "AFURLSessionManager.h"
|
#import "SM_AFURLSessionManager.h"
|
||||||
#import <objc/runtime.h>
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
#ifndef NSFoundationVersionNumber_iOS_8_0
|
#ifndef NSFoundationVersionNumber_iOS_8_0
|
||||||
@@ -69,19 +69,19 @@ static dispatch_group_t url_session_manager_completion_group() {
|
|||||||
return af_url_session_manager_completion_group;
|
return af_url_session_manager_completion_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume";
|
NSString * const SM_AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume";
|
||||||
NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete";
|
NSString * const SM_AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete";
|
||||||
NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend";
|
NSString * const SM_AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend";
|
||||||
NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate";
|
NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate";
|
||||||
NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error";
|
NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error";
|
||||||
|
|
||||||
NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse";
|
NSString * const SM_AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse";
|
||||||
NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer";
|
NSString * const SM_AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer";
|
||||||
NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata";
|
NSString * const SM_AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata";
|
||||||
NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error";
|
NSString * const SM_AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error";
|
||||||
NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath";
|
NSString * const SM_AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath";
|
||||||
|
|
||||||
static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock";
|
static NSString * const SM_AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock";
|
||||||
|
|
||||||
static NSUInteger const AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask = 3;
|
static NSUInteger const AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask = 3;
|
||||||
|
|
||||||
@@ -111,8 +111,8 @@ typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id re
|
|||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
@interface AFURLSessionManagerTaskDelegate : NSObject <NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate>
|
@interface SM_AFURLSessionManagerTaskDelegate : NSObject <NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate>
|
||||||
@property (nonatomic, weak) AFURLSessionManager *manager;
|
@property (nonatomic, weak) SM_AFURLSessionManager *manager;
|
||||||
@property (nonatomic, strong) NSMutableData *mutableData;
|
@property (nonatomic, strong) NSMutableData *mutableData;
|
||||||
@property (nonatomic, strong) NSProgress *uploadProgress;
|
@property (nonatomic, strong) NSProgress *uploadProgress;
|
||||||
@property (nonatomic, strong) NSProgress *downloadProgress;
|
@property (nonatomic, strong) NSProgress *downloadProgress;
|
||||||
@@ -123,7 +123,7 @@ typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id re
|
|||||||
@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler;
|
@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AFURLSessionManagerTaskDelegate
|
@implementation SM_AFURLSessionManagerTaskDelegate
|
||||||
|
|
||||||
- (instancetype)init {
|
- (instancetype)init {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
@@ -249,12 +249,12 @@ typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id re
|
|||||||
task:(NSURLSessionTask *)task
|
task:(NSURLSessionTask *)task
|
||||||
didCompleteWithError:(NSError *)error
|
didCompleteWithError:(NSError *)error
|
||||||
{
|
{
|
||||||
__strong AFURLSessionManager *manager = self.manager;
|
__strong SM_AFURLSessionManager *manager = self.manager;
|
||||||
|
|
||||||
__block id responseObject = nil;
|
__block id responseObject = nil;
|
||||||
|
|
||||||
__block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
__block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||||
userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer;
|
userInfo[SM_AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer;
|
||||||
|
|
||||||
//Performance Improvement from #2672
|
//Performance Improvement from #2672
|
||||||
NSData *data = nil;
|
NSData *data = nil;
|
||||||
@@ -265,13 +265,13 @@ didCompleteWithError:(NSError *)error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (self.downloadFileURL) {
|
if (self.downloadFileURL) {
|
||||||
userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL;
|
userInfo[SM_AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL;
|
||||||
} else if (data) {
|
} else if (data) {
|
||||||
userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = data;
|
userInfo[SM_AFNetworkingTaskDidCompleteResponseDataKey] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
userInfo[AFNetworkingTaskDidCompleteErrorKey] = error;
|
userInfo[SM_AFNetworkingTaskDidCompleteErrorKey] = error;
|
||||||
|
|
||||||
dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{
|
dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{
|
||||||
if (self.completionHandler) {
|
if (self.completionHandler) {
|
||||||
@@ -279,7 +279,7 @@ didCompleteWithError:(NSError *)error
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo];
|
[[NSNotificationCenter defaultCenter] postNotificationName:SM_AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -292,11 +292,11 @@ didCompleteWithError:(NSError *)error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (responseObject) {
|
if (responseObject) {
|
||||||
userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject;
|
userInfo[SM_AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serializationError) {
|
if (serializationError) {
|
||||||
userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError;
|
userInfo[SM_AFNetworkingTaskDidCompleteErrorKey] = serializationError;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{
|
dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{
|
||||||
@@ -305,7 +305,7 @@ didCompleteWithError:(NSError *)error
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo];
|
[[NSNotificationCenter defaultCenter] postNotificationName:SM_AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -473,7 +473,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
@interface AFURLSessionManager ()
|
@interface SM_AFURLSessionManager ()
|
||||||
@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration;
|
@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration;
|
||||||
@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue;
|
@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue;
|
||||||
@property (readwrite, nonatomic, strong) NSURLSession *session;
|
@property (readwrite, nonatomic, strong) NSURLSession *session;
|
||||||
@@ -497,7 +497,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume;
|
@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AFURLSessionManager
|
@implementation SM_AFURLSessionManager
|
||||||
|
|
||||||
- (instancetype)init {
|
- (instancetype)init {
|
||||||
return [self initWithSessionConfiguration:nil];
|
return [self initWithSessionConfiguration:nil];
|
||||||
@@ -522,16 +522,16 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
|
|
||||||
self.responseSerializer = [AFJSONResponseSerializer serializer];
|
self.responseSerializer = [AFJSONResponseSerializer serializer];
|
||||||
|
|
||||||
self.securityPolicy = [AFSecurityPolicy defaultPolicy];
|
self.securityPolicy = [SM_AFSecurityPolicy defaultPolicy];
|
||||||
|
|
||||||
#if !TARGET_OS_WATCH
|
#if !TARGET_OS_WATCH
|
||||||
self.reachabilityManager = [AFNetworkReachabilityManager sharedManager];
|
self.reachabilityManager = [SM_AFNetworkReachabilityManager sharedManager];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init];
|
self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
self.lock = [[NSLock alloc] init];
|
self.lock = [[NSLock alloc] init];
|
||||||
self.lock.name = AFURLSessionManagerLockName;
|
self.lock.name = SM_AFURLSessionManagerLockName;
|
||||||
|
|
||||||
[self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
|
[self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
|
||||||
for (NSURLSessionDataTask *task in dataTasks) {
|
for (NSURLSessionDataTask *task in dataTasks) {
|
||||||
@@ -565,7 +565,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
if ([task respondsToSelector:@selector(taskDescription)]) {
|
if ([task respondsToSelector:@selector(taskDescription)]) {
|
||||||
if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) {
|
if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidResumeNotification object:task];
|
[[NSNotificationCenter defaultCenter] postNotificationName:SM_AFNetworkingTaskDidResumeNotification object:task];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -576,7 +576,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
if ([task respondsToSelector:@selector(taskDescription)]) {
|
if ([task respondsToSelector:@selector(taskDescription)]) {
|
||||||
if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) {
|
if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidSuspendNotification object:task];
|
[[NSNotificationCenter defaultCenter] postNotificationName:SM_AFNetworkingTaskDidSuspendNotification object:task];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -584,10 +584,10 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
- (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task {
|
- (SM_AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task {
|
||||||
NSParameterAssert(task);
|
NSParameterAssert(task);
|
||||||
|
|
||||||
AFURLSessionManagerTaskDelegate *delegate = nil;
|
SM_AFURLSessionManagerTaskDelegate *delegate = nil;
|
||||||
[self.lock lock];
|
[self.lock lock];
|
||||||
delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)];
|
delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)];
|
||||||
[self.lock unlock];
|
[self.lock unlock];
|
||||||
@@ -595,7 +595,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
return delegate;
|
return delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate
|
- (void)setDelegate:(SM_AFURLSessionManagerTaskDelegate *)delegate
|
||||||
forTask:(NSURLSessionTask *)task
|
forTask:(NSURLSessionTask *)task
|
||||||
{
|
{
|
||||||
NSParameterAssert(task);
|
NSParameterAssert(task);
|
||||||
@@ -613,7 +613,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock
|
downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock
|
||||||
completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
|
completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
|
||||||
{
|
{
|
||||||
AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init];
|
SM_AFURLSessionManagerTaskDelegate *delegate = [[SM_AFURLSessionManagerTaskDelegate alloc] init];
|
||||||
delegate.manager = self;
|
delegate.manager = self;
|
||||||
delegate.completionHandler = completionHandler;
|
delegate.completionHandler = completionHandler;
|
||||||
|
|
||||||
@@ -628,7 +628,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock
|
progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock
|
||||||
completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
|
completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
|
||||||
{
|
{
|
||||||
AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init];
|
SM_AFURLSessionManagerTaskDelegate *delegate = [[SM_AFURLSessionManagerTaskDelegate alloc] init];
|
||||||
delegate.manager = self;
|
delegate.manager = self;
|
||||||
delegate.completionHandler = completionHandler;
|
delegate.completionHandler = completionHandler;
|
||||||
|
|
||||||
@@ -644,7 +644,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
|
destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
|
||||||
completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler
|
completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler
|
||||||
{
|
{
|
||||||
AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init];
|
SM_AFURLSessionManagerTaskDelegate *delegate = [[SM_AFURLSessionManagerTaskDelegate alloc] init];
|
||||||
delegate.manager = self;
|
delegate.manager = self;
|
||||||
delegate.completionHandler = completionHandler;
|
delegate.completionHandler = completionHandler;
|
||||||
|
|
||||||
@@ -664,7 +664,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
- (void)removeDelegateForTask:(NSURLSessionTask *)task {
|
- (void)removeDelegateForTask:(NSURLSessionTask *)task {
|
||||||
NSParameterAssert(task);
|
NSParameterAssert(task);
|
||||||
|
|
||||||
AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task];
|
SM_AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task];
|
||||||
[self.lock lock];
|
[self.lock lock];
|
||||||
[delegate cleanUpProgressForTask:task];
|
[delegate cleanUpProgressForTask:task];
|
||||||
[self removeNotificationObserverForTask:task];
|
[self removeNotificationObserverForTask:task];
|
||||||
@@ -726,7 +726,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
- (void)setResponseSerializer:(id <AFURLResponseSerialization>)responseSerializer {
|
- (void)setResponseSerializer:(id <SM_AFURLResponseSerialization>)responseSerializer {
|
||||||
NSParameterAssert(responseSerializer);
|
NSParameterAssert(responseSerializer);
|
||||||
|
|
||||||
_responseSerializer = responseSerializer;
|
_responseSerializer = responseSerializer;
|
||||||
@@ -1078,7 +1078,7 @@ totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend
|
|||||||
task:(NSURLSessionTask *)task
|
task:(NSURLSessionTask *)task
|
||||||
didCompleteWithError:(NSError *)error
|
didCompleteWithError:(NSError *)error
|
||||||
{
|
{
|
||||||
AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task];
|
SM_AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task];
|
||||||
|
|
||||||
// delegate may be nil when completing a task in the background
|
// delegate may be nil when completing a task in the background
|
||||||
if (delegate) {
|
if (delegate) {
|
||||||
@@ -1114,7 +1114,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||||||
dataTask:(NSURLSessionDataTask *)dataTask
|
dataTask:(NSURLSessionDataTask *)dataTask
|
||||||
didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask
|
didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask
|
||||||
{
|
{
|
||||||
AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask];
|
SM_AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask];
|
||||||
if (delegate) {
|
if (delegate) {
|
||||||
[self removeDelegateForTask:dataTask];
|
[self removeDelegateForTask:dataTask];
|
||||||
[self setDelegate:delegate forTask:downloadTask];
|
[self setDelegate:delegate forTask:downloadTask];
|
||||||
@@ -1130,7 +1130,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask
|
|||||||
didReceiveData:(NSData *)data
|
didReceiveData:(NSData *)data
|
||||||
{
|
{
|
||||||
|
|
||||||
AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask];
|
SM_AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask];
|
||||||
[delegate URLSession:session dataTask:dataTask didReceiveData:data];
|
[delegate URLSession:session dataTask:dataTask didReceiveData:data];
|
||||||
|
|
||||||
if (self.dataTaskDidReceiveData) {
|
if (self.dataTaskDidReceiveData) {
|
||||||
@@ -1168,7 +1168,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask
|
|||||||
downloadTask:(NSURLSessionDownloadTask *)downloadTask
|
downloadTask:(NSURLSessionDownloadTask *)downloadTask
|
||||||
didFinishDownloadingToURL:(NSURL *)location
|
didFinishDownloadingToURL:(NSURL *)location
|
||||||
{
|
{
|
||||||
AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask];
|
SM_AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask];
|
||||||
if (self.downloadTaskDidFinishDownloading) {
|
if (self.downloadTaskDidFinishDownloading) {
|
||||||
NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location);
|
NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location);
|
||||||
if (fileURL) {
|
if (fileURL) {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "AFURLRequestSerialization.h"
|
#import "SM_AFURLRequestSerialization.h"
|
||||||
|
|
||||||
@interface TextRequestSerializer : AFHTTPRequestSerializer
|
@interface TextRequestSerializer : AFHTTPRequestSerializer
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
return serializer;
|
return serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLRequestSerialization
|
#pragma mark - SM_AFURLRequestSerialization
|
||||||
|
|
||||||
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||||
withParameters:(id)parameters
|
withParameters:(id)parameters
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "AFURLResponseSerialization.h"
|
#import "SM_AFURLResponseSerialization.h"
|
||||||
|
|
||||||
@interface TextResponseSerializer : AFHTTPResponseSerializer
|
@interface TextResponseSerializer : AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
|||||||
@@ -94,26 +94,26 @@ static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger co
|
|||||||
if (data && !*decoded) {
|
if (data && !*decoded) {
|
||||||
NSMutableDictionary *mutableUserInfo = [@{
|
NSMutableDictionary *mutableUserInfo = [@{
|
||||||
NSURLErrorFailingURLErrorKey:[response URL],
|
NSURLErrorFailingURLErrorKey:[response URL],
|
||||||
AFNetworkingOperationFailingURLResponseErrorKey: response,
|
SM_AFNetworkingOperationFailingURLResponseErrorKey: response,
|
||||||
AFNetworkingOperationFailingURLResponseDataErrorKey: data,
|
SM_AFNetworkingOperationFailingURLResponseDataErrorKey: data,
|
||||||
AFNetworkingOperationFailingURLResponseBodyErrorKey: @"Could not decode response data due to invalid or unknown charset encoding",
|
SM_AFNetworkingOperationFailingURLResponseBodyErrorKey: @"Could not decode response data due to invalid or unknown charset encoding",
|
||||||
} mutableCopy];
|
} mutableCopy];
|
||||||
|
|
||||||
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
|
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:SM_AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
|
||||||
responseIsValid = NO;
|
responseIsValid = NO;
|
||||||
} else if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
|
} else if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
|
||||||
NSMutableDictionary *mutableUserInfo = [@{
|
NSMutableDictionary *mutableUserInfo = [@{
|
||||||
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
|
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"SM_AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
|
||||||
NSURLErrorFailingURLErrorKey: [response URL],
|
NSURLErrorFailingURLErrorKey: [response URL],
|
||||||
AFNetworkingOperationFailingURLResponseErrorKey: response,
|
SM_AFNetworkingOperationFailingURLResponseErrorKey: response,
|
||||||
} mutableCopy];
|
} mutableCopy];
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
mutableUserInfo[SM_AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
||||||
mutableUserInfo[AFNetworkingOperationFailingURLResponseBodyErrorKey] = *decoded;
|
mutableUserInfo[SM_AFNetworkingOperationFailingURLResponseBodyErrorKey] = *decoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
|
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:SM_AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
|
||||||
responseIsValid = NO;
|
responseIsValid = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger co
|
|||||||
return responseIsValid;
|
return responseIsValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AFURLResponseSerialization
|
#pragma mark - SM_AFURLResponseSerialization
|
||||||
|
|
||||||
- (id)responseObjectForResponse:(NSURLResponse *)response
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
data:(NSData *)data
|
data:(NSData *)data
|
||||||
@@ -134,7 +134,7 @@ static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger co
|
|||||||
NSString* decoded = nil;
|
NSString* decoded = nil;
|
||||||
|
|
||||||
if (![self validateResponse:(NSHTTPURLResponse *)response data:data decoded:&decoded error:error]) {
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data decoded:&decoded error:error]) {
|
||||||
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, SM_AFURLResponseSerializationErrorDomain)) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user