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

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

Issue 2152793003: Remove an extra \r\n and fix a test. (Closed) Base URL: git@github.com:dart-lang/http@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:math'; 7 import 'dart:math';
8 8
9 import 'base_request.dart'; 9 import 'base_request.dart';
10 import 'byte_stream.dart'; 10 import 'byte_stream.dart';
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 ]; 128 ];
129 129
130 /// Returns the header string for a field. The return value is guaranteed to 130 /// Returns the header string for a field. The return value is guaranteed to
131 /// contain only ASCII characters. 131 /// contain only ASCII characters.
132 String _headerForField(String name, String value) { 132 String _headerForField(String name, String value) {
133 var header = 133 var header =
134 'content-disposition: form-data; name="${_browserEncode(name)}"'; 134 'content-disposition: form-data; name="${_browserEncode(name)}"';
135 if (!isPlainAscii(value)) { 135 if (!isPlainAscii(value)) {
136 header = '$header\r\n' 136 header = '$header\r\n'
137 'content-type: text/plain; charset=utf-8\r\n' 137 'content-type: text/plain; charset=utf-8\r\n'
138 'content-transfer-encoding: binary\r\n'; 138 'content-transfer-encoding: binary';
139 } 139 }
140 return '$header\r\n\r\n'; 140 return '$header\r\n\r\n';
141 } 141 }
142 142
143 /// Returns the header string for a file. The return value is guaranteed to 143 /// Returns the header string for a file. The return value is guaranteed to
144 /// contain only ASCII characters. 144 /// contain only ASCII characters.
145 String _headerForFile(MultipartFile file) { 145 String _headerForFile(MultipartFile file) {
146 var header = 'content-type: ${file.contentType}\r\n' 146 var header = 'content-type: ${file.contentType}\r\n'
147 'content-disposition: form-data; name="${_browserEncode(file.field)}"'; 147 'content-disposition: form-data; name="${_browserEncode(file.field)}"';
148 148
(...skipping 16 matching lines...) Expand all
165 /// Returns a randomly-generated multipart boundary string 165 /// Returns a randomly-generated multipart boundary string
166 String _boundaryString() { 166 String _boundaryString() {
167 var prefix = "dart-http-boundary-"; 167 var prefix = "dart-http-boundary-";
168 var list = new List<int>.generate(_BOUNDARY_LENGTH - prefix.length, 168 var list = new List<int>.generate(_BOUNDARY_LENGTH - prefix.length,
169 (index) => 169 (index) =>
170 _BOUNDARY_CHARACTERS[_random.nextInt(_BOUNDARY_CHARACTERS.length)], 170 _BOUNDARY_CHARACTERS[_random.nextInt(_BOUNDARY_CHARACTERS.length)],
171 growable: false); 171 growable: false);
172 return "$prefix${new String.fromCharCodes(list)}"; 172 return "$prefix${new String.fromCharCodes(list)}";
173 } 173 }
174 } 174 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698