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