Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Unified Diff: tests/standalone/io/http_redirect_test.dart

Issue 11366169: Fix multiple onRequest callbacks during redirect. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_redirect_test.dart
diff --git a/tests/standalone/io/http_redirect_test.dart b/tests/standalone/io/http_redirect_test.dart
index c35cb1c59a2721068160b6d0ff9b846479079c39..38fd18d4a9d5e08961e4507622292ec87114f781 100644
--- a/tests/standalone/io/http_redirect_test.dart
+++ b/tests/standalone/io/http_redirect_test.dart
@@ -21,6 +21,23 @@ HttpServer setupServer() {
});
}
+ // Setup simple redirect.
+ server.addRequestHandler(
+ (HttpRequest request) => request.path == "/redirect",
+ (HttpRequest request, HttpResponse response) {
+ response.headers.set(HttpHeaders.LOCATION,
+ "http://127.0.0.1:${server.port}/location");
+ response.statusCode = HttpStatus.MOVED_PERMANENTLY;
+ response.outputStream.close();
+ }
+ );
+ server.addRequestHandler(
+ (HttpRequest request) => request.path == "/location",
+ (HttpRequest request, HttpResponse response) {
+ response.outputStream.close();
+ }
+ );
+
// Setup redirect chain.
int n = 1;
addRedirectHandler(n++, HttpStatus.MOVED_PERMANENTLY);
@@ -94,6 +111,35 @@ void testAutoRedirect() {
HttpServer server = setupServer();
HttpClient client = new HttpClient();
+ var requestCount = 0;
+
+ void onRequest(HttpClientRequest request) {
+ requestCount++;
+ request.outputStream.close();
+ }
+
+ void onResponse(HttpClientResponse response) {
+ response.inputStream.onData =
+ () => Expect.fail("Response data not expected");
+ response.inputStream.onClosed = () {
+ Expect.equals(1, requestCount);
+ server.close();
+ client.shutdown();
+ };
+ };
+
+ HttpClientConnection conn =
+ client.getUrl(
+ new Uri.fromString("http://127.0.0.1:${server.port}/redirect"));
+ conn.onRequest = onRequest;
+ conn.onResponse = onResponse;
+ conn.onError = (e) => Expect.fail("Error not expected ($e)");
+}
+
+void testAutoRedirectLimit() {
+ HttpServer server = setupServer();
+ HttpClient client = new HttpClient();
+
HttpClientConnection conn =
client.getUrl(new Uri.fromString("http://127.0.0.1:${server.port}/1"));
conn.onResponse = (HttpClientResponse response) {
@@ -130,5 +176,7 @@ void testRedirectLoop() {
main() {
testManualRedirect();
testAutoRedirect();
+ testAutoRedirectRequestBody();
+ testAutoRedirectLimit();
testRedirectLoop();
}
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698