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

Side by Side Diff: pkg/http_server/lib/src/virtual_directory.dart

Issue 17550004: Use toNativePath() in http_server pkg, to get the native path string on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 part of http_server; 5 part of http_server;
6 6
7 /** 7 /**
8 * A [VirtualDirectory] can serve files and directory-listing from a root path, 8 * A [VirtualDirectory] can serve files and directory-listing from a root path,
9 * to [HttpRequest]s. 9 * to [HttpRequest]s.
10 * 10 *
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (entity is File) { 80 if (entity is File) {
81 entity.openRead().pipe(request.response).catchError((_) {}); 81 entity.openRead().pipe(request.response).catchError((_) {});
82 } else { 82 } else {
83 _serveErrorPage(HttpStatus.NOT_FOUND, request); 83 _serveErrorPage(HttpStatus.NOT_FOUND, request);
84 } 84 }
85 }); 85 });
86 } 86 }
87 87
88 Future<FileSystemEntity> _locateResource(Path path, 88 Future<FileSystemEntity> _locateResource(Path path,
89 Iterable<String> segments) { 89 Iterable<String> segments) {
90 return FileSystemEntity.type(path.toString(), followLinks: false) 90 return FileSystemEntity.type(path.toNativePath(), followLinks: false)
91 .then((type) { 91 .then((type) {
92 switch (type) { 92 switch (type) {
93 case FileSystemEntityType.FILE: 93 case FileSystemEntityType.FILE:
94 if (segments.isEmpty) return new File.fromPath(path); 94 if (segments.isEmpty) return new File.fromPath(path);
95 break; 95 break;
96 96
97 case FileSystemEntityType.DIRECTORY: 97 case FileSystemEntityType.DIRECTORY:
98 if (segments.isEmpty) { 98 if (segments.isEmpty) {
99 if (_allowDirectoryListing) return new Directory.fromPath(path); 99 if (_allowDirectoryListing) return new Directory.fromPath(path);
100 } else { 100 } else {
101 return _locateResource(path.append(segments.first), 101 return _locateResource(path.append(segments.first),
102 segments.skip(1)); 102 segments.skip(1));
103 } 103 }
104 break; 104 break;
105 105
106 case FileSystemEntityType.LINK: 106 case FileSystemEntityType.LINK:
107 if (followLinks) { 107 if (followLinks) {
108 // TODO 108 // TODO
109 } 109 }
110 break; 110 break;
111
112 } 111 }
113 // Return `null` on fall-through, to indicate NOT_FOUND. 112 // Return `null` on fall-through, to indicate NOT_FOUND.
114 return null; 113 return null;
115 }); 114 });
116 } 115 }
117 116
118 void _serveErrorPage(int error, HttpRequest request) { 117 void _serveErrorPage(int error, HttpRequest request) {
119 request.response.statusCode = error; 118 request.response.statusCode = error;
120 request.response.close(); 119 request.response.close();
121 } 120 }
122 } 121 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698