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_request; | 5 library streamed_request; |
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'; |
(...skipping 14 matching lines...) Expand all Loading... |
25 /// Closing this signals the end of the request. | 25 /// Closing this signals the end of the request. |
26 EventSink<List<int>> get sink => _controller.sink; | 26 EventSink<List<int>> get sink => _controller.sink; |
27 | 27 |
28 /// The controller for [sink], from which [BaseRequest] will read data for | 28 /// The controller for [sink], from which [BaseRequest] will read data for |
29 /// [finalize]. | 29 /// [finalize]. |
30 final StreamController<List<int>> _controller; | 30 final StreamController<List<int>> _controller; |
31 | 31 |
32 /// Creates a new streaming request. | 32 /// Creates a new streaming request. |
33 StreamedRequest(String method, Uri url) | 33 StreamedRequest(String method, Uri url) |
34 : super(method, url), | 34 : super(method, url), |
35 _controller = new StreamController<List<int>>(); | 35 _controller = new StreamController<List<int>>(sync: true); |
36 | 36 |
37 /// Freezes all mutable fields other than [stream] and returns a | 37 /// Freezes all mutable fields other than [stream] and returns a |
38 /// single-subscription [ByteStream] that emits the data being written to | 38 /// single-subscription [ByteStream] that emits the data being written to |
39 /// [sink]. | 39 /// [sink]. |
40 ByteStream finalize() { | 40 ByteStream finalize() { |
41 super.finalize(); | 41 super.finalize(); |
42 return new ByteStream(_controller.stream); | 42 return new ByteStream(_controller.stream); |
43 } | 43 } |
44 } | 44 } |
OLD | NEW |