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