Chromium Code Reviews| 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 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 Function _errorCallback; | 68 Function _errorCallback; |
| 69 Function _dirCallback; | 69 Function _dirCallback; |
| 70 | 70 |
| 71 _VirtualDirectory(this.root); | 71 _VirtualDirectory(this.root); |
| 72 | 72 |
| 73 void serve(Stream<HttpRequest> requests) { | 73 void serve(Stream<HttpRequest> requests) { |
| 74 requests.listen(serveRequest); | 74 requests.listen(serveRequest); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void serveRequest(HttpRequest request) { | 77 void serveRequest(HttpRequest request) { |
| 78 var path = new Path(request.uri.path).canonicalize(); | 78 var path = new Path(Uri.decodeComponent(request.uri.path)).canonicalize(); |
|
Lasse Reichstein Nielsen
2013/07/01 11:51:51
I think this is wrong.
From the URI RFC: "A path c
Anders Johnsen
2013/07/01 14:14:12
Done.
| |
| 79 | 79 |
| 80 if (!path.isAbsolute) { | 80 if (!path.isAbsolute) { |
| 81 return _serveErrorPage(HttpStatus.NOT_FOUND, request); | 81 return _serveErrorPage(HttpStatus.NOT_FOUND, request); |
| 82 } | 82 } |
| 83 | 83 |
| 84 _locateResource(new Path('.'), path.segments()) | 84 _locateResource(new Path('.'), path.segments()) |
| 85 .then((entity) { | 85 .then((entity) { |
| 86 if (entity == null) { | 86 if (entity == null) { |
| 87 _serveErrorPage(HttpStatus.NOT_FOUND, request); | 87 _serveErrorPage(HttpStatus.NOT_FOUND, request); |
| 88 return; | 88 return; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 | 372 |
| 373 Future close() => new Future.value(); | 373 Future close() => new Future.value(); |
| 374 | 374 |
| 375 void setMimeType(var bytes) { | 375 void setMimeType(var bytes) { |
| 376 var mimeType = lookupMimeType(path, headerBytes: bytes); | 376 var mimeType = lookupMimeType(path, headerBytes: bytes); |
| 377 if (mimeType != null) { | 377 if (mimeType != null) { |
| 378 response.headers.contentType = ContentType.parse(mimeType); | 378 response.headers.contentType = ContentType.parse(mimeType); |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 } | 381 } |
| OLD | NEW |