Skip to content

Commit

Permalink
Stream to NSStream
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Oct 10, 2024
1 parent 95880e4 commit 4a8b5a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
5 changes: 4 additions & 1 deletion pkgs/cupertino_http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 1.5.2-wip
## 2.0.0-wip

* MutableURLRequest.httpBodyStream now takes a `NSInputStream` instead of a
`Stream<List<int>>`.

## 1.5.1

Expand Down
7 changes: 2 additions & 5 deletions pkgs/cupertino_http/lib/src/cupertino_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ abstract class _ObjectHolder<T extends objc.NSObject> {
int get hashCode => _nsObject.hashCode;
}

objc.NSInputStream _streamToNSInputStream(Stream<List<int>> stream) =>
stream.toNSInputStream();

/// A cache for [URLRequest]s. Used by [URLSessionConfiguration.cache].
///
/// See [NSURLCache](https://developer.apple.com/documentation/foundation/nsurlcache)
Expand Down Expand Up @@ -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<List<int>> stream) {
_mutableUrlRequest.HTTPBodyStream = _streamToNSInputStream(stream);
set httpBodyStream(objc.NSInputStream stream) {
_mutableUrlRequest.HTTPBodyStream = stream;
}

set httpMethod(String method) {
Expand Down
4 changes: 2 additions & 2 deletions pkgs/cupertino_http/lib/src/cupertino_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
Expand Down

0 comments on commit 4a8b5a9

Please sign in to comment.