File tree Expand file tree Collapse file tree 3 files changed +6
-8
lines changed
QCloudCore/Classes/Base/QCLOUDRestNet Expand file tree Collapse file tree 3 files changed +6
-8
lines changed Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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];
You can’t perform that action at this time.
0 commit comments