The new HTTP server implementation does not fully adhere to common C++ practice such as described in Core Guidelines[^1][^2]. Beyond motivations such as information hiding and enforcing invariants, exposing data through accessor methods also implies adding lock annotations.
Commits:
- Makes
HTTPResponsea struct since it is used that way. (https://github.com/bitcoin/bitcoin/pull/35182#discussion_r3336757663) HTTPRequest:- Saner return type for
GetHeader()(old type was mirroring the now removed libevent-wrapper). - Make fields private.
- Saner return type for
- Simplifies boolean logic in
HTTPServer::DisconnectClients(). (https://github.com/bitcoin/bitcoin/pull/35182#discussion_r3336757663) - Extraction of
HTTPServerfunctions intoHTTPRemoteClient: RefactorsHTTPRemoteClientto be more self-contained rather than havingHTTPServerreach into the fields of other objects. (https://github.com/bitcoin/bitcoin/pull/35182#discussion_r3339543447, #35182 (review)) - Severely narrows
http_bitcoinnamespace and renames it tobitcoin_http(https://github.com/bitcoin/bitcoin/pull/35182#discussion_r3264510816)
Follow-up to #35182.
[^1]: Core Guidelines: C.2: Use class if the class has an invariant; use struct if the data members can vary independently - https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently [^2]: Core Guidelines: C.9: Minimize exposure of members - https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c9-minimize-exposure-of-members