Skip to content

Commit 3cd704b

Browse files
committed
config ios8
1 parent 7d5242e commit 3cd704b

File tree

6 files changed

+12
-29
lines changed

6 files changed

+12
-29
lines changed

QiniuSDK/Common/QNSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ BOOL hasAts();
1616
BOOL allowsArbitraryLoads();
1717

1818
//iOS8判断
19-
BOOL hasDns();
19+
BOOL isNotIOS8();
2020

2121
#endif /* QNSystem_h */

QiniuSDK/Common/QNSystem.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ BOOL allowsArbitraryLoads() {
6868
return ats.boolValue;
6969
}
7070

71-
BOOL hasDns(){
71+
BOOL isNotIOS8(){
7272
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED)
7373
float sysVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
7474
if ((sysVersion >= 8.0) && sysVersion < 9.0) {

QiniuSDK/Storage/QNConfiguration.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,4 @@ typedef void (^QNConfigurationBuilderBlock)(QNConfigurationBuilder *builder);
173173

174174
@property (assign) BOOL disableATS;
175175

176-
@property (assign) BOOL isNotIOS8;
177-
178176
@end

QiniuSDK/Storage/QNConfiguration.m

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ static void addZoneToDns(QNZone *zone, QNDnsManager *dns) {
4646
return d;
4747
}
4848

49-
@interface QNConfiguration()
50-
51-
@property (assign) BOOL isNotIOS8;
52-
53-
@end
54-
5549
@implementation QNConfiguration
5650

5751
+ (instancetype)build:(QNConfigurationBuilderBlock)block {
@@ -78,8 +72,7 @@ - (instancetype)initWithBuilder:(QNConfigurationBuilder *)builder {
7872
_converter = builder.converter;
7973

8074
_disableATS = builder.disableATS;
81-
_isNotIOS8 = builder.isNotIOS8;
82-
if (_disableATS && _isNotIOS8) {
75+
if (_disableATS) {
8376
_dns = initDns(builder);
8477
addZoneToDns(builder.zone, _dns);
8578
} else {
@@ -107,13 +100,13 @@ - (instancetype)init {
107100
_proxy = nil;
108101
_converter = nil;
109102

110-
if (hasAts() && !allowsArbitraryLoads()) {
103+
if (hasAts() && !allowsArbitraryLoads()&& !isNotIOS8()) {
111104
_disableATS = NO;
112105
} else {
113106
_disableATS = YES;
114107
}
115108

116-
_isNotIOS8 = hasDns();
109+
117110
}
118111
return self;
119112
}

QiniuSDKTests/QNFormUploadTest.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#import "HappyDns.h"
1616
#import "QNTestConfig.h"
17+
#import "QNSystem.h"
1718

1819
@interface QNFormUploadTest : XCTestCase
1920

@@ -273,7 +274,7 @@ - (void)testDnsHosts {
273274
QNResolver *resolver = [[QNResolver alloc] initWithAddres:@"114.114.115.115"];
274275
QNDnsManager *dns = [[QNDnsManager alloc] init:[NSArray arrayWithObject:resolver] networkInfo:[QNNetworkInfo normal]];
275276
QNConfiguration *config = [QNConfiguration build:^(QNConfigurationBuilder *builder) {
276-
if (builder.isNotIOS8) {
277+
if (isNotIOS8()) {
277278
isNotiOS8 = YES;
278279
NSArray *ips = [QNZone zone0].up.ips;
279280
QNServiceAddress *s1 = [[QNServiceAddress alloc] init:@"http://uphosttest.qiniu.com" ips:ips];

QiniuSDKTests/QNResumeUploadTest.m

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,14 @@ - (void)testUrlConvert {
265265
}
266266

267267
- (void)testHosts {
268-
__block BOOL isNotiOS8 = NO;
269268
QNResolver *resolver = [[QNResolver alloc] initWithAddres:@"114.114.115.115"];
270269
QNDnsManager *dns = [[QNDnsManager alloc] init:[NSArray arrayWithObject:resolver] networkInfo:[QNNetworkInfo normal]];
271270
QNConfiguration *config = [QNConfiguration build:^(QNConfigurationBuilder *builder) {
272-
if(builder.isNotIOS8){
273-
isNotiOS8 = YES;
274-
NSArray *ips = [QNZone zone0].up.ips;
275-
QNServiceAddress *s1 = [[QNServiceAddress alloc] init:@"http://uphosttest.qiniu.com" ips:ips];
276-
QNServiceAddress *s2 = [[QNServiceAddress alloc] init:@"http://uphosttestbak.qiniu.com" ips:ips];
277-
builder.zone = [[QNZone alloc] initWithUp:s1 upBackup:s2];
278-
builder.dns = dns;
279-
}
271+
NSArray *ips = [QNZone zone0].up.ips;
272+
QNServiceAddress *s1 = [[QNServiceAddress alloc] init:@"http://uphosttest.qiniu.com" ips:ips];
273+
QNServiceAddress *s2 = [[QNServiceAddress alloc] init:@"http://uphosttestbak.qiniu.com" ips:ips];
274+
builder.zone = [[QNZone alloc] initWithUp:s1 upBackup:s2];
275+
builder.dns = dns;
280276
}];
281277

282278
QNUploadManager *upManager = [[QNUploadManager alloc] initWithConfiguration:config];
@@ -296,12 +292,7 @@ - (void)testHosts {
296292
NSLog(@"info %@", info);
297293
XCTAssert(info.isOK, @"Pass");
298294
XCTAssert([keyUp isEqualToString:key], @"Pass");
299-
if(isNotiOS8){
300295
XCTAssert([info.host isEqual:@"uphosttest.qiniu.com"] || [info.host isEqual:@"uphosttestbak.qiniu.com"], @"Pass");
301-
}else
302-
{
303-
XCTAssert([info.host isEqual:@"upload.qiniu.com"], @"Pass");
304-
}
305296
[QNTempFile removeTempfile:tempFile];
306297
}
307298

0 commit comments

Comments
 (0)