Skip to content
Permalink
Browse files

Merge pull request #263 from longbai/pandora

release new version
  • Loading branch information...
longbai committed Dec 2, 2017
2 parents 61aae6c + 1298bce commit c42fdd99f5cdb1e5d5045cdb7f5f5a0a6ea0cf13
@@ -19,7 +19,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate

*.xccoverage.plist

# Subversion
.svn
@@ -16,7 +16,7 @@ before_script:
- export QINIU_TEST_ENV="travis"

script:
- xcodebuild test -workspace QiniuSDK.xcworkspace -scheme QiniuSDK_iOS -configuration Release -destination 'platform=iOS Simulator,OS=11.0,name=iPhone SE'
- xcodebuild test -workspace QiniuSDK.xcworkspace -scheme QiniuSDK_iOS -configuration Release -destination 'platform=iOS Simulator,OS=11.0,name=iPhone SE' -enableCodeCoverage YES
- xcodebuild test -workspace QiniuSDK.xcworkspace -scheme QiniuSDK_Mac -configuration Release -destination 'platform=macOS,arch=x86_64'

after_success:
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Qiniu'
s.version = '7.1.8'
s.version = '7.2.0'
s.summary = 'Qiniu Resource Storage SDK for iOS and Mac'
s.homepage = 'https://github.com/qiniu/objc-sdk'
s.social_media_url = 'http://weibo.com/qiniutek'
@@ -13,12 +13,11 @@ Pod::Spec.new do |s|
s.source_files = "QiniuSDK/**/*.{h,m}"
s.requires_arc = true
s.libraries = 'z'
s.dependency 'AFNetworking', '~> 3'
s.dependency 'HappyDNS', '~> 0.3'
s.license = { :type => "MIT", :text => <<-LICENSE
The MIT License (MIT)
Copyright (c) 2011-2016 qiniu.com
Copyright (c) 2011-2017 qiniu.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -6,7 +6,6 @@
// Copyright (c) 2014年 Qiniu. All rights reserved.
//


#import "HappyDNS.h"
#import "QNAsyncRun.h"
#import "QNConfiguration.h"
@@ -51,24 +50,23 @@ - (instancetype)initWithProgress:(QNInternalProgressBlock)progressBlock {
}

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task
didSendBodyData:(int64_t)bytesSent
totalBytesSent:(int64_t)totalBytesSent
totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend {
didSendBodyData:(int64_t)bytesSent
totalBytesSent:(int64_t)totalBytesSent
totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend {

_progressBlock(totalBytesSent, totalBytesExpectedToSend);
if (_cancelBlock && _cancelBlock()) {
[_task cancel];
}

float progress = (float)totalBytesSent / totalBytesExpectedToSend;
if (progress==1.0f) {
self.task =nil;
if (progress == 1.0f) {
self.task = nil;
self.cancelBlock = nil;
self.progressBlock = nil;
}
}


@end

@interface QNSessionManager ()
@@ -109,7 +107,6 @@ - (void)dealloc {
}
}


- (instancetype)init {
return [self initWithProxy:nil timeout:60 urlConverter:nil dns:nil];
}
@@ -206,10 +203,10 @@ - (void)sendRequest2:(NSMutableURLRequest *)request
QNInternalProgressBlock progressBlock2 = ^(long long totalBytesWritten, long long totalBytesExpectedToWrite) {
progressBlock(totalBytesWritten, totalBytesExpectedToWrite);
};
QNProgessDelegate *delegate =(QNProgessDelegate *)_httpManager.delegate;
QNProgessDelegate *delegate = (QNProgessDelegate *)_httpManager.delegate;
delegate.progressBlock = progressBlock2;
NSURLSessionUploadTask *uploadTask = [_httpManager uploadTaskWithRequest:request fromData:nil completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSURLSessionUploadTask *uploadTask = [_httpManager uploadTaskWithRequest:request fromData:nil completionHandler:^(NSData *_Nullable data, NSURLResponse *_Nullable response, NSError *_Nullable error) {

NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
double duration = [[NSDate date] timeIntervalSinceDate:startTime];
QNResponseInfo *info;
@@ -234,7 +231,6 @@ - (void)sendRequest2:(NSMutableURLRequest *)request
[uploadTask resume];
}


- (void)multipartPost:(NSString *)url
withData:(NSData *)data
withParams:(NSDictionary *)params
@@ -244,35 +240,35 @@ - (void)multipartPost:(NSString *)url
withProgressBlock:(QNInternalProgressBlock)progressBlock
withCancelBlock:(QNCancelBlock)cancelBlock
withAccess:(NSString *)access {
NSURL *URL = [[NSURL alloc]initWithString:url];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30];
NSURL *URL = [[NSURL alloc] initWithString:url];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30];
request.HTTPMethod = @"POST";
NSString *boundary = @"werghnvt54wef654rjuhgb56trtg34tweuyrgf";
request.allHTTPHeaderFields = @{
@"Content-Type":[NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]
};
NSMutableData *postData = [[NSMutableData alloc]init];
@"Content-Type" : [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]
};
NSMutableData *postData = [[NSMutableData alloc] init];
for (NSString *paramsKey in params) {
NSString *pair = [NSString stringWithFormat:@"--%@\r\nContent-Disposition: form-data; name=\"%@\"\r\n\r\n",boundary,paramsKey];
NSString *pair = [NSString stringWithFormat:@"--%@\r\nContent-Disposition: form-data; name=\"%@\"\r\n\r\n", boundary, paramsKey];
[postData appendData:[pair dataUsingEncoding:NSUTF8StringEncoding]];

id value = [params objectForKey:paramsKey];
if ([value isKindOfClass:[NSString class]]) {
[postData appendData:[value dataUsingEncoding:NSUTF8StringEncoding]];
}else if ([value isKindOfClass:[NSData class]]){
} else if ([value isKindOfClass:[NSData class]]) {
[postData appendData:value];
}
[postData appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
}
NSString *filePair = [NSString stringWithFormat:@"--%@\r\nContent-Disposition: form-data; name=\"%@\"; filename=\"%@\"\nContent-Type:%@\r\n\r\n",boundary,@"file",key,mime];
NSString *filePair = [NSString stringWithFormat:@"--%@\r\nContent-Disposition: form-data; name=\"%@\"; filename=\"%@\"\nContent-Type:%@\r\n\r\n", boundary, @"file", key, mime];
[postData appendData:[filePair dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:data];
[postData appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
request.HTTPBody = postData;
[request setValue:[NSString stringWithFormat:@"%lu",(unsigned long)postData.length] forHTTPHeaderField:@"Content-Length"];
[request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)postData.length] forHTTPHeaderField:@"Content-Length"];

[self sendRequest:request withCompleteBlock:completeBlock withProgressBlock:progressBlock withCancelBlock:cancelBlock
withAccess:access];
withAccess:access];
}

- (void)post:(NSString *)url
@@ -307,8 +303,8 @@ - (void)get:(NSString *)url
QNAsyncRun(^{
NSURL *URL = [NSURL URLWithString:url];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *_Nullable data, NSURLResponse *_Nullable response, NSError *_Nullable error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
NSData *s = [@"{}" dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *resp = nil;
@@ -327,12 +323,11 @@ - (void)get:(NSString *)url
} else {
info = [QNSessionManager buildResponseInfo:httpResponse withError:error withDuration:0 withResponse:s withHost:@"" withIp:@""];
}

completeBlock(info, resp);
}];
[dataTask resume];



});
}

@@ -91,7 +91,7 @@ + (void)removeKey:(NSString *)key
NSString *path = [QNFileRecorder pathJoin:key path:dir];
[[NSFileManager defaultManager] removeItemAtPath:path error:&error];
if (error) {
NSLog(@"%s,%@",__func__,error);
NSLog(@"%s,%@", __func__, error);
}
}

@@ -89,8 +89,8 @@ typedef void (^QNPrequeryReturn)(int code);

@interface QNZone : NSObject

@property (nonatomic, strong) NSArray <NSString *> * upDomainList;
@property (nonatomic, strong) QNZoneInfo * zoneInfo;
@property (nonatomic, strong) NSArray<NSString *> *upDomainList;
@property (nonatomic, strong) QNZoneInfo *zoneInfo;

/**
* 默认上传服务器地址列表
@@ -107,11 +107,11 @@ typedef void (^QNPrequeryReturn)(int code);
@interface QNZoneInfo : NSObject

@property (readonly, nonatomic) long ttl;
@property (readonly, nonatomic) NSMutableArray <NSString *> * upDomainsList;
@property (readonly, nonatomic) NSMutableDictionary * upDomainsDic;
@property (readonly, nonatomic) NSMutableArray<NSString *> *upDomainsList;
@property (readonly, nonatomic) NSMutableDictionary *upDomainsDic;

- (instancetype)init:(long)ttl
upDomainsList:(NSMutableArray <NSString *> *)upDomainsList
upDomainsList:(NSMutableArray<NSString *> *)upDomainsList
upDomainsDic:(NSMutableDictionary *)upDomainsDic;
- (QNZoneInfo *)buildInfoFromJson:(NSDictionary *)resp;

@@ -154,7 +154,7 @@ typedef void (^QNPrequeryReturn)(int code);
*
* @return Zone实例
*/
- (instancetype)initWithupDomainList:(NSArray <NSString *> *)upList;
- (instancetype)initWithupDomainList:(NSArray<NSString *> *)upList;

/**
* Zone初始化方法
@@ -163,7 +163,7 @@ typedef void (^QNPrequeryReturn)(int code);
*
* @return Zone实例
*/
+ (instancetype)createWithHost:(NSArray <NSString *> *)upList;
+ (instancetype)createWithHost:(NSArray<NSString *> *)upList;

- (void)preQuery:(QNUpToken *)token
on:(QNPrequeryReturn)ret;
Oops, something went wrong.

0 comments on commit c42fdd9

Please sign in to comment.
You can’t perform that action at this time.