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

Side by Side Diff: pkg/http/lib/src/multipart_request.dart

Issue 16125005: Make new StreamController be async by default. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/expect/lib/expect.dart ('k') | pkg/http/lib/src/streamed_request.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 multipart_request; 5 library multipart_request;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:math'; 9 import 'dart:math';
10 import 'dart:utf'; 10 import 'dart:utf';
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 /// Freezes all mutable fields and returns a single-subscription [ByteStream] 83 /// Freezes all mutable fields and returns a single-subscription [ByteStream]
84 /// that will emit the request body. 84 /// that will emit the request body.
85 ByteStream finalize() { 85 ByteStream finalize() {
86 // TODO(nweiz): freeze fields and files 86 // TODO(nweiz): freeze fields and files
87 var boundary = _boundaryString(_BOUNDARY_LENGTH); 87 var boundary = _boundaryString(_BOUNDARY_LENGTH);
88 headers['content-type'] = 'multipart/form-data; boundary="$boundary"'; 88 headers['content-type'] = 'multipart/form-data; boundary="$boundary"';
89 headers['content-transfer-encoding'] = 'binary'; 89 headers['content-transfer-encoding'] = 'binary';
90 super.finalize(); 90 super.finalize();
91 91
92 var controller = new StreamController<List<int>>(); 92 var controller = new StreamController<List<int>>(sync: true);
93 93
94 void writeAscii(String string) { 94 void writeAscii(String string) {
95 assert(isPlainAscii(string)); 95 assert(isPlainAscii(string));
96 controller.add(string.codeUnits); 96 controller.add(string.codeUnits);
97 } 97 }
98 98
99 writeUtf8(String string) => controller.add(encodeUtf8(string)); 99 writeUtf8(String string) => controller.add(encodeUtf8(string));
100 writeLine() => controller.add([13, 10]); // \r\n 100 writeLine() => controller.add([13, 10]); // \r\n
101 101
102 fields.forEach((name, value) { 102 fields.forEach((name, value) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 String _boundaryString(int length) { 162 String _boundaryString(int length) {
163 var prefix = "dart-http-boundary-"; 163 var prefix = "dart-http-boundary-";
164 var list = new List<int>(length - prefix.length); 164 var list = new List<int>(length - prefix.length);
165 for (var i = 0; i < list.length; i++) { 165 for (var i = 0; i < list.length; i++) {
166 list[i] = _BOUNDARY_CHARACTERS[ 166 list[i] = _BOUNDARY_CHARACTERS[
167 _random.nextInt(_BOUNDARY_CHARACTERS.length)]; 167 _random.nextInt(_BOUNDARY_CHARACTERS.length)];
168 } 168 }
169 return "$prefix${new String.fromCharCodes(list)}"; 169 return "$prefix${new String.fromCharCodes(list)}";
170 } 170 }
171 } 171 }
OLDNEW
« no previous file with comments | « pkg/expect/lib/expect.dart ('k') | pkg/http/lib/src/streamed_request.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698