Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Mar 11, 2024
1 parent 98c0ae7 commit 34d3908
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cupertino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ jobs:
run: |
cd example
flutter pub get
flutter test --timeout=1200s integration_test/
flutter test --timeout=1200s integration_test/main.dart
2 changes: 2 additions & 0 deletions pkgs/cupertino_http/example/integration_test/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'url_session_delegate_test.dart' as url_session_delegate_test;
import 'url_session_task_test.dart' as url_session_task_test;
import 'url_session_test.dart' as url_session_test;
import 'utils_test.dart' as utils_test;
import 'web_socket_conformance_test.dart' as web_socket_conformance_test;

/// Execute all the tests in this directory.
///
Expand All @@ -43,4 +44,5 @@ void main() {
url_session_task_test.main();
url_session_test.main();
utils_test.main();
web_socket_conformance_test.main();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:cupertino_http/cupertino_http.dart';
import 'package:test/test.dart';
import 'package:web_socket_conformance_tests/web_socket_conformance_tests.dart';

void main() {
testAll(CupertinoWebSocket.connect);

group('defaultSessionConfiguration', () {
testAll(
CupertinoWebSocket.connect,
);
});
group('fromSessionConfiguration', () {
final config = URLSessionConfiguration.ephemeralSessionConfiguration();
testAll((uri, {protocols}) =>
CupertinoWebSocket.connect(uri, protocols: protocols, config: config));
});
}
7 changes: 4 additions & 3 deletions pkgs/cupertino_http/lib/src/cupertino_web_socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ConnectionException extends WebSocketException {
String toString() => 'CupertinoErrorWebSocketException: $message $error';
}

/// A [WebSocket] using the
/// A [WebSocket] implemented using the
/// [NSURLSessionWebSocketTask API](https://developer.apple.com/documentation/foundation/nsurlsessionwebsockettask).
class CupertinoWebSocket implements WebSocket {
/// Create a new WebSocket connection using the
Expand All @@ -32,7 +32,8 @@ class CupertinoWebSocket implements WebSocket {
/// the peer is able to select. See
/// [RFC-6455 1.9](https://datatracker.ietf.org/doc/html/rfc6455#section-1.9).
static Future<CupertinoWebSocket> connect(Uri url,
{Iterable<String>? protocols}) async {
{Iterable<String>? protocols,
URLSessionConfiguration? config}) async {
if (!url.isScheme('ws') && !url.isScheme('wss')) {
throw ArgumentError.value(
url, 'url', 'only ws: and wss: schemes are supported');
Expand All @@ -42,7 +43,7 @@ class CupertinoWebSocket implements WebSocket {
late CupertinoWebSocket webSocket;

final session = URLSession.sessionWithConfiguration(
URLSessionConfiguration.defaultSessionConfiguration(),
config ?? URLSessionConfiguration.defaultSessionConfiguration(),
onComplete: (session, task, error) {
if (!readyCompleter.isCompleted) {
if (error != null) {
Expand Down

0 comments on commit 34d3908

Please sign in to comment.