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