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 http_test; | 5 library http_test; |
6 | 6 |
7 import 'package:http/http.dart' as http; | 7 import 'package:http/http.dart' as http; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 | 9 |
10 import 'utils.dart'; | 10 import 'utils.dart'; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 'user-agent': ['Dart'], | 291 'user-agent': ['Dart'], |
292 'x-random-header': ['Value'], | 292 'x-random-header': ['Value'], |
293 'x-other-header': ['Other Value'] | 293 'x-other-header': ['Other Value'] |
294 }, | 294 }, |
295 })))); | 295 })))); |
296 }), completes); | 296 }), completes); |
297 }); | 297 }); |
298 | 298 |
299 test('read throws an error for a 4** status code', () { | 299 test('read throws an error for a 4** status code', () { |
300 expect(startServer().then((_) { | 300 expect(startServer().then((_) { |
301 expect(http.read(serverUrl.resolve('/error')), throwsHttpException); | 301 expect(http.read(serverUrl.resolve('/error')), throwsClientException); |
302 }), completes); | 302 }), completes); |
303 }); | 303 }); |
304 | 304 |
305 test('readBytes', () { | 305 test('readBytes', () { |
306 expect(startServer().then((_) { | 306 expect(startServer().then((_) { |
307 var future = http.readBytes(serverUrl, headers: { | 307 var future = http.readBytes(serverUrl, headers: { |
308 'X-Random-Header': 'Value', | 308 'X-Random-Header': 'Value', |
309 'X-Other-Header': 'Other Value', | 309 'X-Other-Header': 'Other Value', |
310 'User-Agent': 'Dart' | 310 'User-Agent': 'Dart' |
311 }).then((bytes) => new String.fromCharCodes(bytes)); | 311 }).then((bytes) => new String.fromCharCodes(bytes)); |
312 | 312 |
313 expect(future, completion(parse(equals({ | 313 expect(future, completion(parse(equals({ |
314 'method': 'GET', | 314 'method': 'GET', |
315 'path': '/', | 315 'path': '/', |
316 'headers': { | 316 'headers': { |
317 'content-length': ['0'], | 317 'content-length': ['0'], |
318 'accept-encoding': ['gzip'], | 318 'accept-encoding': ['gzip'], |
319 'user-agent': ['Dart'], | 319 'user-agent': ['Dart'], |
320 'x-random-header': ['Value'], | 320 'x-random-header': ['Value'], |
321 'x-other-header': ['Other Value'] | 321 'x-other-header': ['Other Value'] |
322 }, | 322 }, |
323 })))); | 323 })))); |
324 }), completes); | 324 }), completes); |
325 }); | 325 }); |
326 | 326 |
327 test('readBytes throws an error for a 4** status code', () { | 327 test('readBytes throws an error for a 4** status code', () { |
328 expect(startServer().then((_) { | 328 expect(startServer().then((_) { |
329 expect(http.readBytes(serverUrl.resolve('/error')), throwsHttpException)
; | 329 expect(http.readBytes(serverUrl.resolve('/error')), |
| 330 throwsClientException); |
330 }), completes); | 331 }), completes); |
331 }); | 332 }); |
332 }); | 333 }); |
333 } | 334 } |
OLD | NEW |