Skip to content

Commit

Permalink
Provide access to NSURLSession.sessionDescription (#881)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan authored Feb 27, 2023
1 parent 1500a71 commit bb86cf3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
4 changes: 4 additions & 0 deletions pkgs/cupertino_http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.1

* Add a `URLSession.sessionDescription` field.

## 0.1.0

* Restructure `package:cupertino_http` to offer a single `import`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ void testURLSession(URLSession session) {
server.close();
});

test('sessionDescription', () async {
session.sessionDescription = null;
expect(session.sessionDescription, null);
session.sessionDescription = 'Happy Days!';
expect(session.sessionDescription, 'Happy Days!');
});

test('dataTask', () async {
final task = session.dataTaskWithRequest(
URLRequest.fromUrl(Uri.parse('http://localhost:${server.port}')))
Expand Down
21 changes: 15 additions & 6 deletions pkgs/cupertino_http/lib/src/cupertino_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1067,15 +1067,24 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
onFinishedDownloading: onFinishedDownloading,
onComplete: onComplete);
}
// A **copy** of the configuration for this sesion.
//
// See [NSURLSession.configuration](https://developer.apple.com/documentation/foundation/nsurlsession/1411477-configuration)

/// A **copy** of the configuration for this sesion.
///
/// See [NSURLSession.configuration](https://developer.apple.com/documentation/foundation/nsurlsession/1411477-configuration)
URLSessionConfiguration get configuration => URLSessionConfiguration._(
ncb.NSURLSessionConfiguration.castFrom(_nsObject.configuration!));

// Create a [URLSessionTask] that accesses a server URL.
//
// See [NSURLSession dataTaskWithRequest:](https://developer.apple.com/documentation/foundation/nsurlsession/1410592-datataskwithrequest)
/// A description of the session that may be useful for debugging.
///
/// See [NSURLSession.sessionDescription](https://developer.apple.com/documentation/foundation/nsurlsession/1408277-sessiondescription)
String? get sessionDescription =>
toStringOrNull(_nsObject.sessionDescription);
set sessionDescription(String? value) =>
_nsObject.sessionDescription = value?.toNSString(linkedLibs);

/// Create a [URLSessionTask] that accesses a server URL.
///
/// See [NSURLSession dataTaskWithRequest:](https://developer.apple.com/documentation/foundation/nsurlsession/1410592-datataskwithrequest)
URLSessionTask dataTaskWithRequest(URLRequest request) {
final task =
URLSessionTask._(_nsObject.dataTaskWithRequest_(request._nsObject));
Expand Down
2 changes: 1 addition & 1 deletion pkgs/cupertino_http/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: cupertino_http
description: >
A macOS/iOS Flutter plugin that provides access to the Foundation URL
Loading System.
version: 0.1.0
version: 0.1.1
repository: https://github.com/dart-lang/http/tree/master/pkgs/cupertino_http

environment:
Expand Down

0 comments on commit bb86cf3

Please sign in to comment.