Skip to content

Commit 3cb688b

Browse files
committed
Review fixes
1 parent 5294ae2 commit 3cb688b

File tree

6 files changed

+24
-152
lines changed

6 files changed

+24
-152
lines changed

pkgs/cupertino_http/example/integration_test/main.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import 'url_session_configuration_test.dart' as url_session_configuration_test;
1616
import 'url_session_delegate_test.dart' as url_session_delegate_test;
1717
import 'url_session_task_test.dart' as url_session_task_test;
1818
import 'url_session_test.dart' as url_session_test;
19-
import 'utils_test.dart' as utils_test;
2019
import 'web_socket_conformance_test.dart' as web_socket_conformance_test;
2120

2221
/// Execute all the tests in this directory.
@@ -39,6 +38,5 @@ void main() {
3938
url_session_delegate_test.main();
4039
url_session_task_test.main();
4140
url_session_test.main();
42-
utils_test.main();
4341
web_socket_conformance_test.main();
4442
}

pkgs/cupertino_http/example/integration_test/utils_test.dart

Lines changed: 0 additions & 86 deletions
This file was deleted.

pkgs/cupertino_http/example/macos/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@
405405
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
406406
GCC_WARN_UNUSED_FUNCTION = YES;
407407
GCC_WARN_UNUSED_VARIABLE = YES;
408-
MACOSX_DEPLOYMENT_TARGET = 10.14;
408+
MACOSX_DEPLOYMENT_TARGET = 10.15;
409409
MTL_ENABLE_DEBUG_INFO = NO;
410410
SDKROOT = macosx;
411411
SWIFT_COMPILATION_MODE = wholemodule;
@@ -484,7 +484,7 @@
484484
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
485485
GCC_WARN_UNUSED_FUNCTION = YES;
486486
GCC_WARN_UNUSED_VARIABLE = YES;
487-
MACOSX_DEPLOYMENT_TARGET = 10.14;
487+
MACOSX_DEPLOYMENT_TARGET = 10.15;
488488
MTL_ENABLE_DEBUG_INFO = YES;
489489
ONLY_ACTIVE_ARCH = YES;
490490
SDKROOT = macosx;
@@ -531,7 +531,7 @@
531531
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
532532
GCC_WARN_UNUSED_FUNCTION = YES;
533533
GCC_WARN_UNUSED_VARIABLE = YES;
534-
MACOSX_DEPLOYMENT_TARGET = 10.14;
534+
MACOSX_DEPLOYMENT_TARGET = 10.15;
535535
MTL_ENABLE_DEBUG_INFO = NO;
536536
SDKROOT = macosx;
537537
SWIFT_COMPILATION_MODE = wholemodule;

pkgs/cupertino_http/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
ignoresPersistentStateOnLaunch = "NO"
4949
debugDocumentVersioning = "YES"
5050
debugServiceExtension = "internal"
51+
enableGPUValidationMode = "1"
5152
allowLocationSimulation = "YES">
5253
<BuildableProductRunnable
5354
runnableDebuggingMode = "0">

pkgs/cupertino_http/lib/src/cupertino_api.dart

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import 'native_cupertino_bindings.dart'
4040
NSURLSessionResponseDisposition,
4141
NSURLSessionTaskState,
4242
NSURLSessionWebSocketMessageType;
43-
import 'utils.dart';
4443

4544
export 'native_cupertino_bindings.dart'
4645
show
@@ -53,6 +52,11 @@ export 'native_cupertino_bindings.dart'
5352
NSURLSessionWebSocketCloseCode,
5453
NSURLSessionWebSocketMessageType;
5554

55+
objc.NSURL _uriToNSURL(Uri uri) =>
56+
objc.NSURL.URLWithString(uri.toString().toNSString())!;
57+
Uri _nsurlToUri(objc.NSURL url) =>
58+
Uri.parse(url.absoluteString!.toDartString());
59+
5660
abstract class _ObjectHolder<T extends objc.NSObject> {
5761
final T _nsObject;
5862

@@ -100,7 +104,7 @@ class URLCache extends _ObjectHolder<ncb.NSURLCache> {
100104
ncb.NSURLCache.alloc().initWithMemoryCapacity$1(
101105
memoryCapacity,
102106
diskCapacity: diskCapacity,
103-
directoryURL: directory == null ? null : uriToNSURL(directory),
107+
directoryURL: directory == null ? null : _uriToNSURL(directory),
104108
),
105109
);
106110
}
@@ -199,7 +203,7 @@ class URLSessionConfiguration
199203
Map<String, String>? get httpAdditionalHeaders {
200204
if (_nsObject.HTTPAdditionalHeaders case var additionalHeaders?) {
201205
final headers = objc.NSDictionary.castFrom(additionalHeaders);
202-
return stringNSDictionaryToMap(headers);
206+
return (objc.toDartObject(headers) as Map).cast<String, String>();
203207
}
204208
return null;
205209
}
@@ -209,11 +213,8 @@ class URLSessionConfiguration
209213
_nsObject.HTTPAdditionalHeaders = null;
210214
return;
211215
}
212-
final d = objc.NSMutableDictionary.alloc().init();
213-
headers.forEach((key, value) {
214-
d.setObject(value.toNSString(), forKey: key.toNSString());
215-
});
216-
_nsObject.HTTPAdditionalHeaders = d;
216+
_nsObject.HTTPAdditionalHeaders =
217+
objc.toObjCObject(headers) as objc.NSMutableDictionary;
217218
}
218219

219220
/// What policy to use when deciding whether to accept cookies.
@@ -378,12 +379,9 @@ class HTTPURLResponse extends URLResponse {
378379
/// The HTTP headers of the response.
379380
///
380381
/// See [HTTPURLResponse.allHeaderFields](https://developer.apple.com/documentation/foundation/nshttpurlresponse/1417930-allheaderfields)
381-
Map<String, String> get allHeaderFields {
382-
final headers = objc.NSDictionary.castFrom(
383-
_httpUrlResponse.allHeaderFields,
384-
);
385-
return stringNSDictionaryToMap(headers);
386-
}
382+
Map<String, String> get allHeaderFields =>
383+
(objc.toDartObject(_httpUrlResponse.allHeaderFields) as Map)
384+
.cast<String, String>();
387385

388386
@override
389387
String toString() =>
@@ -697,7 +695,7 @@ class URLRequest extends _ObjectHolder<ncb.NSURLRequest> {
697695
///
698696
/// See [NSURLRequest.requestWithURL:](https://developer.apple.com/documentation/foundation/nsurlrequest/1528603-requestwithurl)
699697
factory URLRequest.fromUrl(Uri uri) =>
700-
URLRequest._(ncb.NSURLRequest.requestWithURL(uriToNSURL(uri)));
698+
URLRequest._(ncb.NSURLRequest.requestWithURL(_uriToNSURL(uri)));
701699

702700
/// Returns all of the HTTP headers for the request.
703701
///
@@ -706,7 +704,8 @@ class URLRequest extends _ObjectHolder<ncb.NSURLRequest> {
706704
if (_nsObject.allHTTPHeaderFields == null) {
707705
return null;
708706
} else {
709-
return stringNSDictionaryToMap(_nsObject.allHTTPHeaderFields!);
707+
return (objc.toDartObject(_nsObject.allHTTPHeaderFields!) as Map)
708+
.cast<String, String>();
710709
}
711710
}
712711

@@ -745,7 +744,7 @@ class URLRequest extends _ObjectHolder<ncb.NSURLRequest> {
745744
if (nsUrl == null) {
746745
return null;
747746
}
748-
return nsurlToUri(nsUrl);
747+
return _nsurlToUri(nsUrl);
749748
}
750749

751750
@override
@@ -953,7 +952,7 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
953952
onFinishedDownloading(
954953
URLSession._(nsSession, isBackground: isBackground),
955954
URLSessionDownloadTask._(nsTask),
956-
nsurlToUri(nsUrl),
955+
_nsurlToUri(nsUrl),
957956
);
958957
});
959958
}
@@ -1224,13 +1223,13 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
12241223
final URLSessionWebSocketTask task;
12251224
if (protocols == null) {
12261225
task = URLSessionWebSocketTask._(
1227-
_nsObject.webSocketTaskWithURL(uriToNSURL(uri)),
1226+
_nsObject.webSocketTaskWithURL(_uriToNSURL(uri)),
12281227
);
12291228
} else {
12301229
task = URLSessionWebSocketTask._(
12311230
_nsObject.webSocketTaskWithURL$1(
1232-
uriToNSURL(uri),
1233-
protocols: stringIterableToNSArray(protocols),
1231+
_uriToNSURL(uri),
1232+
protocols: objc.toObjCObject(protocols) as objc.NSArray,
12341233
),
12351234
);
12361235
}

pkgs/cupertino_http/lib/src/utils.dart

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)