Skip to content

Commit 6ccc0ff

Browse files
author
garenwang
committed
# 5.9.6
1.签名修复
1 parent 7919fdc commit 6ccc0ff

16 files changed

+87
-39
lines changed

CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# 5.9.5
2-
1.新增媒体处理接口。
3-
2.新增存储桶防盗链接口。
4-
3.新增视频审核接口。
1+
# 5.9.6
2+
1.签名修复
53

64
# 5.9.4
75
1.修复已知bug

QCloudCOSXML.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
22
s.name = "QCloudCOSXML"
33

44

5-
s.version = "5.9.5"
5+
s.version = "5.9.6"
66

77

88
s.summary = "QCloudCOSXML 腾讯云iOS-SDK组件"
@@ -22,15 +22,15 @@ s.version = "5.9.5"
2222
s.subspec 'Default' do |default|
2323
default.source_files = 'QCloudCOSXML/Classes/**/*','QCloudCOSXML/Classes/QCloudCOSXML/*'
2424

25-
default.dependency "QCloudCore",'5.9.5'
25+
default.dependency "QCloudCore",'5.9.6'
2626
end
2727
s.subspec 'Slim' do |slim|
2828
slim.source_files = 'QCloudCOSXML/Classes/**/*','QCloudCOSXML/Classes/QCloudCOSXML/*'
29-
slim.dependency "QCloudCore/WithoutMTA",'5.9.5'
29+
slim.dependency "QCloudCore/WithoutMTA",'5.9.6'
3030
end
3131
s.subspec 'Transfer' do |transfer|
3232
transfer.source_files = 'QCloudCOSXML/Classes/*','QCloudCOSXML/Classes/Transfer/**/*','QCloudCOSXML/Classes/Base/**/*'
33-
transfer.dependency "QCloudCore/WithoutMTA",'5.9.5'
33+
transfer.dependency "QCloudCore/WithoutMTA",'5.9.6'
3434

3535
end
3636

QCloudCOSXML/Classes/Manager/QCloudCOSXMLService+Manager.m

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,30 @@ - (void)getPresignedURL:(QCloudGetPresignedURLRequest *)request {
271271
request:request
272272
urlRequest:(NSMutableURLRequest *)urlRequest
273273
compelete:^(QCloudSignature *signature, NSError *error) {
274-
NSString *authorizatioinString = signature.signature;
274+
NSString *signatureStr = signature.signature;
275+
NSMutableArray *paramas = [signatureStr componentsSeparatedByString:@"&"];
276+
[[paramas copy] enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull stop) {
277+
if([obj hasPrefix:@"q-url-param-list"]){
278+
NSArray *temp = [obj componentsSeparatedByString:@"="];
279+
NSString *key = temp.firstObject;
280+
NSString *value = [QCloudStrigngURLEncode(QCloudStrigngURLEncode(temp.lastObject , NSUTF8StringEncoding), NSUTF8StringEncoding) lowercaseString];
281+
paramas[idx] = [NSString stringWithFormat:@"%@=%@",key,value];
282+
*stop = YES;
283+
}
284+
}];
285+
NSString *authorizatioinString = [paramas componentsJoinedByString:@"&"];
275286
if ([requestURLString hasSuffix:@"&"] || [requestURLString hasSuffix:@"?"]) {
276287
requestURLString = [requestURLString stringByAppendingString:authorizatioinString];
277-
} else {
288+
} else if([requestURLString containsString:@"?"] && ![requestURLString hasSuffix:@"&"]){
289+
requestURLString = [requestURLString stringByAppendingFormat:@"&%@", authorizatioinString];
290+
}else {
278291
requestURLString = [requestURLString stringByAppendingFormat:@"?%@", authorizatioinString];
279292
}
280293
if (signature.token) {
281294
requestURLString =
282295
[requestURLString stringByAppendingFormat:@"&x-cos-security-token=%@", signature.token];
283296
}
297+
284298
QCloudGetPresignedURLResult *result = [[QCloudGetPresignedURLResult alloc] init];
285299
result.presienedURL = requestURLString;
286300
if (request.finishBlock) {

QCloudCOSXML/Classes/Manager/request/QCloudGetPresignedURLRequest.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ NS_ASSUME_NONNULL_BEGIN
7373
@property (nonatomic, readonly) NSString *contentMD5;
7474
@property (nonatomic, readonly) NSDictionary<NSString *, NSString *> *requestHeaders;
7575
@property (nonatomic, readonly) NSDictionary<NSString *, NSString *> *requestParameters;
76+
@property (nonatomic, readonly) NSArray<NSString *> *uriComponents;
7677
@property (nonatomic, assign) bool isUseSignature;
78+
//获取预签名函数,默认签入Header Host;您也可以选择不签入Header Host,但可能导致请求失败或安全漏洞
79+
@property (nonatomic, assign) bool signHost;
7780
/**
7881
添加使用预签名请求的头部
7982
@@ -90,6 +93,8 @@ NS_ASSUME_NONNULL_BEGIN
9093
*/
9194
- (void)setValue:(NSString *_Nullable)value forRequestParameter:(NSString *_Nullable)requestParameter;
9295

96+
- (void)setURICompnent:(NSString *)component;
97+
9398
/**
9499
设置完成回调。请求完成后会通过该回调来获取结果,如果没有error,那么可以认为请求成功。
95100

QCloudCOSXML/Classes/Manager/request/QCloudGetPresignedURLRequest.m

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@interface QCloudGetPresignedURLRequest ()
1212
@property (nonatomic, strong) NSMutableDictionary<NSString *, NSString *> *internalRequestParameters;
1313
@property (nonatomic, strong) NSMutableDictionary<NSString *, NSString *> *internalRequestHeaders;
14+
@property (nonatomic, strong) NSMutableArray *internalUriComponents;
1415
//@property (nonatomic, copy) void(^finishBlock)(QCloudGetPresignedURLResult* result, NSError* error);
1516
@end
1617

@@ -20,7 +21,9 @@ - (instancetype)init {
2021
if (self) {
2122
self.internalRequestParameters = [NSMutableDictionary dictionary];
2223
self.internalRequestHeaders = [NSMutableDictionary dictionary];
24+
self.internalUriComponents = [NSMutableArray array];
2325
self.isUseSignature = YES;
26+
self.signHost = YES;
2427
}
2528
return self;
2629
}
@@ -31,6 +34,10 @@ - (instancetype)init {
3134
- (NSDictionary<NSString *, NSString *> *)requestParameters {
3235
return [NSDictionary dictionaryWithDictionary:self.internalRequestParameters];
3336
}
37+
38+
-(NSMutableArray<NSString *> *)uriComponents{
39+
return [NSMutableArray arrayWithArray:self.internalUriComponents];
40+
}
3441
- (NSString *)contentType {
3542
return [self.internalRequestHeaders objectForKey:@"Content-Type"];
3643
}
@@ -51,6 +58,9 @@ - (void)setValue:(NSString *_Nullable)value forRequestHeader:(NSString *)request
5158
[self.internalRequestHeaders setValue:value forKey:requestHeader];
5259
}
5360

61+
- (void)setURICompnent:(NSString *)component{
62+
[self.internalUriComponents addObject:component];
63+
}
5464
- (void)setValue:(NSString *_Nullable)value forRequestParameter:(NSString *)requestParameter {
5565
[self.internalRequestParameters setValue:value forKey:requestParameter];
5666
}
@@ -76,11 +86,22 @@ - (NSURLRequest *)buildURLRequest:(NSError *__autoreleasing *)error {
7686
if (self.object) {
7787
[URLString appendFormat:@"/%@", self.object];
7888
}
79-
89+
90+
[self.uriComponents enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
91+
[URLString appendFormat:@"?%@", obj];
92+
}];
93+
94+
95+
if(self.signHost){
96+
NSURL *url = [NSURL URLWithString:URLString];
97+
[self.internalRequestHeaders setValue:url.host forKey:@"host"];
98+
}
8099
[self.requestHeaders enumerateKeysAndObjectsUsingBlock:^(NSString *_Nonnull key, NSString *_Nonnull obj, BOOL *_Nonnull stop) {
81100
[mutableURLRequest setValue:obj forHTTPHeaderField:key];
82101
}];
102+
83103

104+
84105
NSString *paramters = QCloudURLEncodeParamters(self.requestParameters, NO, NSUTF8StringEncoding);
85106
NSString *resultURL;
86107
if (paramters && paramters.length > 0) {
@@ -117,7 +138,7 @@ - (NSURLRequest *)buildURLRequest:(NSError *__autoreleasing *)error {
117138

118139
kCFStringEncodingUTF8));
119140
[mutableURLRequest setURL:[NSURL URLWithString:encodedString]];
120-
141+
121142
return mutableURLRequest;
122143
}
123144

QCloudCOSXML/Classes/QCloudCOSXMLVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#ifndef QCloudCOSXMLModuleVersion_h
77
#define QCloudCOSXMLModuleVersion_h
8-
#define QCloudCOSXMLModuleVersionNumber 509005
8+
#define QCloudCOSXMLModuleVersionNumber 509006
99

1010
//dependency
1111

QCloudCOSXML/Classes/QCloudCOSXMLVersion.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#import "QCloudCOSXMLVersion.h"
2-
NSString * const QCloudCOSXMLModuleVersion = @"5.9.5";
2+
NSString * const QCloudCOSXMLModuleVersion = @"5.9.6";
33
NSString * const QCloudCOSXMLModuleName = @"QCloudCOSXML";
44
@interface QCloudQCloudCOSXMLLoad : NSObject
55
@end

QCloudCOSXML/Classes/Transfer/request/QCloudCOSXMLDownloadObjectRequest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
使用分块及续传下载时,指定任务记录文件的路径
117117
*/
118118
@property (strong, nonatomic) NSString *resumableTaskFile;
119+
//针对本次下载行流量控制的限速值,必须为数字,单位默认为 bit/s。限速值设置范围为819200 - 838860800,即100KB/s - 100MB/s,如果超出该范围将返回400错误
120+
@property (nonatomic, assign) NSInteger trafficLimit;
119121
- (void)setCOSServerSideEncyption;
120122
- (void)setCOSServerSideEncyptionWithCustomerKey:(NSString *)customerKey;
121123

QCloudCOSXML/Classes/Transfer/request/QCloudCOSXMLDownloadObjectRequest.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ - (void)fakeStart {
114114
- (void)startGetObject {
115115

116116
QCloudGetObjectRequest *request = [QCloudGetObjectRequest new];
117+
request.trafficLimit = self.trafficLimit;
117118
request.customHeaders = [self.customHeaders copy];
118119
request.downloadingURL = self.downloadingURL;
119120
request.localCacheDownloadOffset = self.localCacheDownloadOffset;

QCloudCOSXML/Classes/Transfer/request/QCloudGetObjectRequest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ RFC 2616 中定义的指定文件下载范围,以字节(bytes)为单位
139139
给图片添加盲水印
140140
*/
141141
@property (strong, nonatomic) NSString *watermarkRule;
142+
//针对本次下载行流量控制的限速值,必须为数字,单位默认为 bit/s。限速值设置范围为819200 - 838860800,即100KB/s - 100MB/s,如果超出该范围将返回400错误
143+
@property (nonatomic, assign) NSInteger trafficLimit;
142144

143145
@end
144146
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)