| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 _server.addRequestHandler((request) => request.path == '/redirect', | 81 _server.addRequestHandler((request) => request.path == '/redirect', |
| 82 (request, response) { | 82 (request, response) { |
| 83 response.statusCode = 302; | 83 response.statusCode = 302; |
| 84 response.headers.set('location', serverUrl.resolve('/').toString()); | 84 response.headers.set('location', serverUrl.resolve('/').toString()); |
| 85 response.contentLength = 0; | 85 response.contentLength = 0; |
| 86 response.outputStream.close(); | 86 response.outputStream.close(); |
| 87 }); | 87 }); |
| 88 | 88 |
| 89 _server.defaultRequestHandler = (request, response) { | 89 _server.defaultRequestHandler = (request, response) { |
| 90 consumeInputStream(request.inputStream).then((requestBodyBytes) { | 90 wrapInputStream(request.inputStream).toBytes().then((requestBodyBytes) { |
| 91 response.statusCode = 200; | 91 response.statusCode = 200; |
| 92 response.headers.contentType = new ContentType("application", "json"); | 92 response.headers.contentType = new ContentType("application", "json"); |
| 93 | 93 |
| 94 var requestBody; | 94 var requestBody; |
| 95 if (requestBodyBytes.isEmpty) { | 95 if (requestBodyBytes.isEmpty) { |
| 96 requestBody = null; | 96 requestBody = null; |
| 97 } else if (request.headers.contentType.charset != null) { | 97 } else if (request.headers.contentType.charset != null) { |
| 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); |
| (...skipping 350 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 |