From 4a8b5a9db857e07605f60c1f8358335aee5036a8 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Wed, 9 Oct 2024 18:23:27 -0700 Subject: [PATCH] Stream to NSStream --- pkgs/cupertino_http/CHANGELOG.md | 5 ++++- pkgs/cupertino_http/lib/src/cupertino_api.dart | 7 ++----- pkgs/cupertino_http/lib/src/cupertino_client.dart | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/cupertino_http/CHANGELOG.md b/pkgs/cupertino_http/CHANGELOG.md index 4667f6ab1f..989b18ab45 100644 --- a/pkgs/cupertino_http/CHANGELOG.md +++ b/pkgs/cupertino_http/CHANGELOG.md @@ -1,4 +1,7 @@ -## 1.5.2-wip +## 2.0.0-wip + +* MutableURLRequest.httpBodyStream now takes a `NSInputStream` instead of a + `Stream>`. ## 1.5.1 diff --git a/pkgs/cupertino_http/lib/src/cupertino_api.dart b/pkgs/cupertino_http/lib/src/cupertino_api.dart index 771a245475..e2af108c70 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_api.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_api.dart @@ -62,9 +62,6 @@ abstract class _ObjectHolder { int get hashCode => _nsObject.hashCode; } -objc.NSInputStream _streamToNSInputStream(Stream> stream) => - stream.toNSInputStream(); - /// A cache for [URLRequest]s. Used by [URLSessionConfiguration.cache]. /// /// See [NSURLCache](https://developer.apple.com/documentation/foundation/nsurlcache) @@ -755,8 +752,8 @@ class MutableURLRequest extends URLRequest { /// Sets the body of the request to the given [Stream]. /// /// See [NSMutableURLRequest.HTTPBodyStream](https://developer.apple.com/documentation/foundation/nsurlrequest/1407341-httpbodystream). - set httpBodyStream(Stream> stream) { - _mutableUrlRequest.HTTPBodyStream = _streamToNSInputStream(stream); + set httpBodyStream(objc.NSInputStream stream) { + _mutableUrlRequest.HTTPBodyStream = stream; } set httpMethod(String method) { diff --git a/pkgs/cupertino_http/lib/src/cupertino_client.dart b/pkgs/cupertino_http/lib/src/cupertino_client.dart index 0915144d1f..041f7f584c 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_client.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_client.dart @@ -327,10 +327,10 @@ class CupertinoClient extends BaseClient { // then setting `httpBodyStream` will cause the request to fail - // even if the stream is empty. if (profile == null) { - urlRequest.httpBodyStream = s; + urlRequest.httpBodyStream = s.toNSInputStream(); } else { final splitter = StreamSplitter(s); - urlRequest.httpBodyStream = splitter.split(); + urlRequest.httpBodyStream = splitter.split().toNSInputStream(); unawaited(profile.requestData.bodySink.addStream(splitter.split())); } }