We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 928d7a1 commit 5c7b451Copy full SHA for 5c7b451
lib/src/body.dart
@@ -29,6 +29,9 @@ class Body {
29
/// determined efficiently.
30
final int contentLength;
31
32
+ /// An empty stream for use with empty bodies.
33
+ static const _emptyStream = const Stream.empty();
34
+
35
Body._(this._stream, this.encoding, this.contentLength);
36
37
/// Converts [body] to a byte stream and wraps it in a [Body].
@@ -38,8 +41,9 @@ class Body {
38
41
/// used to convert it to a [Stream<List<int>>].
39
42
factory Body(body, [Encoding encoding]) {
40
43
if (body is Body) return body;
- if (body == null)
- return new Body._(new Stream.fromIterable([]), encoding, 0);
44
+ if (body == null) {
45
+ return new Body._(_emptyStream, encoding, 0);
46
+ }
47
48
Stream<List<int>> stream;
49
int contentLength;
0 commit comments