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

Unified Diff: pkg/http_server/test/virtual_directory_test.dart

Issue 119453005: Make VirtualDirectory redirect if the directory-path does not end with a tailing slash. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
Index: pkg/http_server/test/virtual_directory_test.dart
diff --git a/pkg/http_server/test/virtual_directory_test.dart b/pkg/http_server/test/virtual_directory_test.dart
index 97ec5ca8984f8154905321294289656a011cfc6e..6583e592dc1c60d00692f06346032bfe89fdbde6 100644
--- a/pkg/http_server/test/virtual_directory_test.dart
+++ b/pkg/http_server/test/virtual_directory_test.dart
@@ -231,6 +231,20 @@ void main() {
});
_testVirDir('index-2', (server, dir) {
+ new Directory('${dir.path}/dir').createSync();
+ var virDir = new VirtualDirectory(dir.path);
+ virDir.allowDirectoryListing = true;
+ virDir.directoryHandler = (dir2, request) {
+ fail('not expected');
+ };
+ virDir.serve(server);
+ return getStatusCode(server.port, '/dir', followRedirects: false)
+ .then((result) {
+ expect(result, 301);
+ });
+ });
+
+ _testVirDir('index-3', (server, dir) {
new File('${dir.path}/dir/index.html')
..createSync(recursive: true)
..writeAsStringSync('index file');
@@ -247,6 +261,24 @@ void main() {
expect(result, 'index file');
});
});
+
+ _testVirDir('index-4', (server, dir) {
+ new File('${dir.path}/dir/index.html')
+ ..createSync(recursive: true)
+ ..writeAsStringSync('index file');
+ var virDir = new VirtualDirectory(dir.path);
+ virDir.allowDirectoryListing = true;
+ virDir.directoryHandler = (dir2, request) {
+ // Redirect directory-requests to index.html files.
+ var indexUri = new Uri.file(dir2.path).resolve('index.html');
+ virDir.serveFile(new File(indexUri.toFilePath()), request);
+ };
+ virDir.serve(server);
+ return getAsString(server.port, '/dir/')
+ .then((result) {
+ expect(result, 'index file');
+ });
+ });
});
});
« pkg/http_server/lib/src/virtual_directory.dart ('K') | « pkg/http_server/test/utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698