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

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

Issue 12300017: Throw an error when we redirect on a non-persistent connection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months 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 0b2f13329eafb41a1886d564de8fe0295d0e3cfc..4df9782b8ec0c3de39b553d2f9cb6935c74976d4 100644
--- a/tests/standalone/io/http_redirect_test.dart
+++ b/tests/standalone/io/http_redirect_test.dart
@@ -128,6 +128,18 @@ HttpServer setupServer() {
}
);
+ // Setup redirect where we close the connection.
+ server.addRequestHandler(
+ (HttpRequest request) => request.path == "/closing",
+ (HttpRequest request, HttpResponse response) {
+ response.headers.set(HttpHeaders.LOCATION,
+ "http://127.0.0.1:${server.port}/");
+ response.statusCode = HttpStatus.FOUND;
+ response.persistentConnection = false;
+ response.outputStream.close();
+ }
+ );
+
return server;
}
@@ -352,6 +364,27 @@ void testRedirectLoop() {
};
}
+void testRedirectClosingConnection() {
+ HttpServer server = setupServer();
+ HttpClient client = new HttpClient();
+
+ int redirectCount = 0;
+ HttpClientConnection conn =
+ client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/closing"));
+
+ conn.followRedirects = true;
+ conn.onResponse = (HttpClientResponse response) {
+ response.inputStream.onData = () => Expect.fail("Response not expected");
+ response.inputStream.onClosed = () => Expect.fail("Response not expected");
+ };
+ conn.onError = (e) {
+ Expect.isTrue(e is RedirectException);
+ Expect.isNull(e.redirects);
+ server.close();
+ client.shutdown();
+ };
+}
+
main() {
testManualRedirect();
testManualRedirectWithHeaders();
@@ -361,4 +394,5 @@ main() {
testAutoRedirect303POST();
testAutoRedirectLimit();
testRedirectLoop();
+ testRedirectClosingConnection();
}
« 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