Skip to content

Commit bb86cf3

Browse files
authored
Provide access to NSURLSession.sessionDescription (#881)
1 parent 1500a71 commit bb86cf3

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

pkgs/cupertino_http/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.1.1
2+
3+
* Add a `URLSession.sessionDescription` field.
4+
15
## 0.1.0
26

37
* Restructure `package:cupertino_http` to offer a single `import`.

pkgs/cupertino_http/example/integration_test/url_session_test.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ void testURLSession(URLSession session) {
185185
server.close();
186186
});
187187

188+
test('sessionDescription', () async {
189+
session.sessionDescription = null;
190+
expect(session.sessionDescription, null);
191+
session.sessionDescription = 'Happy Days!';
192+
expect(session.sessionDescription, 'Happy Days!');
193+
});
194+
188195
test('dataTask', () async {
189196
final task = session.dataTaskWithRequest(
190197
URLRequest.fromUrl(Uri.parse('http://localhost:${server.port}')))

pkgs/cupertino_http/lib/src/cupertino_api.dart

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,15 +1067,24 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
10671067
onFinishedDownloading: onFinishedDownloading,
10681068
onComplete: onComplete);
10691069
}
1070-
// A **copy** of the configuration for this sesion.
1071-
//
1072-
// See [NSURLSession.configuration](https://developer.apple.com/documentation/foundation/nsurlsession/1411477-configuration)
1070+
1071+
/// A **copy** of the configuration for this sesion.
1072+
///
1073+
/// See [NSURLSession.configuration](https://developer.apple.com/documentation/foundation/nsurlsession/1411477-configuration)
10731074
URLSessionConfiguration get configuration => URLSessionConfiguration._(
10741075
ncb.NSURLSessionConfiguration.castFrom(_nsObject.configuration!));
10751076

1076-
// Create a [URLSessionTask] that accesses a server URL.
1077-
//
1078-
// See [NSURLSession dataTaskWithRequest:](https://developer.apple.com/documentation/foundation/nsurlsession/1410592-datataskwithrequest)
1077+
/// A description of the session that may be useful for debugging.
1078+
///
1079+
/// See [NSURLSession.sessionDescription](https://developer.apple.com/documentation/foundation/nsurlsession/1408277-sessiondescription)
1080+
String? get sessionDescription =>
1081+
toStringOrNull(_nsObject.sessionDescription);
1082+
set sessionDescription(String? value) =>
1083+
_nsObject.sessionDescription = value?.toNSString(linkedLibs);
1084+
1085+
/// Create a [URLSessionTask] that accesses a server URL.
1086+
///
1087+
/// See [NSURLSession dataTaskWithRequest:](https://developer.apple.com/documentation/foundation/nsurlsession/1410592-datataskwithrequest)
10791088
URLSessionTask dataTaskWithRequest(URLRequest request) {
10801089
final task =
10811090
URLSessionTask._(_nsObject.dataTaskWithRequest_(request._nsObject));

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.1.0
5+
version: 0.1.1
66
repository: https://github.com/dart-lang/http/tree/master/pkgs/cupertino_http
77

88
environment:

0 commit comments

Comments
 (0)