| 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' as json; | 9 import 'dart:json' as json; |
| 10 import 'dart:uri'; | 10 import 'dart:uri'; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 var encoding = requiredEncodingForCharset( | 98 var encoding = requiredEncodingForCharset( |
| 99 request.headers.contentType.charset); | 99 request.headers.contentType.charset); |
| 100 requestBody = decodeString(requestBodyBytes, encoding); | 100 requestBody = decodeString(requestBodyBytes, encoding); |
| 101 } else { | 101 } else { |
| 102 requestBody = requestBodyBytes; | 102 requestBody = requestBodyBytes; |
| 103 } | 103 } |
| 104 | 104 |
| 105 var content = { | 105 var content = { |
| 106 'method': request.method, | 106 'method': request.method, |
| 107 'path': request.path, | 107 'path': request.path, |
| 108 'headers': <String>{} | 108 'headers': <String, String>{} |
| 109 }; | 109 }; |
| 110 if (requestBody != null) content['body'] = requestBody; | 110 if (requestBody != null) content['body'] = requestBody; |
| 111 request.headers.forEach((name, values) { | 111 request.headers.forEach((name, values) { |
| 112 // These headers are automatically generated by dart:io, so we don't | 112 // These headers are automatically generated by dart:io, so we don't |
| 113 // want to test them here. | 113 // want to test them here. |
| 114 if (name == 'cookie' || name == 'host') return; | 114 if (name == 'cookie' || name == 'host') return; |
| 115 | 115 |
| 116 content['headers'][name] = values; | 116 content['headers'][name] = values; |
| 117 }); | 117 }); |
| 118 | 118 |
| (...skipping 332 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 |