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

Side by Side Diff: pkg/http/test/multipart_test.dart

Issue 23450003: Add encoding tests to pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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/http/lib/src/utils.dart ('k') | pkg/http/test/request_test.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_test; 5 library multipart_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:utf'; 9 import 'dart:utf';
10 10
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 expect(request, bodyMatches(''' 138 expect(request, bodyMatches('''
139 --{{boundary}} 139 --{{boundary}}
140 content-type: application/json; charset=utf-8 140 content-type: application/json; charset=utf-8
141 content-disposition: form-data; name="file" 141 content-disposition: form-data; name="file"
142 142
143 {"hello": "world"} 143 {"hello": "world"}
144 --{{boundary}}-- 144 --{{boundary}}--
145 ''')); 145 '''));
146 }); 146 });
147 147
148 // TODO(nweiz): test creating a multipart file with a charset other than UTF-8 148 test('with a file with a iso-8859-1 body', () {
149 // once issue 6284 is fixed. 149 var request = new http.MultipartRequest('POST', dummyUrl);
150 // "Ã¥" encoded as ISO-8859-1 and then read as UTF-8 results in "å".
151 var file = new http.MultipartFile.fromString('file', 'non-ascii: "Ã¥"',
152 contentType: new ContentType('text', 'plain', charset: 'iso-8859-1'));
153 request.files.add(file);
150 154
151 // TODO(nweiz): test creating a string with a unicode body once issue 6284 is 155 expect(request, bodyMatches('''
152 // fixed. 156 --{{boundary}}
157 content-type: text/plain; charset=iso-8859-1
158 content-disposition: form-data; name="file"
159
160 non-ascii: "å"
161 --{{boundary}}--
162 '''));
163 });
153 164
154 test('with a stream file', () { 165 test('with a stream file', () {
155 var request = new http.MultipartRequest('POST', dummyUrl); 166 var request = new http.MultipartRequest('POST', dummyUrl);
156 var controller = new StreamController(sync: true); 167 var controller = new StreamController(sync: true);
157 request.files.add(new http.MultipartFile('file', controller.stream, 5)); 168 request.files.add(new http.MultipartFile('file', controller.stream, 5));
158 169
159 expect(request, bodyMatches(''' 170 expect(request, bodyMatches('''
160 --{{boundary}} 171 --{{boundary}}
161 content-type: application/octet-stream 172 content-type: application/octet-stream
162 content-disposition: form-data; name="file" 173 content-disposition: form-data; name="file"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 content-type: application/octet-stream 235 content-type: application/octet-stream
225 content-disposition: form-data; name="file"; filename="test-file" 236 content-disposition: form-data; name="file"; filename="test-file"
226 237
227 hello 238 hello
228 --{{boundary}}-- 239 --{{boundary}}--
229 ''')); 240 '''));
230 }), completes); 241 }), completes);
231 }); 242 });
232 }); 243 });
233 } 244 }
OLDNEW
« no previous file with comments | « pkg/http/lib/src/utils.dart ('k') | pkg/http/test/request_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698