From 10a74f18b99442fb028c84f72754d32f63237616 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 23 Apr 2024 00:18:16 +1000 Subject: [PATCH] emu/http.cpp, util/server_http_impl.hpp: Added override qualifiers for overridden virtual member functions. --- src/emu/http.cpp | 26 +++++++++++++------------- src/lib/util/server_http_impl.hpp | 8 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/emu/http.cpp b/src/emu/http.cpp index 8c95e731552..2a30a13dba3 100644 --- a/src/emu/http.cpp +++ b/src/emu/http.cpp @@ -144,28 +144,28 @@ public: virtual ~http_request_impl() = default; /** Retrieves the requested resource. */ - virtual const std::string get_resource() { + virtual const std::string get_resource() override { // The entire resource: path, query and fragment. return m_request->path; } /** Returns the path part of the requested resource. */ - virtual const std::string get_path() { + virtual const std::string get_path() override { return m_request->path.substr(0, m_path_end); } /** Returns the query part of the requested resource. */ - virtual const std::string get_query() { + virtual const std::string get_query() override { return m_query == std::string::npos ? "" : m_request->path.substr(m_query, m_query_end); } /** Returns the fragment part of the requested resource. */ - virtual const std::string get_fragment() { + virtual const std::string get_fragment() override { return m_fragment == std::string::npos ? "" : m_request->path.substr(m_fragment); } /** Retrieves a header from the HTTP request. */ - virtual const std::string get_header(const std::string &header_name) { + virtual const std::string get_header(const std::string &header_name) override { auto i = m_request->header.find(header_name); if (i != m_request->header.end()) { return (*i).second; @@ -175,7 +175,7 @@ public: } /** Retrieves a header from the HTTP request. */ - virtual const std::list get_headers(const std::string &header_name) { + virtual const std::list get_headers(const std::string &header_name) override { std::list result; auto range = m_request->header.equal_range(header_name); for (auto i = range.first; i != range.second; i++) { @@ -185,7 +185,7 @@ public: } /** Returns the body that was submitted with the HTTP request. */ - virtual const std::string get_body() { + virtual const std::string get_body() override { // TODO(cbrunschen): What to return here - http_server::Request has a 'content' feld that is never filled in! return ""; } @@ -204,23 +204,23 @@ struct http_response_impl : public http_manager::http_response { virtual ~http_response_impl() = default; /** Sets the HTTP status to be returned to the client. */ - virtual void set_status(int status) { + virtual void set_status(int status) override { m_status = status; } /** Sets the HTTP content type to be returned to the client. */ - virtual void set_content_type(const std::string &content_type) { + virtual void set_content_type(const std::string &content_type) override { m_content_type = content_type; } /** Sets the body to be sent to the client. */ - virtual void set_body(const std::string &body) { + virtual void set_body(const std::string &body) override { m_body.str(""); append_body(body); } /** Appends something to the body to be sent to the client. */ - virtual void append_body(const std::string &body) { + virtual void append_body(const std::string &body) override { m_body << body; } @@ -258,7 +258,7 @@ struct websocket_connection_impl : public http_manager::websocket_connection { : m_wsserver(server), m_connection(connection) { } /** Sends a message to the client that is connected on the other end of this Websocket connection. */ - virtual void send_message(const std::string &payload, int opcode) { + virtual void send_message(const std::string &payload, int opcode) override { if (auto connection = m_connection.lock()) { std::shared_ptr message_stream = std::make_shared(); (*message_stream) << payload; @@ -267,7 +267,7 @@ struct websocket_connection_impl : public http_manager::websocket_connection { } /** Closes this open Websocket connection. */ - virtual void close() { + virtual void close() override { if (auto connection = m_connection.lock()) { m_wsserver->send_close(connection, 1000 /* normal close */); } diff --git a/src/lib/util/server_http_impl.hpp b/src/lib/util/server_http_impl.hpp index e949e6b2483..7de440bce2c 100644 --- a/src/lib/util/server_http_impl.hpp +++ b/src/lib/util/server_http_impl.hpp @@ -63,10 +63,10 @@ namespace webpp { } } public: - virtual Response& status(int number) { m_ostream << statusToString(number); return *this; } - virtual void type(std::string str) { m_header << "Content-Type: "<< str << "\r\n"; } - virtual void send(std::string str) { m_ostream << m_header.str() << "Content-Length: " << str.length() << "\r\n\r\n" << str; } - virtual size_t size() const { return m_streambuf.size(); } + virtual Response& status(int number) override { m_ostream << statusToString(number); return *this; } + virtual void type(std::string str) override { m_header << "Content-Type: "<< str << "\r\n"; } + virtual void send(std::string str) override { m_ostream << m_header.str() << "Content-Length: " << str.length() << "\r\n\r\n" << str; } + virtual size_t size() const override { return m_streambuf.size(); } std::shared_ptr socket() { return m_socket; } /// If true, force server to close the connection after the response have been sent.