File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,19 @@ class Response {
19
19
),
20
20
);
21
21
22
+ /// Create a [Response] with a stream of bytes.
23
+ Response .stream ({
24
+ int statusCode = 200 ,
25
+ Stream <List <int >>? body,
26
+ Map <String , Object >? headers,
27
+ }) : this ._(
28
+ shelf.Response (
29
+ statusCode,
30
+ body: body,
31
+ headers: headers,
32
+ ),
33
+ );
34
+
22
35
/// Create a [Response] with a byte array body.
23
36
Response .bytes ({
24
37
int statusCode = 200 ,
Original file line number Diff line number Diff line change @@ -100,6 +100,15 @@ void main() {
100
100
});
101
101
});
102
102
103
+ group ('stream' , () {
104
+ test ('has correct body' , () {
105
+ final bytes = utf8.encode ('hello' );
106
+ final stream = Stream .value (bytes);
107
+ final response = Response .stream (body: stream);
108
+ expect (response.bytes (), emits (equals (bytes)));
109
+ });
110
+ });
111
+
103
112
group ('formData' , () {
104
113
final contentTypeFormUrlEncoded = {
105
114
HttpHeaders .contentTypeHeader: formUrlEncodedContentType.mimeType
You can’t perform that action at this time.
0 commit comments