Skip to content

Commit

Permalink
Merge pull request #90 from qiniu/develop
Browse files Browse the repository at this point in the history
Release 6.3.1
  • Loading branch information
longbai committed Aug 18, 2014
2 parents 03fe09d + e450c20 commit a228567
Show file tree
Hide file tree
Showing 29 changed files with 460 additions and 230 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: objective-c
xcode_project: QiniuSDK.xcodeproj
xcode_scheme: QiniuSDKTests
xcode_sdk: iphonesimulator7.0
xcode_sdk:
- iphonesimulator7.1
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## CHANGE LOG

### v6.3.1

- [#81] uploadfiledatawithoutkey
- [#85] UA 增加client id
- [#86] 使用自带base64库,解决iOS6 兼容问题
- [#87] 升级到AFNetworking 2.3.1
- [#89] 修正demo未下载就上传崩溃问题

### v6.3.0

- [#77] 多host上传重试
Expand Down
10 changes: 5 additions & 5 deletions QiniuDemo/QiniuDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
BA08949A1987771100EE7ED8 /* QiniuConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = BA0894991987771100EE7ED8 /* QiniuConfig.m */; };
BACC917718BFA40000D87926 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BACC917618BFA40000D87926 /* Foundation.framework */; };
BACC917918BFA40000D87926 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BACC917818BFA40000D87926 /* CoreGraphics.framework */; };
BACC917B18BFA40000D87926 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BACC917A18BFA40000D87926 /* UIKit.framework */; };
Expand Down Expand Up @@ -49,6 +50,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
BA0894991987771100EE7ED8 /* QiniuConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QiniuConfig.m; sourceTree = "<group>"; };
BACC917318BFA40000D87926 /* QiniuDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QiniuDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
BACC917618BFA40000D87926 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
BACC917818BFA40000D87926 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -205,6 +207,7 @@
BACC921318C0EF1400D87926 /* QiniuSDK */ = {
isa = PBXGroup;
children = (
BA0894991987771100EE7ED8 /* QiniuConfig.m */,
DF0ED6431941DE9D00D2BB59 /* AFNetworking */,
BACC922818C0EF1400D87926 /* QiniuBlkputRet.h */,
BACC922918C0EF1400D87926 /* QiniuBlkputRet.m */,
Expand Down Expand Up @@ -297,7 +300,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = QiniuDemo;
LastUpgradeCheck = 0500;
LastUpgradeCheck = 0510;
ORGANIZATIONNAME = Qiniu;
TargetAttributes = {
BACC919318BFA40000D87926 = {
Expand Down Expand Up @@ -350,6 +353,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BA08949A1987771100EE7ED8 /* QiniuConfig.m in Sources */,
BACC924518C0EF1400D87926 /* QiniuUtils.m in Sources */,
DF0ED65B1941DE9D00D2BB59 /* AFSecurityPolicy.m in Sources */,
DF0ED6581941DE9D00D2BB59 /* AFHTTPRequestOperationManager.m in Sources */,
Expand Down Expand Up @@ -421,7 +425,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -460,7 +463,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -526,7 +528,6 @@
BACC91A918BFA40000D87926 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/QiniuDemo.app/QiniuDemo";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
Expand All @@ -549,7 +550,6 @@
BACC91AA18BFA40000D87926 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/QiniuDemo.app/QiniuDemo";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
Expand Down
3 changes: 3 additions & 0 deletions QiniuDemo/QiniuDemo/QiniuDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ - (IBAction)resumableUpload:(id)sender {
}

- (IBAction)simpleUpload:(id)sender {
if (_filePath == nil) {
return;
}

[self.sUploader uploadFile:_filePath key:[NSString stringWithFormat:@"test-%@.png", [self timeString]] extra:nil];
}
Expand Down
4 changes: 2 additions & 2 deletions QiniuSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
Expand Down Expand Up @@ -424,7 +424,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
Expand Down
1 change: 0 additions & 1 deletion QiniuSDK/AFNetworking/AFHTTPRequestOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#import <Foundation/Foundation.h>
#import "AFURLConnectionOperation.h"
#import "AFURLResponseSerialization.h"

/**
`AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.
Expand Down
14 changes: 9 additions & 5 deletions QiniuSDK/AFNetworking/AFHTTPRequestOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio
#pragma mark - AFURLRequestOperation

- (void)pause {
[super pause];

u_int64_t offset = 0;
if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) {
offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue];
Expand All @@ -164,19 +166,21 @@ - (void)pause {
}
[mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"];
self.request = mutableURLRequest;

[super pause];
}

#pragma mark - NSCoding
#pragma mark - NSecureCoding

+ (BOOL)supportsSecureCoding {
return YES;
}

- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (!self) {
return nil;
}

self.responseSerializer = [decoder decodeObjectForKey:NSStringFromSelector(@selector(responseSerializer))];
self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];

return self;
}
Expand All @@ -195,7 +199,7 @@ - (id)copyWithZone:(NSZone *)zone {
operation.responseSerializer = [self.responseSerializer copyWithZone:zone];
operation.completionQueue = self.completionQueue;
operation.completionGroup = self.completionGroup;

return operation;
}

Expand Down
22 changes: 18 additions & 4 deletions QiniuSDK/AFNetworking/AFHTTPRequestOperationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@
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.
## NSCoding & NSCopying Caveats
## NSecureCoding & NSCopying Caveats
`AFHTTPRequestOperationManager` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however:
`AFHTTPRequestOperationManager` conforms to the `NSecureCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however:
- Archives and copies of HTTP clients will be initialized with an empty operation queue.
- NSCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set.
- NSecureCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set.
*/
@interface AFHTTPRequestOperationManager : NSObject <NSCoding, NSCopying>
@interface AFHTTPRequestOperationManager : NSObject <NSSecureCoding, NSCopying>

/**
The URL used to monitor reachability, and construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods.
Expand Down Expand Up @@ -144,6 +144,20 @@
*/
@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager;

///-------------------------------
/// @name Managing Callback Queues
///-------------------------------

/**
The dispatch queue for the `completionBlock` of request operations. If `NULL` (default), the main queue is used.
*/
@property (nonatomic, strong) dispatch_queue_t completionQueue;

/**
The dispatch group for the `completionBlock` of request operations. If `NULL` (default), a private dispatch group is used.
*/
@property (nonatomic, strong) dispatch_group_t completionGroup;

///---------------------------------------------
/// @name Creating and Initializing HTTP Clients
///---------------------------------------------
Expand Down
19 changes: 16 additions & 3 deletions QiniuSDK/AFNetworking/AFHTTPRequestOperationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)requ
operation.securityPolicy = self.securityPolicy;

[operation setCompletionBlockWithSuccess:success failure:failure];
operation.completionQueue = self.completionQueue;
operation.completionGroup = self.completionGroup;

return operation;
}
Expand All @@ -116,6 +118,7 @@ - (AFHTTPRequestOperation *)GET:(NSString *)URLString
{
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"GET" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil];
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];

[self.operationQueue addOperation:operation];

return operation;
Expand All @@ -132,6 +135,7 @@ - (AFHTTPRequestOperation *)HEAD:(NSString *)URLString
success(requestOperation);
}
} failure:failure];

[self.operationQueue addOperation:operation];

return operation;
Expand All @@ -144,6 +148,7 @@ - (AFHTTPRequestOperation *)POST:(NSString *)URLString
{
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil];
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];

[self.operationQueue addOperation:operation];

return operation;
Expand All @@ -157,6 +162,7 @@ - (AFHTTPRequestOperation *)POST:(NSString *)URLString
{
NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:nil];
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];

[self.operationQueue addOperation:operation];

return operation;
Expand All @@ -169,6 +175,7 @@ - (AFHTTPRequestOperation *)PUT:(NSString *)URLString
{
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"PUT" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil];
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];

[self.operationQueue addOperation:operation];

return operation;
Expand All @@ -181,6 +188,7 @@ - (AFHTTPRequestOperation *)PATCH:(NSString *)URLString
{
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"PATCH" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil];
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];

[self.operationQueue addOperation:operation];

return operation;
Expand All @@ -193,6 +201,7 @@ - (AFHTTPRequestOperation *)DELETE:(NSString *)URLString
{
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"DELETE" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil];
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];

[self.operationQueue addOperation:operation];

return operation;
Expand All @@ -204,7 +213,11 @@ - (NSString *)description {
return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.operationQueue];
}

#pragma mark - NSCoding
#pragma mark - NSecureCoding

+ (BOOL)supportsSecureCoding {
return YES;
}

- (id)initWithCoder:(NSCoder *)decoder {
NSURL *baseURL = [decoder decodeObjectForKey:NSStringFromSelector(@selector(baseURL))];
Expand All @@ -214,8 +227,8 @@ - (id)initWithCoder:(NSCoder *)decoder {
return nil;
}

self.requestSerializer = [decoder decodeObjectForKey:NSStringFromSelector(@selector(requestSerializer))];
self.responseSerializer = [decoder decodeObjectForKey:NSStringFromSelector(@selector(responseSerializer))];
self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))];
self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];

return self;
}
Expand Down
2 changes: 1 addition & 1 deletion QiniuSDK/AFNetworking/AFHTTPSessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

#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)

@interface AFHTTPSessionManager : AFURLSessionManager <NSCoding, NSCopying>
@interface AFHTTPSessionManager : AFURLSessionManager <NSSecureCoding, NSCopying>

/**
The URL used to monitor reachability, and construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods.
Expand Down
23 changes: 16 additions & 7 deletions QiniuSDK/AFNetworking/AFHTTPSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

#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)

#import "AFHTTPRequestOperation.h"
#import "AFURLRequestSerialization.h"
#import "AFURLResponseSerialization.h"

#import <Availability.h>
#import <Security/Security.h>
Expand Down Expand Up @@ -278,15 +279,23 @@ - (NSString *)description {
return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue];
}

#pragma mark - NSCoding
#pragma mark - NSecureCoding

+ (BOOL)supportsSecureCoding {
return YES;
}

- (id)initWithCoder:(NSCoder *)decoder {
NSURL *baseURL = [decoder decodeObjectForKey:NSStringFromSelector(@selector(baseURL))];
NSURLSessionConfiguration *configuration = [decoder decodeObjectForKey:@"sessionConfiguration"];
NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))];
NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"];
if (!configuration) {
NSString *configurationIdentifier = [decoder decodeObjectForKey:@"identifier"];
NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"];
if (configurationIdentifier) {
#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100)
configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier];
#else
configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier];
#endif
}
}

Expand All @@ -295,8 +304,8 @@ - (id)initWithCoder:(NSCoder *)decoder {
return nil;
}

self.requestSerializer = [decoder decodeObjectForKey:NSStringFromSelector(@selector(requestSerializer))];
self.responseSerializer = [decoder decodeObjectForKey:NSStringFromSelector(@selector(responseSerializer))];
self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))];
self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];

return self;
}
Expand Down
2 changes: 2 additions & 0 deletions QiniuSDK/AFNetworking/AFNetworkReachabilityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
/**
`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.
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.
Expand Down
7 changes: 7 additions & 0 deletions QiniuSDK/AFNetworking/AFNetworkReachabilityManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }];
});

}

static const void * AFNetworkReachabilityRetainCallback(const void *info) {
Expand Down Expand Up @@ -188,6 +189,7 @@ - (void)startMonitoring {
if (strongSelf.networkReachabilityStatusBlock) {
strongSelf.networkReachabilityStatusBlock(status);
}

};

SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
Expand All @@ -206,6 +208,11 @@ - (void)startMonitoring {
AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
dispatch_async(dispatch_get_main_queue(), ^{
callback(status);

NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }];


});
});
}
Expand Down
Loading

0 comments on commit a228567

Please sign in to comment.