Skip to content

Provide access to NSURLSession.sessionDescription #881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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