| OLD | NEW |
| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 }); | 147 }); |
| 148 | 148 |
| 149 // TODO(nweiz): test creating a multipart file with a charset other than UTF-8 | 149 // TODO(nweiz): test creating a multipart file with a charset other than UTF-8 |
| 150 // once issue 6284 is fixed. | 150 // once issue 6284 is fixed. |
| 151 | 151 |
| 152 // TODO(nweiz): test creating a string with a unicode body once issue 6284 is | 152 // TODO(nweiz): test creating a string with a unicode body once issue 6284 is |
| 153 // fixed. | 153 // fixed. |
| 154 | 154 |
| 155 test('with a stream file', () { | 155 test('with a stream file', () { |
| 156 var request = new http.MultipartRequest('POST', dummyUrl); | 156 var request = new http.MultipartRequest('POST', dummyUrl); |
| 157 var controller = new StreamController(); | 157 var controller = new StreamController(sync: true); |
| 158 request.files.add(new http.MultipartFile('file', controller.stream, 5)); | 158 request.files.add(new http.MultipartFile('file', controller.stream, 5)); |
| 159 | 159 |
| 160 expect(request, bodyMatches(''' | 160 expect(request, bodyMatches(''' |
| 161 --{{boundary}} | 161 --{{boundary}} |
| 162 content-type: application/octet-stream | 162 content-type: application/octet-stream |
| 163 content-disposition: form-data; name="file" | 163 content-disposition: form-data; name="file" |
| 164 | 164 |
| 165 hello | 165 hello |
| 166 --{{boundary}}-- | 166 --{{boundary}}-- |
| 167 ''')); | 167 ''')); |
| 168 | 168 |
| 169 controller.add([104, 101, 108, 108, 111]); | 169 controller.add([104, 101, 108, 108, 111]); |
| 170 controller.close(); | 170 controller.close(); |
| 171 }); | 171 }); |
| 172 | 172 |
| 173 test('with an empty stream file', () { | 173 test('with an empty stream file', () { |
| 174 var request = new http.MultipartRequest('POST', dummyUrl); | 174 var request = new http.MultipartRequest('POST', dummyUrl); |
| 175 var controller = new StreamController(); | 175 var controller = new StreamController(sync: true); |
| 176 request.files.add(new http.MultipartFile('file', controller.stream, 0)); | 176 request.files.add(new http.MultipartFile('file', controller.stream, 0)); |
| 177 | 177 |
| 178 expect(request, bodyMatches(''' | 178 expect(request, bodyMatches(''' |
| 179 --{{boundary}} | 179 --{{boundary}} |
| 180 content-type: application/octet-stream | 180 content-type: application/octet-stream |
| 181 content-disposition: form-data; name="file" | 181 content-disposition: form-data; name="file" |
| 182 | 182 |
| 183 | 183 |
| 184 --{{boundary}}-- | 184 --{{boundary}}-- |
| 185 ''')); | 185 ''')); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 content-type: application/octet-stream | 225 content-type: application/octet-stream |
| 226 content-disposition: form-data; name="file"; filename="test-file" | 226 content-disposition: form-data; name="file"; filename="test-file" |
| 227 | 227 |
| 228 hello | 228 hello |
| 229 --{{boundary}}-- | 229 --{{boundary}}-- |
| 230 ''')); | 230 ''')); |
| 231 }), completes); | 231 }), completes); |
| 232 }); | 232 }); |
| 233 }); | 233 }); |
| 234 } | 234 } |
| OLD | NEW |