OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 curl_client_test; | 5 library curl_client_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
9 import 'dart:json'; | 9 import 'dart:json' as json; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
11 | 11 |
12 import '../../../pkg/unittest/lib/unittest.dart'; | 12 import '../../../pkg/unittest/lib/unittest.dart'; |
13 import '../../../pkg/http/lib/http.dart' as http; | 13 import '../../../pkg/http/lib/http.dart' as http; |
14 import '../../pub/curl_client.dart'; | 14 import '../../pub/curl_client.dart'; |
15 import '../../pub/io.dart'; | 15 import '../../pub/io.dart'; |
16 | 16 |
17 // TODO(rnystrom): All of the code from here to the "---..." line was copied | 17 // TODO(rnystrom): All of the code from here to the "---..." line was copied |
18 // from pkg/http/test/utils.dart and pkg/http/lib/src/utils.dart. It's copied | 18 // from pkg/http/test/utils.dart and pkg/http/lib/src/utils.dart. It's copied |
19 // here because http/test/utils.dart is now using "package:" imports and this | 19 // here because http/test/utils.dart is now using "package:" imports and this |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 }); | 116 }); |
117 | 117 |
118 var outputEncoding; | 118 var outputEncoding; |
119 var encodingName = request.queryParameters['response-encoding']; | 119 var encodingName = request.queryParameters['response-encoding']; |
120 if (encodingName != null) { | 120 if (encodingName != null) { |
121 outputEncoding = requiredEncodingForCharset(encodingName); | 121 outputEncoding = requiredEncodingForCharset(encodingName); |
122 } else { | 122 } else { |
123 outputEncoding = Encoding.ASCII; | 123 outputEncoding = Encoding.ASCII; |
124 } | 124 } |
125 | 125 |
126 var body = JSON.stringify(content); | 126 var body = json.stringify(content); |
127 response.contentLength = body.length; | 127 response.contentLength = body.length; |
128 response.outputStream.writeString(body, outputEncoding); | 128 response.outputStream.writeString(body, outputEncoding); |
129 response.outputStream.close(); | 129 response.outputStream.close(); |
130 }); | 130 }); |
131 }; | 131 }; |
132 | 132 |
133 _server.listen("127.0.0.1", 0); | 133 _server.listen("127.0.0.1", 0); |
134 } | 134 } |
135 | 135 |
136 /// Stops the current HTTP server. | 136 /// Stops the current HTTP server. |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 test('without following redirects', () { | 451 test('without following redirects', () { |
452 var request = new http.Request('GET', serverUrl.resolve('/redirect')); | 452 var request = new http.Request('GET', serverUrl.resolve('/redirect')); |
453 request.followRedirects = false; | 453 request.followRedirects = false; |
454 expect(new CurlClient().send(request).then(http.Response.fromStream) | 454 expect(new CurlClient().send(request).then(http.Response.fromStream) |
455 .then((response) { | 455 .then((response) { |
456 expect(response.statusCode, equals(302)); | 456 expect(response.statusCode, equals(302)); |
457 expect(response.isRedirect, true); | 457 expect(response.isRedirect, true); |
458 }), completes); | 458 }), completes); |
459 }); | 459 }); |
460 } | 460 } |
OLD | NEW |