| 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"; | 9 import "package:path/path.dart"; |
| 10 import "package:unittest/unittest.dart"; | 10 import "package:unittest/unittest.dart"; |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 }), completion(equals(expected))); | 662 }), completion(equals(expected))); |
| 663 }); | 663 }); |
| 664 } | 664 } |
| 665 testEncoding('..', HttpStatus.NOT_FOUND, false); | 665 testEncoding('..', HttpStatus.NOT_FOUND, false); |
| 666 testEncoding('%2e%2e', HttpStatus.OK); | 666 testEncoding('%2e%2e', HttpStatus.OK); |
| 667 testEncoding('%252e%252e', HttpStatus.OK); | 667 testEncoding('%252e%252e', HttpStatus.OK); |
| 668 testEncoding('/', HttpStatus.OK, false); | 668 testEncoding('/', HttpStatus.OK, false); |
| 669 testEncoding('%2f', HttpStatus.NOT_FOUND, false); | 669 testEncoding('%2f', HttpStatus.NOT_FOUND, false); |
| 670 testEncoding('%2f', HttpStatus.OK, true); | 670 testEncoding('%2f', HttpStatus.OK, true); |
| 671 }); | 671 }); |
| 672 |
| 673 group('serve-file', () { |
| 674 test('from-dir-handler', () { |
| 675 expect(HttpServer.bind('localhost', 0).then((server) { |
| 676 var dir = Directory.systemTemp.createTempSync('http_server_virtual_'); |
| 677 new File('${dir.path}/file')..writeAsStringSync('file contents'); |
| 678 var virDir = new VirtualDirectory(dir.path); |
| 679 virDir.allowDirectoryListing = true; |
| 680 virDir.directoryHandler = (d, request) { |
| 681 expect(FileSystemEntity.identicalSync(dir.path, d.path), isTrue); |
| 682 virDir.serveFile(new File('${d.path}/file'), request); |
| 683 }; |
| 684 |
| 685 virDir.serve(server); |
| 686 |
| 687 return getAsString(server.port, '/') |
| 688 .whenComplete(() { |
| 689 server.close(); |
| 690 dir.deleteSync(recursive: true); |
| 691 }); |
| 692 }), completion(equals('file contents'))); |
| 693 }); |
| 694 }); |
| 672 } | 695 } |
| 673 | 696 |
| OLD | NEW |