diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2023-05-20 00:34:51 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-21 07:52:41 +0200 |
commit | e795641d9945ab5b59ccd43b1f758dadb8067976 (patch) | |
tree | ed55c0de6160fbed61aaf212347aba121c280222 | |
parent | fecaf27b3ae17163c61304710cd3140fbe71fbe7 (diff) | |
download | serenity-e795641d9945ab5b59ccd43b1f758dadb8067976.zip |
WebServer: Prefer LibFileSystem over DeprecatedFile
-rw-r--r-- | Userland/Services/WebServer/Client.cpp | 6 | ||||
-rw-r--r-- | Userland/Services/WebServer/main.cpp | 5 |
2 files changed, 4 insertions, 7 deletions
diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp index 7139ee1996..345c9ad345 100644 --- a/Userland/Services/WebServer/Client.cpp +++ b/Userland/Services/WebServer/Client.cpp @@ -14,7 +14,6 @@ #include <AK/StringBuilder.h> #include <AK/URL.h> #include <LibCore/DateTime.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/DirIterator.h> #include <LibCore/File.h> #include <LibCore/MappedFile.h> @@ -144,13 +143,12 @@ ErrorOr<bool> Client::handle_request(HTTP::HttpRequest const& request) real_path = index_html_path; } - auto file = Core::DeprecatedFile::construct(real_path.bytes_as_string_view()); - if (!file->open(Core::OpenMode::ReadOnly)) { + if (!FileSystem::exists(real_path.bytes_as_string_view())) { TRY(send_error_response(404, request)); return false; } - if (file->is_device()) { + if (FileSystem::is_device(real_path.bytes_as_string_view())) { TRY(send_error_response(403, request)); return false; } diff --git a/Userland/Services/WebServer/main.cpp b/Userland/Services/WebServer/main.cpp index 7f4dbadb62..bfff02d13b 100644 --- a/Userland/Services/WebServer/main.cpp +++ b/Userland/Services/WebServer/main.cpp @@ -8,7 +8,6 @@ #include <AK/String.h> #include <LibCore/ArgsParser.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/EventLoop.h> #include <LibCore/MappedFile.h> #include <LibCore/System.h> @@ -57,7 +56,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return 1; } - auto real_document_root_path = Core::DeprecatedFile::real_path_for(document_root_path); + auto real_document_root_path = TRY(FileSystem::real_path(document_root_path)); if (!FileSystem::exists(real_document_root_path)) { warnln("Root path does not exist: '{}'", document_root_path); return 1; @@ -69,7 +68,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (!username.is_empty() && !password.is_empty()) credentials = HTTP::HttpRequest::BasicAuthenticationCredentials { username, password }; - WebServer::Configuration configuration(real_document_root_path, credentials); + WebServer::Configuration configuration(real_document_root_path.to_deprecated_string(), credentials); Core::EventLoop loop; |