Skip to content

Commit

Permalink
add configuration of HTTPMaximumConnectionsPerHost
Browse files Browse the repository at this point in the history
  • Loading branch information
wlll129 authored and huiguangjun committed Mar 26, 2024
1 parent 1a2c2eb commit cbe9bbd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions AliyunOSSSDK/OSSClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ - (instancetype)initWithEndpoint:(NSString *)endpoint
netConf.proxyPort = conf.proxyPort;
netConf.maxConcurrentRequestCount = conf.maxConcurrentRequestCount;
netConf.enableFollowRedirects = conf.isFollowRedirectsEnable;
netConf.HTTPMaximumConnectionsPerHost = conf.HTTPMaximumConnectionsPerHost;
}
self.networking = [[OSSNetworking alloc] initWithConfiguration:netConf];
}
Expand Down
5 changes: 5 additions & 0 deletions AliyunOSSSDK/OSSModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ Sets the session Id for background file transmission
/// Set whether to allow the redirection with a modified request
@property (nonatomic, assign) BOOL isFollowRedirectsEnable;

/// The maximum number of simultaneous persistent connections per host.
/// The default value is NSURLSessionConfiguration's default value
/// https://developer.apple.com/documentation/foundation/urlsessionconfiguration/1407597-httpmaximumconnectionsperhost
@property (nonatomic, assign) uint32_t HTTPMaximumConnectionsPerHost;

@end

@protocol OSSRequestInterceptor <NSObject>
Expand Down
2 changes: 2 additions & 0 deletions AliyunOSSSDK/OSSModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ - (instancetype)init {
self.cnameExcludeList = @[];
self.isAllowUACarrySystemInfo = YES;
self.isFollowRedirectsEnable = YES;
// When the value <= 0, do not set HTTPMaximumConnectionsPerHost and use the default value of NSURLSessionConfiguration
self.HTTPMaximumConnectionsPerHost = 0;
}
return self;
}
Expand Down
1 change: 1 addition & 0 deletions AliyunOSSSDK/OSSNetworking.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@property (nonatomic, strong) NSString * proxyHost;
@property (nonatomic, strong) NSNumber * proxyPort;
@property (nonatomic, assign) BOOL enableFollowRedirects;
@property (nonatomic, assign) uint32_t HTTPMaximumConnectionsPerHost;
@end


Expand Down
3 changes: 3 additions & 0 deletions AliyunOSSSDK/OSSNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ - (instancetype)initWithConfiguration:(OSSNetworkingConfiguration *)configuratio
if (configuration.timeoutIntervalForResource > 0) {
conf.timeoutIntervalForResource = configuration.timeoutIntervalForResource;
}
if (configuration.HTTPMaximumConnectionsPerHost > 0) {
conf.HTTPMaximumConnectionsPerHost = configuration.HTTPMaximumConnectionsPerHost;
}

if (configuration.proxyHost && configuration.proxyPort) {
// Create an NSURLSessionConfiguration that uses the proxy
Expand Down

0 comments on commit cbe9bbd

Please sign in to comment.