Skip to content

Commit 4fc3d58

Browse files
authored
Add the ability to configure the max connections to a host. (#790)
1 parent 40ab316 commit 4fc3d58

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

pkgs/cupertino_http/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.0.6
2+
3+
* Make the number of simulateous connections allowed to the same host
4+
configurable.
5+
16
## 0.0.5
27

38
* Add the ability to set network service type.

pkgs/cupertino_http/example/integration_test/url_session_configuration_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ void testProperties(URLSessionConfiguration config) {
4242
expect(config.httpCookieAcceptPolicy,
4343
HTTPCookieAcceptPolicy.httpCookieAcceptPolicyNever);
4444
});
45+
test('httpMaximumConnectionsPerHost', () {
46+
config.httpMaximumConnectionsPerHost = 6;
47+
expect(config.httpMaximumConnectionsPerHost, 6);
48+
config.httpMaximumConnectionsPerHost = 23;
49+
expect(config.httpMaximumConnectionsPerHost, 23);
50+
});
4551
test('httpShouldSetCookies', () {
4652
config.httpShouldSetCookies = true;
4753
expect(config.httpShouldSetCookies, true);

pkgs/cupertino_http/lib/cupertino_http.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,15 @@ class URLSessionConfiguration
214214
set httpCookieAcceptPolicy(HTTPCookieAcceptPolicy value) =>
215215
_nsObject.HTTPCookieAcceptPolicy = value.index;
216216

217+
// The maximun number of connections that a URLSession can have open to the
218+
// same host.
219+
//
220+
// See [NSURLSessionConfiguration.HTTPMaximumConnectionsPerHost](https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/1407597-httpmaximumconnectionsperhost).
221+
int get httpMaximumConnectionsPerHost =>
222+
_nsObject.HTTPMaximumConnectionsPerHost;
223+
set httpMaximumConnectionsPerHost(int value) =>
224+
_nsObject.HTTPMaximumConnectionsPerHost = value;
225+
217226
/// Whether requests should include cookies from the cookie store.
218227
///
219228
/// See [NSURLSessionConfiguration.HTTPShouldSetCookies](https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/1411589-httpshouldsetcookies)
@@ -296,6 +305,7 @@ class URLSessionConfiguration
296305
'discretionary=$discretionary '
297306
'httpCookieAcceptPolicy=$httpCookieAcceptPolicy '
298307
'httpShouldSetCookies=$httpShouldSetCookies '
308+
'httpMaximumConnectionsPerHost=$httpMaximumConnectionsPerHost '
299309
'httpShouldUsePipelining=$httpShouldUsePipelining '
300310
'requestCachePolicy=$requestCachePolicy '
301311
'sessionSendsLaunchEvents=$sessionSendsLaunchEvents '

pkgs/cupertino_http/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: cupertino_http
22
description: >
33
A macOS/iOS Flutter plugin that provides access to the Foundation URL
44
Loading System.
5-
version: 0.0.5
5+
version: 0.0.6
66
repository: https://github.com/dart-lang/http/tree/master/pkgs/cupertino_http
77

88
environment:

0 commit comments

Comments
 (0)