Line data Source code
1 : // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 : // for details. All rights reserved. Use of this source code is governed by a
3 : // BSD-style license that can be found in the LICENSE file.
4 :
5 : import 'dart:async';
6 :
7 : import 'byte_stream.dart';
8 : import 'base_response.dart';
9 : import 'base_request.dart';
10 : import 'utils.dart';
11 :
12 : /// An HTTP response where the response body is received asynchronously after
13 : /// the headers have been received.
14 : class StreamedResponse extends BaseResponse {
15 : /// The stream from which the response body data can be read. This should
16 : /// always be a single-subscription stream.
17 : final ByteStream stream;
18 :
19 : /// Creates a new streaming response. [stream] should be a single-subscription
20 : /// stream.
21 : StreamedResponse(
22 : Stream<List<int>> stream,
23 : int statusCode,
24 : {int contentLength,
25 : BaseRequest request,
26 : Map<String, String> headers: const {},
27 : bool isRedirect: false,
28 : bool persistentConnection: true,
29 : String reasonPhrase})
30 0 : : this.stream = toByteStream(stream),
31 0 : super(
32 : statusCode,
33 : contentLength: contentLength,
34 : request: request,
35 : headers: headers,
36 : isRedirect: isRedirect,
37 : persistentConnection: persistentConnection,
38 : reasonPhrase: reasonPhrase);
39 : }
|