| 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 | 5 |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 import "dart:async"; | 7 import "dart:async"; |
| 8 import "dart:io"; | 8 import "dart:io"; |
| 9 import "dart:uri"; | 9 import "dart:uri"; |
| 10 | 10 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 }); | 322 }); |
| 323 }); | 323 }); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void testAutoRedirectLimit() { | 326 void testAutoRedirectLimit() { |
| 327 setupServer().then((server) { | 327 setupServer().then((server) { |
| 328 HttpClient client = new HttpClient(); | 328 HttpClient client = new HttpClient(); |
| 329 | 329 |
| 330 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/1")) | 330 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/1")) |
| 331 .then((HttpClientRequest request) => request.close()) | 331 .then((HttpClientRequest request) => request.close()) |
| 332 .catchError((e) { | 332 .catchError((error) { |
| 333 Expect.equals(5, e.error.redirects.length); | 333 Expect.equals(5, error.redirects.length); |
| 334 server.close(); | 334 server.close(); |
| 335 client.close(); | 335 client.close(); |
| 336 }, test: (e) => e is RedirectLimitExceededException); | 336 }, test: (e) => e is RedirectLimitExceededException); |
| 337 }); | 337 }); |
| 338 } | 338 } |
| 339 | 339 |
| 340 void testRedirectLoop() { | 340 void testRedirectLoop() { |
| 341 setupServer().then((server) { | 341 setupServer().then((server) { |
| 342 HttpClient client = new HttpClient(); | 342 HttpClient client = new HttpClient(); |
| 343 | 343 |
| 344 int redirectCount = 0; | 344 int redirectCount = 0; |
| 345 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/A")) | 345 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/A")) |
| 346 .then((HttpClientRequest request) => request.close()) | 346 .then((HttpClientRequest request) => request.close()) |
| 347 .catchError((e) { | 347 .catchError((error) { |
| 348 Expect.equals(2, e.error.redirects.length); | 348 Expect.equals(2, error.redirects.length); |
| 349 server.close(); | 349 server.close(); |
| 350 client.close(); | 350 client.close(); |
| 351 }, test: (e) => e is RedirectLoopException); | 351 }, test: (e) => e is RedirectLoopException); |
| 352 }); | 352 }); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void testRedirectClosingConnection() { | 355 void testRedirectClosingConnection() { |
| 356 setupServer().then((server) { | 356 setupServer().then((server) { |
| 357 HttpClient client = new HttpClient(); | 357 HttpClient client = new HttpClient(); |
| 358 | 358 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 374 testManualRedirect(); | 374 testManualRedirect(); |
| 375 testManualRedirectWithHeaders(); | 375 testManualRedirectWithHeaders(); |
| 376 testAutoRedirect(); | 376 testAutoRedirect(); |
| 377 testAutoRedirectWithHeaders(); | 377 testAutoRedirectWithHeaders(); |
| 378 testAutoRedirect301POST(); | 378 testAutoRedirect301POST(); |
| 379 testAutoRedirect303POST(); | 379 testAutoRedirect303POST(); |
| 380 testAutoRedirectLimit(); | 380 testAutoRedirectLimit(); |
| 381 testRedirectLoop(); | 381 testRedirectLoop(); |
| 382 testRedirectClosingConnection(); | 382 testRedirectClosingConnection(); |
| 383 } | 383 } |
| OLD | NEW |