Skip to content

Commit 9e6a7b2

Browse files
committed
Merge pull request #62 from qiniu/develop
Release 6.2.5
2 parents 211b736 + 5705af0 commit 9e6a7b2

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

QiniuSDK/QiniuUtils.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
NSDictionary *dic = nil;
1919
NSError *httpError = nil;
2020
long errorCode = 400;
21-
21+
2222
if (request) {
2323
NSDictionary *responseObj = request.responseObject;
2424
if ([responseObj isKindOfClass:NSDictionary.class]) {
@@ -27,7 +27,7 @@
2727
httpError = [request error];
2828
errorCode = [request response].statusCode;
2929
}
30-
30+
3131
NSString *errorDescription = nil;
3232
if (dic) { // Check if there is response content.
3333
NSObject *errorObj = [dic objectForKey:kQiniuErrorKey];
@@ -39,11 +39,12 @@
3939
errorCode = [httpError code];
4040
errorDescription = [httpError localizedDescription];
4141
}
42-
43-
NSDictionary *userInfo = nil;
42+
43+
NSString *reqid = [[request.response allHeaderFields] objectForKey:@"X-Reqid"];
44+
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObject:reqid forKey:@"reqid"];
4445
if (errorDescription) {
45-
userInfo = [NSDictionary dictionaryWithObject:errorDescription forKey:kQiniuErrorKey];
46+
[userInfo setObject:errorDescription forKey:kQiniuErrorKey];
4647
}
47-
48+
4849
return [NSError errorWithDomain:kQiniuErrorDomain code:errorCode userInfo:userInfo];
4950
}

QiniuSDKTests/QiniuSDKTests.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ - (void) testSimpleUpload
110110
XCTAssertEqual(_succeed, YES, "SimpleUpload failed, error: %@", _error);
111111
}
112112

113+
- (void) testSimpleUploadFailed
114+
{
115+
QiniuSimpleUploader *uploader = [QiniuSimpleUploader uploaderWithToken:@""];
116+
uploader.delegate = self;
117+
[uploader uploadFile:_filePath key:[NSString stringWithFormat:@"test-%@.png", [self timeString]] extra:nil];
118+
[self waitFinish];
119+
XCTAssertEqual(NO, NO, "SimpleUpload should failed, error: %@", _error);
120+
}
121+
113122

114123
- (void) testSimpleUploadWithUndefinedKey
115124
{

0 commit comments

Comments
 (0)