diff --git a/modules/web/SCsub b/modules/web/SCsub index 667775b6e..d32ed5761 100644 --- a/modules/web/SCsub +++ b/modules/web/SCsub @@ -26,6 +26,7 @@ sources = [ "http_server_simple/http_server_simple.cpp", "http_server_simple/web_server_simple.cpp", + "http_server_simple/simple_web_server_request.cpp", ] if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': diff --git a/modules/web/http_server_simple/http_server_simple.cpp b/modules/web/http_server_simple/http_server_simple.cpp index f3bf3717f..7d0905848 100644 --- a/modules/web/http_server_simple/http_server_simple.cpp +++ b/modules/web/http_server_simple/http_server_simple.cpp @@ -102,6 +102,7 @@ void HTTPServerSimple::_send_response() { s += "Cache-Control: no-store, max-age=0\r\n"; s += "\r\n"; CharString cs = s.utf8(); + Error err = peer->put_data((const uint8_t *)cs.get_data(), cs.size() - 1); if (err != OK) { memdelete(f); @@ -120,6 +121,7 @@ void HTTPServerSimple::_send_response() { ERR_FAIL(); } } + memdelete(f); } diff --git a/modules/web/http_server_simple/simple_web_server_request.cpp b/modules/web/http_server_simple/simple_web_server_request.cpp new file mode 100644 index 000000000..9e0270a6f --- /dev/null +++ b/modules/web/http_server_simple/simple_web_server_request.cpp @@ -0,0 +1,78 @@ +#include "simple_web_server_request.h" + +#include "../http/web_server.h" +#include "../http/web_server_cookie.h" +#include "core/object.h" + +#include "../http/http_session.h" + +#include "../http/http_session_manager.h" +#include "../http/web_node.h" + +#include "../http/web_permission.h" + +String SimpleWebServerRequest::get_cookie(const String &key) { + return ""; +} + +void SimpleWebServerRequest::add_cookie(const Ref &cookie) { +} + +void SimpleWebServerRequest::remove_cookie(const String &key) { +} + +HTTPServerEnums::HTTPMethod SimpleWebServerRequest::get_method() const { + return HTTPServerEnums::HTTP_METHOD_GET; +} + +void SimpleWebServerRequest::parse_files() { +} +int SimpleWebServerRequest::get_file_count() const { + return 0; +} +int SimpleWebServerRequest::get_file_length(const int index) const { + return 0; +} +const uint8_t *SimpleWebServerRequest::get_file_data(const int index) const { + return nullptr; +} +String SimpleWebServerRequest::get_file_data_str(const int index) const { + return ""; +} + +String SimpleWebServerRequest::get_parameter(const String &key) const { + return ""; +} + +void SimpleWebServerRequest::send_redirect(const String &location, const HTTPServerEnums::HTTPStatusCode status_code) { +} + +void SimpleWebServerRequest::send() { + // if (connection_closed) { + // SimpleWebServerRequestPool::return_request(this); + // return; + // } + + // SimpleWebServerRequestPool::return_request(this); +} + +void SimpleWebServerRequest::send_file(const String &p_file_path) { + // SimpleWebServerRequestPool::return_request(this); +} + +String SimpleWebServerRequest::parser_get_path() { + return ""; +} + +String SimpleWebServerRequest::get_host() const { + return ""; +} + +SimpleWebServerRequest::SimpleWebServerRequest() { +} + +SimpleWebServerRequest::~SimpleWebServerRequest() { +} + +void SimpleWebServerRequest::_bind_methods() { +} diff --git a/modules/web/http_server_simple/simple_web_server_request.h b/modules/web/http_server_simple/simple_web_server_request.h new file mode 100644 index 000000000..dcd984c49 --- /dev/null +++ b/modules/web/http_server_simple/simple_web_server_request.h @@ -0,0 +1,51 @@ +#ifndef SIMPLE_WEB_SERVER_REQUEST_H +#define SIMPLE_WEB_SERVER_REQUEST_H + +#include "core/dictionary.h" +#include "core/ustring.h" +#include "core/vector.h" + +#include "../http/web_server_request.h" + +#include "../http/http_server_enums.h" + +class WebServer; +class WebServerCookie; +class HTTPSession; +class WebPermission; +class WebNode; + +class SimpleWebServerRequest : public WebServerRequest { + GDCLASS(SimpleWebServerRequest, WebServerRequest); + +public: + virtual String get_cookie(const String &key); + virtual void add_cookie(const Ref &cookie); + virtual void remove_cookie(const String &key); + + virtual HTTPServerEnums::HTTPMethod get_method() const; + + virtual void parse_files(); + virtual int get_file_count() const; + virtual int get_file_length(const int index) const; + virtual const uint8_t *get_file_data(const int index) const; + virtual String get_file_data_str(const int index) const; + + virtual String get_parameter(const String &key) const; + + virtual void send_redirect(const String &location, const HTTPServerEnums::HTTPStatusCode status_code = HTTPServerEnums::HTTP_STATUS_CODE_302_FOUND); + virtual void send(); + virtual void send_file(const String &p_file_path); + virtual String parser_get_path(); + virtual String get_host() const; + + virtual String get_path_full() const; + + SimpleWebServerRequest(); + ~SimpleWebServerRequest(); + +protected: + static void _bind_methods(); +}; + +#endif