Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://github.com/CocoaPods/Specs.git'

def shared_dependencies
pod 'HappyDNS', '>= 0.3'
# pod 'HappyDNS', '>= 0.3'
end

def test_dependencies
Expand Down
2 changes: 1 addition & 1 deletion QiniuSDK/BigData/QNPipeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ - (instancetype)init:(QNPipelineConfig*)config {
}
_config = config;
#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090)
_httpManager = [[QNSessionManager alloc] initWithProxy:nil timeout:config.timeoutInterval urlConverter:nil dns:nil];
_httpManager = [[QNSessionManager alloc] initWithProxy:nil timeout:config.timeoutInterval urlConverter:nil];
#endif
}
return self;
Expand Down
3 changes: 1 addition & 2 deletions QiniuSDK/Http/QNSessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

- (instancetype)initWithProxy:(NSDictionary *)proxyDict
timeout:(UInt32)timeout
urlConverter:(QNUrlConvert)converter
dns:(QNDnsManager *)dns;
urlConverter:(QNUrlConvert)converter;

- (void)multipartPost:(NSString *)url
withData:(NSData *)data
Expand Down
23 changes: 2 additions & 21 deletions QiniuSDK/Http/QNSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright (c) 2014年 Qiniu. All rights reserved.
//

#import "HappyDNS.h"
#import "QNAsyncRun.h"
#import "QNConfiguration.h"
#import "QNResponseInfo.h"
Expand Down Expand Up @@ -69,16 +68,14 @@ @interface QNSessionManager ()
@property (nonatomic, strong) QNUrlConvert converter;
@property bool noProxy;
@property (nonatomic, strong) NSDictionary *proxyDict;
@property (nonatomic) QNDnsManager *dns;
@property (nonatomic, strong) NSOperationQueue *delegateQueue;
@end

@implementation QNSessionManager

- (instancetype)initWithProxy:(NSDictionary *)proxyDict
timeout:(UInt32)timeout
urlConverter:(QNUrlConvert)converter
dns:(QNDnsManager *)dns {
urlConverter:(QNUrlConvert)converter {
if (self = [super init]) {
if (proxyDict != nil) {
_noProxy = NO;
Expand All @@ -89,14 +86,13 @@ - (instancetype)initWithProxy:(NSDictionary *)proxyDict
_delegateQueue = [[NSOperationQueue alloc] init];
_timeout = timeout;
_converter = converter;
_dns = dns;
}

return self;
}

- (instancetype)init {
return [self initWithProxy:nil timeout:60 urlConverter:nil dns:nil];
return [self initWithProxy:nil timeout:60 urlConverter:nil];
}

+ (QNResponseInfo *)buildResponseInfo:(NSHTTPURLResponse *)response
Expand Down Expand Up @@ -140,21 +136,6 @@ - (void)sendRequest:(NSMutableURLRequest *)request
url = [[NSURL alloc] initWithString:_converter(u)];
request.URL = url;
domain = url.host;
} else if (_noProxy && _dns != nil && [url.scheme isEqualToString:@"http"]) {
if (isIpV6FullySupported() || ![QNIP isV6]) {
ips = [_dns queryWithDomain:[[QNDomain alloc] init:domain hostsFirst:NO hasCname:YES maxTtl:1000]];
double duration = [[NSDate date] timeIntervalSinceDate:startTime];

if (ips == nil || ips.count == 0) {
NSError *error = [[NSError alloc] initWithDomain:domain code:-1003 userInfo:@{ @"error" : @"unkonwn host" }];

QNResponseInfo *info = [QNResponseInfo responseInfoWithNetError:error host:domain duration:duration];
NSLog(@"failure %@", info);

completeBlock(info, nil);
return;
}
}
}
[self sendRequest2:request withCompleteBlock:completeBlock withProgressBlock:progressBlock withCancelBlock:cancelBlock withIpArray:ips withIndex:0 withDomain:domain withRetryTimes:3 withStartTime:startTime withAccess:access];
}
Expand Down
4 changes: 0 additions & 4 deletions QiniuSDK/Storage/QNConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ extern const UInt32 kQNBlockSize;
typedef NSString * (^QNUrlConvert)(NSString *url);

@class QNConfigurationBuilder;
@class QNDnsManager;
@class QNZone;
/**
* Builder block
Expand Down Expand Up @@ -74,7 +73,6 @@ typedef void (^QNConfigurationBuilderBlock)(QNConfigurationBuilder *builder);

@property (nonatomic, readonly) QNUrlConvert converter;

@property (nonatomic, readonly) QNDnsManager *dns;

@property (readonly) BOOL disableATS;

Expand Down Expand Up @@ -182,7 +180,6 @@ typedef void (^QNPrequeryReturn)(int code);

@interface QNAutoZone : QNZone

- (instancetype)initWithDns:(QNDnsManager *)dns;

- (NSString *)up:(QNUpToken *)token
isHttps:(BOOL)isHttps
Expand Down Expand Up @@ -230,7 +227,6 @@ typedef void (^QNPrequeryReturn)(int code);

@property (nonatomic, strong) QNUrlConvert converter;

@property (nonatomic, strong) QNDnsManager *dns;

@property (assign) BOOL disableATS;

Expand Down
26 changes: 4 additions & 22 deletions QiniuSDK/Storage/QNConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,13 @@
//

#import "QNConfiguration.h"
#import "HappyDNS.h"
#import "QNNetworkInfo.h"
#import "QNResponseInfo.h"
#import "QNSessionManager.h"
#import "QNSystem.h"
#import "QNUpToken.h"

const UInt32 kQNBlockSize = 4 * 1024 * 1024;

static QNDnsManager *initDns(QNConfigurationBuilder *builder) {
QNDnsManager *d = builder.dns;
if (d == nil) {
id<QNResolverDelegate> r1 = [QNResolver systemResolver];
id<QNResolverDelegate> r2 = [[QNResolver alloc] initWithAddress:@"119.29.29.29"];
id<QNResolverDelegate> r3 = [[QNResolver alloc] initWithAddress:@"114.114.115.115"];
d = [[QNDnsManager alloc] init:[NSArray arrayWithObjects:r1, r2, r3, nil] networkInfo:[QNNetworkInfo normal]];
}
return d;
}

@implementation QNConfiguration

Expand All @@ -51,11 +39,7 @@ - (instancetype)initWithBuilder:(QNConfigurationBuilder *)builder {
_converter = builder.converter;

_disableATS = builder.disableATS;
if (_disableATS) {
_dns = initDns(builder);
} else {
_dns = nil;
}

_zone = builder.zone;

_useHttps = builder.useHttps;
Expand All @@ -69,7 +53,7 @@ @implementation QNConfigurationBuilder

- (instancetype)init {
if (self = [super init]) {
_zone = [[QNAutoZone alloc] initWithDns:nil];
_zone = [[QNAutoZone alloc] init];
_chunkSize = 2 * 1024 * 1024;
_putThreshold = 4 * 1024 * 1024;
_retryMax = 3;
Expand Down Expand Up @@ -346,16 +330,14 @@ @implementation QNAutoZone {
NSMutableDictionary *cache;
NSLock *lock;
QNSessionManager *sesionManager;
QNDnsManager *dns;
}

- (instancetype)initWithDns:(QNDnsManager *)dns1 {
- (instancetype)init{
if (self = [super init]) {
dns = dns1;
server = @"https://uc.qbox.me";
cache = [NSMutableDictionary new];
lock = [NSLock new];
sesionManager = [[QNSessionManager alloc] initWithProxy:nil timeout:10 urlConverter:nil dns:dns];
sesionManager = [[QNSessionManager alloc] initWithProxy:nil timeout:10 urlConverter:nil];
}
return self;
}
Expand Down
2 changes: 1 addition & 1 deletion QiniuSDK/Storage/QNUploadManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ - (instancetype)initWithConfiguration:(QNConfiguration *)config {
}
_config = config;
#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090)
_httpManager = [[QNSessionManager alloc] initWithProxy:config.proxy timeout:config.timeoutInterval urlConverter:config.converter dns:config.dns];
_httpManager = [[QNSessionManager alloc] initWithProxy:config.proxy timeout:config.timeoutInterval urlConverter:config.converter];
#endif
}
return self;
Expand Down
3 changes: 1 addition & 2 deletions QiniuSDKTests/QNAutoZoneTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#import "QNResponseInfo.h"
#import "QNSessionManager.h"

#import "HappyDNS.h"
#import "QNConfiguration.h"

#import "QNTestConfig.h"
Expand All @@ -38,7 +37,7 @@ - (void)tearDown {
}

- (void)testHttp {
QNAutoZone* autoZone = [[QNAutoZone alloc] initWithDns:nil];
QNAutoZone* autoZone = [[QNAutoZone alloc] init];
QNUpToken* tok = [QNUpToken parse:g_token];
__block int x = 0;
__block int c = 0;
Expand Down
1 change: 0 additions & 1 deletion QiniuSDKTests/QNFormUploadTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#import "QiniuSDK.h"

#import "HappyDns.h"
#import "QNSystem.h"
#import "QNTestConfig.h"

Expand Down
1 change: 0 additions & 1 deletion QiniuSDKTests/QNResumeUploadTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#import <AGAsyncTestHelper.h>

#import "HappyDNS.h"
#import "QiniuSDK.h"

#import "QNTempFile.h"
Expand Down
5 changes: 2 additions & 3 deletions QiniuSDKTests/QNSessionTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#import "QNResponseInfo.h"
#import "QNSessionManager.h"

#import "HappyDNS.h"
#import "QNConfiguration.h"

@interface QNSessionTest : XCTestCase
Expand Down Expand Up @@ -109,7 +108,7 @@ - (void)testProxy {
(NSString *)kCFStreamPropertyHTTPProxyPort : @80,
};

QNSessionManager *httpManager = [[QNSessionManager alloc] initWithProxy:proxyDict timeout:60 urlConverter:nil dns:nil];
QNSessionManager *httpManager = [[QNSessionManager alloc] initWithProxy:proxyDict timeout:60 urlConverter:nil];
NSData *data = [@"Hello, World!" dataUsingEncoding:NSUTF8StringEncoding];
__block QNResponseInfo *testInfo = nil;
[httpManager post:@"http://up123.qiniu.com" withData:data withParams:nil withHeaders:nil withCompleteBlock:^(QNResponseInfo *info, NSDictionary *resp) {
Expand All @@ -129,7 +128,7 @@ - (void)testUrlConvert {
return [url stringByReplacingOccurrencesOfString:@"upnono" withString:@"up"];
};

QNSessionManager *httpManager = [[QNSessionManager alloc] initWithProxy:nil timeout:60 urlConverter:c dns:nil];
QNSessionManager *httpManager = [[QNSessionManager alloc] initWithProxy:nil timeout:60 urlConverter:c];
NSData *data = [@"Hello, World!" dataUsingEncoding:NSUTF8StringEncoding];
__block QNResponseInfo *testInfo = nil;
[httpManager post:@"http://upnono.qiniu.com" withData:data withParams:nil withHeaders:nil withCompleteBlock:^(QNResponseInfo *info, NSDictionary *resp) {
Expand Down