Skip to content

Commit dfa371b

Browse files
committed
Merge pull request #27 from longbai/fixed_error_non_utf8
fixed non utf8 body
2 parents 74c338f + 2c1d2e4 commit dfa371b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

QiniuSDK/Common/QNConfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525

2626
const UInt32 kQNRetryMax = 3;
2727

28-
const float kQNTimeoutInterval = 30.0;
28+
const float kQNTimeoutInterval = 60.0;

QiniuSDK/Http/QNResponseInfo.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ - (instancetype)init:(int)status
9393
NSError *tmp;
9494
NSDictionary *uInfo = [NSJSONSerialization JSONObjectWithData:body options:NSJSONReadingMutableLeaves error:&tmp];
9595
if (tmp != nil) {
96-
uInfo = @{ @"error":[[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding] };
96+
// 出现错误时,如果信息是非UTF8编码会失败,返回nil
97+
NSString *str = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding];
98+
if (str == nil) {
99+
str = @"";
100+
}
101+
uInfo = @{ @"error": str };
97102
}
98103
_error = [[NSError alloc] initWithDomain:domain code:_statusCode userInfo:uInfo];
99104
}

0 commit comments

Comments
 (0)