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

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

Issue 14988003: Support redirect to relative Uri, as specified by rfc3986#4.2. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test for only-domain-missing, paths with '..', and simplify tests. Created 7 years, 7 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 363f8d0c684bcc848df83ae810ea566212aafc52..b3caef57370ae7eec622b6d9f83cf2d32693cf40 100644
--- a/tests/standalone/io/http_redirect_test.dart
+++ b/tests/standalone/io/http_redirect_test.dart
@@ -57,6 +57,69 @@ Future<HttpServer> setupServer() {
}
);
+ // Setup redirects with relative url.
+ addRequestHandler(
+ "/redirectUrl",
+ (HttpRequest request, HttpResponse response) {
+ response.headers.set(HttpHeaders.LOCATION, "/some/relativeUrl");
+ response.statusCode = HttpStatus.MOVED_PERMANENTLY;
+ response.close();
+ }
+ );
+
+ addRequestHandler(
+ "/some/redirectUrl",
+ (HttpRequest request, HttpResponse response) {
+ response.headers.set(HttpHeaders.LOCATION, "relativeUrl");
+ response.statusCode = HttpStatus.MOVED_PERMANENTLY;
+ response.close();
+ }
+ );
+
+ addRequestHandler(
+ "/some/relativeUrl",
+ (HttpRequest request, HttpResponse response) {
+ response.close();
+ }
+ );
+
+ addRequestHandler(
+ "/redirectUrl2",
+ (HttpRequest request, HttpResponse response) {
+ response.headers.set(HttpHeaders.LOCATION, "location");
+ response.statusCode = HttpStatus.MOVED_PERMANENTLY;
+ response.close();
+ }
+ );
+
+ addRequestHandler(
+ "/redirectUrl3",
+ (HttpRequest request, HttpResponse response) {
+ response.headers.set(HttpHeaders.LOCATION, "./location");
+ response.statusCode = HttpStatus.MOVED_PERMANENTLY;
+ response.close();
+ }
+ );
+
+ addRequestHandler(
+ "/redirectUrl4",
+ (HttpRequest request, HttpResponse response) {
+ response.headers.set(HttpHeaders.LOCATION, "./a/b/../../location");
+ response.statusCode = HttpStatus.MOVED_PERMANENTLY;
+ response.close();
+ }
+ );
+
+ addRequestHandler(
+ "/redirectUrl5",
+ (HttpRequest request, HttpResponse response) {
+ response.headers.set(HttpHeaders.LOCATION,
+ "//127.0.0.1:${server.port}/location");
+ response.statusCode = HttpStatus.MOVED_PERMANENTLY;
+ response.close();
+ }
+ );
+
// Setup redirect chain.
int n = 1;
addRedirectHandler(n++, HttpStatus.MOVED_PERMANENTLY);
@@ -370,6 +433,34 @@ void testRedirectClosingConnection() {
});
}
+void testRedirectRelativeUrl() {
+ testPath(String path) {
+ setupServer().then((server) {
+ HttpClient client = new HttpClient();
+
+ print(path);
+ client.getUrl(Uri.parse("http://127.0.0.1:${server.port}$path"))
+ .then((request) => request.close())
+ .then((response) {
+ response.listen(
+ (_) {},
+ onDone: () {
+ Expect.equals(HttpStatus.OK, response.statusCode);
+ Expect.equals(1, response.redirects.length);
+ server.close();
+ client.close();
+ });
+ });
+ });
+ }
+ testPath("/redirectUrl");
+ testPath("/some/redirectUrl");
+ testPath("/redirectUrl2");
+ testPath("/redirectUrl3");
+ testPath("/redirectUrl4");
+ testPath("/redirectUrl5");
+}
+
main() {
testManualRedirect();
testManualRedirectWithHeaders();
@@ -380,4 +471,5 @@ main() {
testAutoRedirectLimit();
testRedirectLoop();
testRedirectClosingConnection();
+ testRedirectRelativeUrl();
}
« 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