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 | 9 |
10 Future<HttpServer> setupServer() { | 10 Future<HttpServer> setupServer() { |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 void testAutoRedirectLimit() { | 384 void testAutoRedirectLimit() { |
385 setupServer().then((server) { | 385 setupServer().then((server) { |
386 HttpClient client = new HttpClient(); | 386 HttpClient client = new HttpClient(); |
387 | 387 |
388 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/1")) | 388 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/1")) |
389 .then((HttpClientRequest request) => request.close()) | 389 .then((HttpClientRequest request) => request.close()) |
390 .catchError((error) { | 390 .catchError((error) { |
391 Expect.equals(5, error.redirects.length); | 391 Expect.equals(5, error.redirects.length); |
392 server.close(); | 392 server.close(); |
393 client.close(); | 393 client.close(); |
394 }, test: (e) => e is RedirectLimitExceededException); | 394 }, test: (e) => e is RedirectException); |
395 }); | 395 }); |
396 } | 396 } |
397 | 397 |
398 void testRedirectLoop() { | 398 void testRedirectLoop() { |
399 setupServer().then((server) { | 399 setupServer().then((server) { |
400 HttpClient client = new HttpClient(); | 400 HttpClient client = new HttpClient(); |
401 | 401 |
402 int redirectCount = 0; | 402 int redirectCount = 0; |
403 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/A")) | 403 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/A")) |
404 .then((HttpClientRequest request) => request.close()) | 404 .then((HttpClientRequest request) => request.close()) |
405 .catchError((error) { | 405 .catchError((error) { |
406 Expect.equals(2, error.redirects.length); | 406 Expect.equals(2, error.redirects.length); |
407 server.close(); | 407 server.close(); |
408 client.close(); | 408 client.close(); |
409 }, test: (e) => e is RedirectLoopException); | 409 }, test: (e) => e is RedirectException); |
410 }); | 410 }); |
411 } | 411 } |
412 | 412 |
413 void testRedirectClosingConnection() { | 413 void testRedirectClosingConnection() { |
414 setupServer().then((server) { | 414 setupServer().then((server) { |
415 HttpClient client = new HttpClient(); | 415 HttpClient client = new HttpClient(); |
416 | 416 |
417 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/closing")) | 417 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/closing")) |
418 .then((request) => request.close()) | 418 .then((request) => request.close()) |
419 .then((response) { | 419 .then((response) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 testManualRedirectWithHeaders(); | 461 testManualRedirectWithHeaders(); |
462 testAutoRedirect(); | 462 testAutoRedirect(); |
463 testAutoRedirectWithHeaders(); | 463 testAutoRedirectWithHeaders(); |
464 testAutoRedirect301POST(); | 464 testAutoRedirect301POST(); |
465 testAutoRedirect303POST(); | 465 testAutoRedirect303POST(); |
466 testAutoRedirectLimit(); | 466 testAutoRedirectLimit(); |
467 testRedirectLoop(); | 467 testRedirectLoop(); |
468 testRedirectClosingConnection(); | 468 testRedirectClosingConnection(); |
469 testRedirectRelativeUrl(); | 469 testRedirectRelativeUrl(); |
470 } | 470 } |
OLD | NEW |