HTTPS server ! HTTPS server is used to create secured HTTPS Web server and communicate with clients using secure HTTPS protocol. It allows to receive GET, POST, PUT, DELETE requests and send HTTP responses. Thread-safe. */
| 27 | Thread-safe. |
| 28 | */ |
| 29 | class HTTPSServer : public Asio::SSLServer |
| 30 | { |
| 31 | public: |
| 32 | using SSLServer::SSLServer; |
| 33 | |
| 34 | HTTPSServer(const HTTPSServer&) = delete; |
| 35 | HTTPSServer(HTTPSServer&&) = delete; |
| 36 | virtual ~HTTPSServer() = default; |
| 37 | |
| 38 | HTTPSServer& operator=(const HTTPSServer&) = delete; |
| 39 | HTTPSServer& operator=(HTTPSServer&&) = delete; |
| 40 | |
| 41 | //! Get the static content cache |
| 42 | CppCommon::FileCache& cache() noexcept { return _cache; } |
| 43 | const CppCommon::FileCache& cache() const noexcept { return _cache; } |
| 44 | |
| 45 | //! Add static content cache |
| 46 | /*! |
| 47 | \param path - Static content path |
| 48 | \param prefix - Cache prefix (default is "/") |
| 49 | \param timeout - Refresh cache timeout (default is 1 hour) |
| 50 | */ |
| 51 | void AddStaticContent(const CppCommon::Path& path, const std::string& prefix = "/", const CppCommon::Timespan& timeout = CppCommon::Timespan::hours(1)); |
| 52 | //! Remove static content cache |
| 53 | /*! |
| 54 | \param path - Static content path |
| 55 | */ |
| 56 | void RemoveStaticContent(const CppCommon::Path& path) { _cache.remove_path(path); } |
| 57 | //! Clear static content cache |
| 58 | void ClearStaticContent() { _cache.clear(); } |
| 59 | |
| 60 | //! Watchdog the static content cache |
| 61 | void Watchdog(const CppCommon::UtcTimestamp& utc = CppCommon::UtcTimestamp()) { _cache.watchdog(utc); } |
| 62 | |
| 63 | protected: |
| 64 | std::shared_ptr<Asio::SSLSession> CreateSession(const std::shared_ptr<Asio::SSLServer>& server) override { return std::make_shared<HTTPSSession>(std::dynamic_pointer_cast<HTTPSServer>(server)); } |
| 65 | |
| 66 | private: |
| 67 | // Static content cache |
| 68 | CppCommon::FileCache _cache; |
| 69 | }; |
| 70 | |
| 71 | /*! \example https_server.cpp HTTPS server example */ |
| 72 |
nothing calls this directly
no outgoing calls
no test coverage detected