| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import "package:http_server/http_server.dart"; | 8 import "package:http_server/http_server.dart"; |
| 9 import 'package:path/path.dart' as pathos; | 9 import 'package:path/path.dart' as pathos; |
| 10 import "package:unittest/unittest.dart"; | 10 import "package:unittest/unittest.dart"; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 return getAsString(virDir, '/') | 185 return getAsString(virDir, '/') |
| 186 .then((result) { | 186 .then((result) { |
| 187 expect(result, 'index file'); | 187 expect(result, 'index file'); |
| 188 }); | 188 }); |
| 189 }); | 189 }); |
| 190 | 190 |
| 191 testVirtualDir('index-2', (dir) { | 191 testVirtualDir('index-2', (dir) { |
| 192 new Directory('${dir.path}/dir').createSync(); | 192 new Directory('${dir.path}/dir').createSync(); |
| 193 var virDir = new VirtualDirectory(dir.path); | 193 var virDir = new VirtualDirectory(dir.path); |
| 194 virDir.allowDirectoryListing = true; | 194 virDir.allowDirectoryListing = true; |
| 195 virDir.directoryHandler = (dir2, request) { | 195 |
| 196 virDir.directoryHandler = protectAsync2((dir2, request) { |
| 196 fail('not expected'); | 197 fail('not expected'); |
| 197 }; | 198 }); |
| 199 |
| 198 return getStatusCodeForVirtDir(virDir, '/dir', followRedirects: false) | 200 return getStatusCodeForVirtDir(virDir, '/dir', followRedirects: false) |
| 199 .then((result) { | 201 .then((result) { |
| 200 expect(result, 301); | 202 expect(result, 301); |
| 201 }); | 203 }); |
| 202 }); | 204 }); |
| 203 | 205 |
| 204 testVirtualDir('index-3', (dir) { | 206 testVirtualDir('index-3', (dir) { |
| 205 new File('${dir.path}/dir/index.html') | 207 new File('${dir.path}/dir/index.html') |
| 206 ..createSync(recursive: true) | 208 ..createSync(recursive: true) |
| 207 ..writeAsStringSync('index file'); | 209 ..writeAsStringSync('index file'); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 return virDir.serveFile(new File('${d.path}/file'), request); | 530 return virDir.serveFile(new File('${d.path}/file'), request); |
| 529 }; | 531 }; |
| 530 | 532 |
| 531 return getAsString(virDir, '/') | 533 return getAsString(virDir, '/') |
| 532 .then((result) { | 534 .then((result) { |
| 533 expect(result, 'file contents'); | 535 expect(result, 'file contents'); |
| 534 }); | 536 }); |
| 535 }); | 537 }); |
| 536 }); | 538 }); |
| 537 } | 539 } |
| OLD | NEW |