MCPcopy Create free account
hub / github.com/chronoxor/CppServer / HTTPSSession

Class HTTPSSession

include/server/http/https_session.h:29–186  ·  view source on GitHub ↗

HTTPS session ! HTTPS session is used to receive/send HTTP requests/responses from the connected HTTPS client. Thread-safe. */

Source from the content-addressed store, hash-verified

27 Thread-safe.
28*/
29class HTTPSSession : public Asio::SSLSession
30{
31public:
32 explicit HTTPSSession(const std::shared_ptr<HTTPSServer>& server);
33 HTTPSSession(const HTTPSSession&) = delete;
34 HTTPSSession(HTTPSSession&&) = delete;
35 virtual ~HTTPSSession() = default;
36
37 HTTPSSession& operator=(const HTTPSSession&) = delete;
38 HTTPSSession& operator=(HTTPSSession&&) = delete;
39
40 //! Get the static content cache
41 CppCommon::FileCache& cache() noexcept { return _cache; }
42 const CppCommon::FileCache& cache() const noexcept { return _cache; }
43
44 //! Get the HTTP response
45 HTTPResponse& response() noexcept { return _response; }
46 const HTTPResponse& response() const noexcept { return _response; }
47
48 //! Send the current HTTP response (synchronous)
49 /*!
50 \return Size of sent data
51 */
52 size_t SendResponse() { return SendResponse(_response); }
53 //! Send the HTTP response (synchronous)
54 /*!
55 \param response - HTTP response
56 \return Size of sent data
57 */
58 size_t SendResponse(const HTTPResponse& response) { return Send(response.cache()); }
59
60 //! Send the HTTP response body (synchronous)
61 /*!
62 \param body - HTTP response body
63 \return Size of sent data
64 */
65 size_t SendResponseBody(std::string_view body) { return Send(body); }
66 //! Send the HTTP response body (synchronous)
67 /*!
68 \param buffer - HTTP response body buffer
69 \param size - HTTP response body size
70 \return Size of sent data
71 */
72 size_t SendResponseBody(const void* buffer, size_t size) { return Send(buffer, size); }
73
74 //! Send the current HTTP response with timeout (synchronous)
75 /*!
76 \param timeout - Timeout
77 \return Size of sent data
78 */
79 size_t SendResponse(const CppCommon::Timespan& timeout) { return SendResponse(_response, timeout); }
80 //! Send the HTTP response with timeout (synchronous)
81 /*!
82 \param response - HTTP response
83 \param timeout - Timeout
84 \return Size of sent data
85 */
86 size_t SendResponse(const HTTPResponse& response, const CppCommon::Timespan& timeout) { return Send(response.cache(), timeout); }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected