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 client_test; | 5 library client_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:uri'; | 8 import 'dart:uri'; |
9 | 9 |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 23 matching lines...) Expand all Loading... |
34 }).whenComplete(client.close), completion(parse(equals({ | 34 }).whenComplete(client.close), completion(parse(equals({ |
35 'method': 'POST', | 35 'method': 'POST', |
36 'path': '/', | 36 'path': '/', |
37 'headers': { | 37 'headers': { |
38 'content-type': ['application/json; charset=utf-8'], | 38 'content-type': ['application/json; charset=utf-8'], |
39 'transfer-encoding': ['chunked'] | 39 'transfer-encoding': ['chunked'] |
40 }, | 40 }, |
41 'body': '{"hello": "world"}' | 41 'body': '{"hello": "world"}' |
42 })))); | 42 })))); |
43 | 43 |
44 request.sink.add('{"hello": "world"}'.charCodes); | 44 request.sink.add('{"hello": "world"}'.codeUnits); |
45 request.sink.close(); | 45 request.sink.close(); |
46 }); | 46 }); |
47 | 47 |
48 test('#send with an invalid URL', () { | 48 test('#send with an invalid URL', () { |
49 var client = new http.Client(); | 49 var client = new http.Client(); |
50 var url = Uri.parse('http://http.invalid'); | 50 var url = Uri.parse('http://http.invalid'); |
51 var request = new http.StreamedRequest("POST", url); | 51 var request = new http.StreamedRequest("POST", url); |
52 request.headers[HttpHeaders.CONTENT_TYPE] = | 52 request.headers[HttpHeaders.CONTENT_TYPE] = |
53 'application/json; charset=utf-8'; | 53 'application/json; charset=utf-8'; |
54 | 54 |
55 expect(client.send(request), throwsSocketIOException); | 55 expect(client.send(request), throwsSocketIOException); |
56 | 56 |
57 request.sink.add('{"hello": "world"}'.charCodes); | 57 request.sink.add('{"hello": "world"}'.codeUnits); |
58 request.sink.close(); | 58 request.sink.close(); |
59 }); | 59 }); |
60 } | 60 } |
OLD | NEW |