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

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

Issue 11713003: Use a semicolon as the separator for multipart form-data requests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 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 | « no previous file | no next file » | 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) 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 multipart_request; 5 library multipart_request;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:math'; 8 import 'dart:math';
9 import 'dart:uri'; 9 import 'dart:uri';
10 import 'dart:utf'; 10 import 'dart:utf';
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 MultipartRequest(String method, Uri url) 74 MultipartRequest(String method, Uri url)
75 : super(method, url), 75 : super(method, url),
76 fields = <String>{}, 76 fields = <String>{},
77 files = <MultipartFile>[]; 77 files = <MultipartFile>[];
78 78
79 /// Freezes all mutable fields and returns an [InputStream] that will emit the 79 /// Freezes all mutable fields and returns an [InputStream] that will emit the
80 /// request body. 80 /// request body.
81 InputStream finalize() { 81 InputStream finalize() {
82 // TODO(nweiz): freeze fields and files 82 // TODO(nweiz): freeze fields and files
83 var boundary = _boundaryString(_BOUNDARY_LENGTH); 83 var boundary = _boundaryString(_BOUNDARY_LENGTH);
84 headers['content-type'] = 'multipart/form-data, boundary="$boundary"'; 84 headers['content-type'] = 'multipart/form-data; boundary="$boundary"';
85 headers['content-transfer-encoding'] = 'binary'; 85 headers['content-transfer-encoding'] = 'binary';
86 super.finalize(); 86 super.finalize();
87 87
88 var stream = new ListInputStream(); 88 var stream = new ListInputStream();
89 89
90 void writeAscii(String string) { 90 void writeAscii(String string) {
91 assert(isPlainAscii(string)); 91 assert(isPlainAscii(string));
92 stream.write(string.charCodes); 92 stream.write(string.charCodes);
93 } 93 }
94 94
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 String _boundaryString(int length) { 157 String _boundaryString(int length) {
158 var prefix = "dart-http-boundary-"; 158 var prefix = "dart-http-boundary-";
159 var list = new List<int>(length - prefix.length); 159 var list = new List<int>(length - prefix.length);
160 for (var i = 0; i < list.length; i++) { 160 for (var i = 0; i < list.length; i++) {
161 list[i] = _BOUNDARY_CHARACTERS[ 161 list[i] = _BOUNDARY_CHARACTERS[
162 _random.nextInt(_BOUNDARY_CHARACTERS.length)]; 162 _random.nextInt(_BOUNDARY_CHARACTERS.length)];
163 } 163 }
164 return "$prefix${new String.fromCharCodes(list)}"; 164 return "$prefix${new String.fromCharCodes(list)}";
165 } 165 }
166 } 166 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698