diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-06-26 10:02:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-26 08:02:50 +0000 |
commit | 7ea894774f3a00a1e31aa22d8862dfb54661e18a (patch) | |
tree | 858269f22bc370d3fc52008576c1dda093b2ee94 /components/net/fetch | |
parent | b3d99a607fda9511900f2d5e2c81f905802fe758 (diff) | |
download | servo-7ea894774f3a00a1e31aa22d8862dfb54661e18a.tar.gz servo-7ea894774f3a00a1e31aa22d8862dfb54661e18a.zip |
Add a directory listing feature for `file` URLs (#32580)
Signed-off-by: Bobulous <Bobulous@users.noreply.github.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Bobulous <Bobulous@users.noreply.github.com>
Diffstat (limited to 'components/net/fetch')
-rw-r--r-- | components/net/fetch/methods.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index d69360f9be4..1f8b70f4e61 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -50,6 +50,7 @@ use crate::http_loader::{ determine_requests_referrer, http_fetch, set_default_accept, set_default_accept_language, HttpState, }; +use crate::local_directory_listing; use crate::subresource_integrity::is_response_integrity_valid; lazy_static! { @@ -729,15 +730,11 @@ async fn scheme_fetch( )); } if let Ok(file_path) = url.to_file_path() { - if let Ok(file) = File::open(file_path.clone()) { - if let Ok(metadata) = file.metadata() { - if metadata.is_dir() { - return Response::network_error(NetworkError::Internal( - "Opening a directory is not supported".into(), - )); - } - } + if file_path.is_dir() { + return local_directory_listing::fetch(request, url, file_path); + } + if let Ok(file) = File::open(file_path.clone()) { // Get range bounds (if any) and try to seek to the requested offset. // If seeking fails, bail out with a NetworkError. let file_size = match file.metadata() { |