Skip to content

Commit 1656202

Browse files
authored
All the user to specify the network service type. (#781)
1 parent d8d2456 commit 1656202

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

pkgs/cupertino_http/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
## 0.0.5
2+
3+
* Add the ability to set network service type.
4+
* Add the ability to control multipath TCP connections.
5+
16
## 0.0.4
27

38
* Add the ability to control caching policy.
4-
* Add the ability to control multipath TCP connections.
59

610
## 0.0.3
711

pkgs/cupertino_http/example/integration_test/url_session_configuration_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ void testProperties(URLSessionConfiguration config) {
6666
expect(config.multipathServiceType,
6767
URLSessionMultipathServiceType.multipathServiceTypeNone);
6868
});
69+
test('networkServiceType', () {
70+
expect(config.networkServiceType,
71+
URLRequestNetworkService.networkServiceTypeDefault);
72+
config.networkServiceType =
73+
URLRequestNetworkService.networkServiceTypeResponsiveData;
74+
expect(config.networkServiceType,
75+
URLRequestNetworkService.networkServiceTypeResponsiveData);
76+
config.networkServiceType =
77+
URLRequestNetworkService.networkServiceTypeDefault;
78+
expect(config.networkServiceType,
79+
URLRequestNetworkService.networkServiceTypeDefault);
80+
});
6981
test('requestCachePolicy', () {
7082
config.requestCachePolicy = URLRequestCachePolicy.returnCacheDataDontLoad;
7183
expect(config.requestCachePolicy,

pkgs/cupertino_http/lib/cupertino_http.dart

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ enum HTTPCookieAcceptPolicy {
5050
httpCookieAcceptPolicyOnlyFromMainDocumentDomain,
5151
}
5252

53-
// Controls how response data is cached.
54-
//
55-
// See [URLRequestCachePolicy](https://developer.apple.com/documentation/foundation/nsurlrequestcachepolicy).
53+
/// Controls how response data is cached.
54+
///
55+
/// See [URLRequestCachePolicy](https://developer.apple.com/documentation/foundation/nsurlrequestcachepolicy).
5656
enum URLRequestCachePolicy {
5757
useProtocolCachePolicy,
5858
reloadIgnoringLocalCacheData,
@@ -72,17 +72,33 @@ enum URLSessionMultipathServiceType {
7272
multipathServiceTypeAggregate,
7373
}
7474

75-
// Controls how [URLSessionTask] execute will proceed after the response is
76-
// received.
77-
//
78-
// See [NSURLSessionResponseDisposition](https://developer.apple.com/documentation/foundation/nsurlsessionresponsedisposition).
75+
/// Controls how [URLSessionTask] execute will proceed after the response is
76+
/// received.
77+
///
78+
/// See [NSURLSessionResponseDisposition](https://developer.apple.com/documentation/foundation/nsurlsessionresponsedisposition).
7979
enum URLSessionResponseDisposition {
8080
urlSessionResponseCancel,
8181
urlSessionResponseAllow,
8282
urlSessionResponseBecomeDownload,
8383
urlSessionResponseBecomeStream
8484
}
8585

86+
/// Provides in indication to the operating system on what type of requests
87+
/// are being sent.
88+
///
89+
/// See [NSURLRequestNetworkServiceType](https://developer.apple.com/documentation/foundation/nsurlrequestnetworkservicetype).
90+
enum URLRequestNetworkService {
91+
networkServiceTypeDefault,
92+
networkServiceTypeVoIP,
93+
networkServiceTypeVideo,
94+
networkServiceTypeBackground,
95+
networkServiceTypeVoice,
96+
networkServiceTypeResponsiveData,
97+
networkServiceTypeAVStreaming,
98+
networkServiceTypeResponsiveAV,
99+
networkServiceTypeCallSignaling
100+
}
101+
86102
/// Information about a failure.
87103
///
88104
/// See [NSError](https://developer.apple.com/documentation/foundation/nserror)
@@ -220,6 +236,15 @@ class URLSessionConfiguration
220236
set multipathServiceType(URLSessionMultipathServiceType value) =>
221237
_nsObject.multipathServiceType = value.index;
222238

239+
/// Provides in indication to the operating system on what type of requests
240+
/// are being sent.
241+
///
242+
/// See [NSURLSessionConfiguration.networkServiceType](https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/1411606-networkservicetype).
243+
URLRequestNetworkService get networkServiceType =>
244+
URLRequestNetworkService.values[_nsObject.networkServiceType];
245+
set networkServiceType(URLRequestNetworkService value) =>
246+
_nsObject.networkServiceType = value.index;
247+
223248
// Controls how to deal with response caching.
224249
//
225250
// See [NSURLSessionConfiguration.requestCachePolicy](https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/1411655-requestcachepolicy)

0 commit comments

Comments
 (0)