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())); } }