From 1ef37c61c2ee229fe24814cf033af91b8d62fab1 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 19 Aug 2022 22:09:30 +0200 Subject: [PATCH] Moved http server simple to it's own module. --- modules/http_server_simple/SCsub | 29 ++++++++++++++++ modules/http_server_simple/config.py | 20 +++++++++++ .../http_server_simple/http_parser.cpp | 2 +- .../http_server_simple/http_parser.h | 0 .../http_server_simple/http_parser/AUTHORS | 0 .../http_parser/LICENSE-MIT | 0 .../http_server_simple/http_parser/README.md | 0 .../http_parser/http_parser.c | 0 .../http_parser/http_parser.h | 0 .../http_server_simple/http_server_simple.cpp | 2 +- .../http_server_simple/http_server_simple.h | 2 +- .../http_server_simple/http_writer.cpp | 0 .../http_server_simple/http_writer.h | 0 modules/http_server_simple/register_types.cpp | 33 +++++++++++++++++++ modules/http_server_simple/register_types.h | 28 ++++++++++++++++ .../simple_web_server_request.cpp | 12 +++---- .../simple_web_server_request.h | 4 +-- .../http_server_simple/web_server_simple.cpp | 0 .../http_server_simple/web_server_simple.h | 2 +- modules/web/SCsub | 7 ---- modules/web/config.py | 2 -- modules/web/register_types.cpp | 4 --- 22 files changed, 122 insertions(+), 25 deletions(-) create mode 100644 modules/http_server_simple/SCsub create mode 100644 modules/http_server_simple/config.py rename modules/{web => }/http_server_simple/http_parser.cpp (99%) rename modules/{web => }/http_server_simple/http_parser.h (100%) rename modules/{web => }/http_server_simple/http_parser/AUTHORS (100%) rename modules/{web => }/http_server_simple/http_parser/LICENSE-MIT (100%) rename modules/{web => }/http_server_simple/http_parser/README.md (100%) rename modules/{web => }/http_server_simple/http_parser/http_parser.c (100%) rename modules/{web => }/http_server_simple/http_parser/http_parser.h (100%) rename modules/{web => }/http_server_simple/http_server_simple.cpp (99%) rename modules/{web => }/http_server_simple/http_server_simple.h (98%) rename modules/{web => }/http_server_simple/http_writer.cpp (100%) rename modules/{web => }/http_server_simple/http_writer.h (100%) create mode 100644 modules/http_server_simple/register_types.cpp create mode 100644 modules/http_server_simple/register_types.h rename modules/{web => }/http_server_simple/simple_web_server_request.cpp (92%) rename modules/{web => }/http_server_simple/simple_web_server_request.h (95%) rename modules/{web => }/http_server_simple/web_server_simple.cpp (100%) rename modules/{web => }/http_server_simple/web_server_simple.h (98%) diff --git a/modules/http_server_simple/SCsub b/modules/http_server_simple/SCsub new file mode 100644 index 000000000..0cdd0ac2f --- /dev/null +++ b/modules/http_server_simple/SCsub @@ -0,0 +1,29 @@ +import os + +Import('env') + +module_env = env.Clone() + +sources = [ + "register_types.cpp", + + "http_server_simple.cpp", + "web_server_simple.cpp", + "simple_web_server_request.cpp", + "http_parser.cpp", + "http_writer.cpp", + "http_parser/http_parser.c", +] + +if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': + # Shared lib compilation + module_env.Append(CCFLAGS=['-fPIC']) + module_env['LIBS'] = [] + shared_lib = module_env.SharedLibrary(target='#bin/http_server_simple', source=sources) + shared_lib_shim = shared_lib[0].name.rsplit('.', 1)[0] + env.Append(LIBS=[shared_lib_shim]) + env.Append(LIBPATH=['#bin']) +else: + # Static compilation + module_env.add_source_files(env.modules_sources, sources) + diff --git a/modules/http_server_simple/config.py b/modules/http_server_simple/config.py new file mode 100644 index 000000000..9c716a1d8 --- /dev/null +++ b/modules/http_server_simple/config.py @@ -0,0 +1,20 @@ + + +def can_build(env, platform): + env.module_add_dependencies("http_server_simple", ["web"], False) + + return True + + +def configure(env): + pass + + +def get_doc_classes(): + return [ + "WebServerSimple", + ] + + +def get_doc_path(): + return "doc_classes" diff --git a/modules/web/http_server_simple/http_parser.cpp b/modules/http_server_simple/http_parser.cpp similarity index 99% rename from modules/web/http_server_simple/http_parser.cpp rename to modules/http_server_simple/http_parser.cpp index 534a7961b..1db914e20 100644 --- a/modules/web/http_server_simple/http_parser.cpp +++ b/modules/http_server_simple/http_parser.cpp @@ -1,6 +1,6 @@ #include "http_parser.h" -#include "../http/web_server_request.h" +#include "modules/web/http/web_server_request.h" #include "./http_parser/http_parser.h" #include "simple_web_server_request.h" diff --git a/modules/web/http_server_simple/http_parser.h b/modules/http_server_simple/http_parser.h similarity index 100% rename from modules/web/http_server_simple/http_parser.h rename to modules/http_server_simple/http_parser.h diff --git a/modules/web/http_server_simple/http_parser/AUTHORS b/modules/http_server_simple/http_parser/AUTHORS similarity index 100% rename from modules/web/http_server_simple/http_parser/AUTHORS rename to modules/http_server_simple/http_parser/AUTHORS diff --git a/modules/web/http_server_simple/http_parser/LICENSE-MIT b/modules/http_server_simple/http_parser/LICENSE-MIT similarity index 100% rename from modules/web/http_server_simple/http_parser/LICENSE-MIT rename to modules/http_server_simple/http_parser/LICENSE-MIT diff --git a/modules/web/http_server_simple/http_parser/README.md b/modules/http_server_simple/http_parser/README.md similarity index 100% rename from modules/web/http_server_simple/http_parser/README.md rename to modules/http_server_simple/http_parser/README.md diff --git a/modules/web/http_server_simple/http_parser/http_parser.c b/modules/http_server_simple/http_parser/http_parser.c similarity index 100% rename from modules/web/http_server_simple/http_parser/http_parser.c rename to modules/http_server_simple/http_parser/http_parser.c diff --git a/modules/web/http_server_simple/http_parser/http_parser.h b/modules/http_server_simple/http_parser/http_parser.h similarity index 100% rename from modules/web/http_server_simple/http_parser/http_parser.h rename to modules/http_server_simple/http_parser/http_parser.h diff --git a/modules/web/http_server_simple/http_server_simple.cpp b/modules/http_server_simple/http_server_simple.cpp similarity index 99% rename from modules/web/http_server_simple/http_server_simple.cpp rename to modules/http_server_simple/http_server_simple.cpp index 53628430b..153285e20 100644 --- a/modules/web/http_server_simple/http_server_simple.cpp +++ b/modules/http_server_simple/http_server_simple.cpp @@ -30,7 +30,7 @@ #include "http_server_simple.h" -#include "../http/web_server_cookie.h" +#include "modules/web/http/web_server_cookie.h" #include "http_parser.h" #include "simple_web_server_request.h" #include "web_server_simple.h" diff --git a/modules/web/http_server_simple/http_server_simple.h b/modules/http_server_simple/http_server_simple.h similarity index 98% rename from modules/web/http_server_simple/http_server_simple.h rename to modules/http_server_simple/http_server_simple.h index 748628b20..2cbd53d36 100644 --- a/modules/web/http_server_simple/http_server_simple.h +++ b/modules/http_server_simple/http_server_simple.h @@ -41,7 +41,7 @@ #include "core/config/project_settings.h" -#include "../http/http_server_enums.h" +#include "modules/web/http/http_server_enums.h" class HTTPParser; class WebServerSimple; diff --git a/modules/web/http_server_simple/http_writer.cpp b/modules/http_server_simple/http_writer.cpp similarity index 100% rename from modules/web/http_server_simple/http_writer.cpp rename to modules/http_server_simple/http_writer.cpp diff --git a/modules/web/http_server_simple/http_writer.h b/modules/http_server_simple/http_writer.h similarity index 100% rename from modules/web/http_server_simple/http_writer.h rename to modules/http_server_simple/http_writer.h diff --git a/modules/http_server_simple/register_types.cpp b/modules/http_server_simple/register_types.cpp new file mode 100644 index 000000000..d08e4dd5c --- /dev/null +++ b/modules/http_server_simple/register_types.cpp @@ -0,0 +1,33 @@ +/* +Copyright (c) 2022 Péter Magyar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "register_types.h" + +#include "web_server_simple.h" + + +void register_http_server_simple_types() { + ClassDB::register_class(); +} + +void unregister_http_server_simple_types() { +} diff --git a/modules/http_server_simple/register_types.h b/modules/http_server_simple/register_types.h new file mode 100644 index 000000000..83778da74 --- /dev/null +++ b/modules/http_server_simple/register_types.h @@ -0,0 +1,28 @@ +#ifndef HTTP_SERVER_SIMPLE_REGISTER_TYPES_H +#define HTTP_SERVER_SIMPLE_REGISTER_TYPES_H +/* +Copyright (c) 2022 Péter Magyar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +void register_http_server_simple_types(); +void unregister_http_server_simple_types(); + +#endif diff --git a/modules/web/http_server_simple/simple_web_server_request.cpp b/modules/http_server_simple/simple_web_server_request.cpp similarity index 92% rename from modules/web/http_server_simple/simple_web_server_request.cpp rename to modules/http_server_simple/simple_web_server_request.cpp index ce4cf7179..da1b5d752 100644 --- a/modules/web/http_server_simple/simple_web_server_request.cpp +++ b/modules/http_server_simple/simple_web_server_request.cpp @@ -1,15 +1,15 @@ #include "simple_web_server_request.h" -#include "../http/web_server.h" -#include "../http/web_server_cookie.h" +#include "modules/web/http/web_server.h" +#include "modules/web/http/web_server_cookie.h" #include "core/object/object.h" -#include "../http/http_session.h" +#include "modules/web/http/http_session.h" -#include "../http/http_session_manager.h" -#include "../http/web_node.h" +#include "modules/web/http/http_session_manager.h" +#include "modules/web/http/web_node.h" -#include "../http/web_permission.h" +#include "modules/web/http/web_permission.h" #include "http_server_simple.h" String SimpleWebServerRequest::get_cookie(const String &key) { diff --git a/modules/web/http_server_simple/simple_web_server_request.h b/modules/http_server_simple/simple_web_server_request.h similarity index 95% rename from modules/web/http_server_simple/simple_web_server_request.h rename to modules/http_server_simple/simple_web_server_request.h index 6349b5cce..1ff1cfae9 100644 --- a/modules/web/http_server_simple/simple_web_server_request.h +++ b/modules/http_server_simple/simple_web_server_request.h @@ -6,9 +6,9 @@ #include "core/string/ustring.h" #include "core/containers/vector.h" -#include "../http/web_server_request.h" +#include "modules/web/http/web_server_request.h" -#include "../http/http_server_enums.h" +#include "modules/web/http/http_server_enums.h" class WebServer; class WebServerCookie; diff --git a/modules/web/http_server_simple/web_server_simple.cpp b/modules/http_server_simple/web_server_simple.cpp similarity index 100% rename from modules/web/http_server_simple/web_server_simple.cpp rename to modules/http_server_simple/web_server_simple.cpp diff --git a/modules/web/http_server_simple/web_server_simple.h b/modules/http_server_simple/web_server_simple.h similarity index 98% rename from modules/web/http_server_simple/web_server_simple.h rename to modules/http_server_simple/web_server_simple.h index 1efcf1e94..0f6bb2fca 100644 --- a/modules/web/http_server_simple/web_server_simple.h +++ b/modules/http_server_simple/web_server_simple.h @@ -37,7 +37,7 @@ #include "core/io/zip_io.h" #include "core/os/mutex.h" -#include "../http/web_server.h" +#include "modules/web/http/web_server.h" #include "core/config/project_settings.h" diff --git a/modules/web/SCsub b/modules/web/SCsub index faa46af36..c68c4a54f 100644 --- a/modules/web/SCsub +++ b/modules/web/SCsub @@ -40,13 +40,6 @@ sources = [ "html/libs/hoedown/version.c", "html/markdown_renderer.cpp", - "http_server_simple/http_server_simple.cpp", - "http_server_simple/web_server_simple.cpp", - "http_server_simple/simple_web_server_request.cpp", - "http_server_simple/http_parser.cpp", - "http_server_simple/http_writer.cpp", - "http_server_simple/http_parser/http_parser.c", - "nodes/static_pages/static_web_page.cpp", "nodes/static_pages/static_web_page_file.cpp", "nodes/static_pages/static_web_page_folder_files.cpp", diff --git a/modules/web/config.py b/modules/web/config.py index cbd448707..1fc6cb521 100644 --- a/modules/web/config.py +++ b/modules/web/config.py @@ -60,8 +60,6 @@ def get_doc_classes(): "MarkdownRenderer", - "WebServerSimple", - "StaticWebPage", "StaticWebPageFile", "StaticWebPageFolderFiles", diff --git a/modules/web/register_types.cpp b/modules/web/register_types.cpp index d9557692c..0c7366f78 100644 --- a/modules/web/register_types.cpp +++ b/modules/web/register_types.cpp @@ -45,8 +45,6 @@ SOFTWARE. #include "http/web_server_middleware.h" #include "http/web_server_request.h" -#include "http_server_simple/web_server_simple.h" - #include "nodes/static_pages/static_web_page.h" #include "nodes/static_pages/static_web_page_file.h" #include "nodes/static_pages/static_web_page_folder_files.h" @@ -111,8 +109,6 @@ void register_web_types() { ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class();