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

Side by Side Diff: pkg/http_server/test/virtual_directory_test.dart

Issue 47513008: Expose 'serveFile' on VirtualDirectory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Expand documentation Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/http_server/lib/src/virtual_directory.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « pkg/http_server/lib/src/virtual_directory.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698