Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(969)

Unified Diff: pkg/http/lib/src/multipart_request.dart

Issue 14051005: Remove deprecated CollectionSink and Stream.pipeInto. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/async/async_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/multipart_request.dart
diff --git a/pkg/http/lib/src/multipart_request.dart b/pkg/http/lib/src/multipart_request.dart
index bc588713cf61d0bd2c4b4654e675bb5da6bbb583..ab66bbdd5db0bb81855d53446b42821bdc89374f 100644
--- a/pkg/http/lib/src/multipart_request.dart
+++ b/pkg/http/lib/src/multipart_request.dart
@@ -41,6 +41,21 @@ class MultipartRequest extends BaseRequest {
static final Random _random = new Random();
+ /// The form fields to send for this request.
+ final Map<String, String> fields;
+
+ /// The private version of [files].
+ final List<MultipartFile> _files;
+
+ /// Creates a new [MultipartRequest].
+ MultipartRequest(String method, Uri url)
+ : super(method, url),
+ fields = {},
+ _files = <MultipartFile>[];
+
+ /// The list of files to upload for this request.
+ List<MultipartFile> get files => _files;
+
/// The total length of the request body, in bytes. This is calculated from
/// [fields] and [files] and cannot be set manually.
int get contentLength {
@@ -52,7 +67,7 @@ class MultipartRequest extends BaseRequest {
encodeUtf8(value).length + "\r\n".length;
});
- for (var file in _files.collection) {
+ for (var file in _files) {
length += "--".length + _BOUNDARY_LENGTH + "\r\n".length +
_headerForFile(file).length +
file.length + "\r\n".length;
@@ -66,25 +81,6 @@ class MultipartRequest extends BaseRequest {
"multipart requests.");
}
- /// The form fields to send for this request.
- final Map<String, String> fields;
-
- /// The sink for files to upload for this request.
- ///
- /// This doesn't need to be closed. When the request is sent, whichever files
- /// are written to this sink at that point will be used.
- CollectionSink<MultipartFile> get files => _files;
-
- /// The private version of [files], typed so that the underlying collection is
- /// accessible.
- final CollectionSink<MultipartFile> _files;
-
- /// Creates a new [MultipartRequest].
- MultipartRequest(String method, Uri url)
- : super(method, url),
- fields = {},
- _files = new CollectionSink<MultipartFile>(<MultipartFile>[]);
-
/// Freezes all mutable fields and returns a single-subscription [ByteStream]
/// that will emit the request body.
ByteStream finalize() {
@@ -111,7 +107,7 @@ class MultipartRequest extends BaseRequest {
writeLine();
});
- Future.forEach(_files.collection, (file) {
+ Future.forEach(_files, (file) {
writeAscii('--$boundary\r\n');
writeAscii(_headerForFile(file));
return writeStreamToSink(file.finalize(), controller)
« no previous file with comments | « no previous file | sdk/lib/async/async_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698