Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
Message.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Framework_WebServer_Message_h_
5#define _Stroika_Framework_WebServer_Message_h_ 1
6
7#include "Stroika/Frameworks/StroikaPreComp.h"
8
9#include "Stroika/Foundation/Common/Property.h"
12
13#include "Stroika/Frameworks/WebServer/Request.h"
14#include "Stroika/Frameworks/WebServer/Response.h"
15
16/*
17 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
18 */
19
21
22 using namespace Stroika::Foundation;
23
24 using IO::Network::URI;
25
26 /**
27 * A message refers to a single back-and-forth request/response pair exchanged over HTTP.
28 *
29 * \note Satisfies Concepts:
30 * o static_assert (not copyable<Message>);
31 * o static_assert (movable<Message>);
32 *
33 * \note \em Thread-Safety <a href="Thread-Safety.md#C++-Standard-Thread-Safety">C++-Standard-Thread-Safety</a>
34 */
35 class Message {
36 public:
37 /**
38 * \note that a Message is not copyable (but is movable). Typically its passed around by reference.
39 */
40 Message () = delete;
41 Message (const Message&) = delete;
42 Message (Message&& src) noexcept;
43 Message (Request&& request, Response&& response, const optional<IO::Network::SocketAddress>& peerAddress = nullopt);
44
45 public:
46 nonvirtual Message& operator= (const Message&) = delete;
47 nonvirtual Message& operator= (Message&& rhs) noexcept;
48
49#if qStroika_Foundation_Debug_AssertExternallySynchronizedMutex_Enabled
50 public:
51 /**
52 * Allow users of the Connection object to have it share a 'assure externally synchronized' context.
53 *
54 * \see AssertExternallySynchronizedMutex::SetAssertExternallySynchronizedMutexContext
55 */
56 nonvirtual void SetAssertExternallySynchronizedMutexContext (const shared_ptr<Debug::AssertExternallySynchronizedMutex::SharedContext>& sharedContext);
57#endif
58
59 public:
60 /**
61 * This is the network address where the message (request) came from and where the message response is
62 * going to be returned to. This can be sometimes omitted/unknown (HOW UNKNOWN - TBD DOCUMENT)
63 *
64 * @see ConnectionOrientedStreamSocket::Ptr::GetPeerAddress
65 */
67
68 public:
69 /**
70 * Returns a read-only reference (so not assignable to) to a const Request& (so cannot modify the request).
71 */
73
74 public:
75 /**
76 * Returns a read-only reference (so not assignable) to a Request& (so CAN modify the request).
77 * This should very rarely be used (just perhaps when constructing the original message).
78 * Generally use request instead.
79 */
81
82 public:
83 /**
84 * Returns a read-only reference (so not assignable) to a const Response& (so cannot modify the response).
85 */
87
88 public:
89 /**
90 * Returns a read-only reference (so not assignable) to a Response& (so CAN modify the response).
91 * Typically, users will want to access the 'rwResponse' not the 'response', since the underlying response object is frequently being updated.
92 */
94
95 public:
96 /**
97 * @see Characters::ToString ();
98 */
99 nonvirtual String ToString () const;
100
101 private:
102 optional<IO::Network::SocketAddress> fPeerAddress_;
103 Request fRequest_;
104 Response fResponse_;
105 [[no_unique_address]] Debug::AssertExternallySynchronizedMutex fThisAssertExternallySynchronized_;
106 };
107
108}
109
110/*
111 ********************************************************************************
112 ***************************** Implementation Details ***************************
113 ********************************************************************************
114 */
115#include "Message.inl"
116
117#endif /*_Stroika_Framework_WebServer_Message_h_*/
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
NOT a real mutex - just a debugging infrastructure support tool so in debug builds can be assured thr...
Common::ReadOnlyProperty< Response & > rwResponse
Definition Message.h:93
Common::ReadOnlyProperty< const Request & > request
Definition Message.h:72
Common::ReadOnlyProperty< optional< IO::Network::SocketAddress > > peerAddress
Definition Message.h:66
Common::ReadOnlyProperty< const Response & > response
Definition Message.h:86
Common::ReadOnlyProperty< Request & > rwRequest
Definition Message.h:80
nonvirtual String ToString() const
Definition Message.cpp:75
this represents a HTTP request object for the WebServer module