Skip to content

Commit eecd8fe

Browse files
author
garenwang
committed
fix
1 parent e2410da commit eecd8fe

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

QCloudCore/Classes/Base/QCLOUDRestNet/CoreRequest/QCloudRequestData.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "QCloudRequestData.h"
1010
#import "NSError+QCloudNetworking.h"
1111
#import "QCloudHTTPBodyPart.h"
12+
#import "QCloudHTTPRequest.h"
1213
#if TARGET_OS_IOS
1314
#import <UIKit/UIKit.h>
1415
#endif
@@ -380,7 +381,10 @@ - (NSString *)description {
380381
- (void)setServerURL:(NSString *)serverURL{
381382
if (self.endpoint) {
382383
_serverURL = [self.endpoint serverURLWithBucket:self.bucket appID:self.appId regionName:self.region].absoluteString;
383-
}else if(self.needChangeHost){
384+
if (self.needChangeHost && [QCloudHTTPRequest needChangeHost:_serverURL]) {
385+
_serverURL = [_serverURL stringByReplacingOccurrencesOfString:@"myqcloud.com" withString:emergencyHost];
386+
}
387+
}else if(self.needChangeHost && [QCloudHTTPRequest needChangeHost:serverURL]){
384388
_serverURL = [serverURL stringByReplacingOccurrencesOfString:@"myqcloud.com" withString:emergencyHost];
385389
}else{
386390
_serverURL = serverURL;

QCloudCore/Classes/Base/QCLOUDRestNet/Error/NSError+QCloudNetworking.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ + (BOOL)isNetworkErrorAndRecoverable:(NSError *)error {
4545
case NSURLErrorClientCertificateRejected:
4646
case NSURLErrorClientCertificateRequired:
4747
case NSURLErrorCannotLoadFromNetwork:
48-
return NO;
4948
case NSURLErrorCannotConnectToHost:
5049
default:
5150
return YES;

QCloudCore/Classes/Base/QCLOUDRestNet/SessionSupport/QCloudHTTPSessionManager.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,7 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp
387387
if (QCloudFileExist(httpRequset.downloadingTempURL.path)) {
388388
httpRequset.localCacheDownloadOffset = QCloudFileSize(httpRequset.downloadingTempURL.path);
389389
}
390-
if (taskData.response.statusCode / 100 == 5) {
391-
httpRequset.requestData.needChangeHost = [httpRequset needChangeHost] && !httpRequset.runOnService.configuration.disableChangeHost && ![taskData.response.allHeaderFields.allKeys containsObject:@"x-cos-request-id"];
392-
}else{
393-
httpRequset.requestData.needChangeHost = [httpRequset needChangeHost] && !httpRequset.runOnService.configuration.disableChangeHost;
394-
}
395-
390+
httpRequset.requestData.needChangeHost = !httpRequset.runOnService.configuration.disableChangeHost;
396391
[httpRequset setValue:@(YES) forKey:@"isRetry"];
397392
httpRequset.retryCount = taskData.httpRequest.retryCount + 1;
398393
[weakSelf executeRestHTTPReqeust:httpRequset];

0 commit comments

Comments
 (0)