http: Make HTTPRequest update state internally #36124

Manually merged
hodlinator merged 4 commits from 2026/08/http_refactors into master 2026-10-29 14:45:08 +00:00 AGit
hodlinator commented 2026-08-31 07:58:53 +00:00 (Migrated from github.com)

Issues in order of importance

#35829 made the fields of HTTPRequest & HTTPRemoteClient private, but still allows anyone with a reference to a request to update the internal state enum. https://github.com/bitcoin/bitcoin/pull/35829#discussion_r3860447518

HTTPRemoteClient::TryReadRequest() only needs to be a static method in order to forward a shared_ptr of a client to a new request.

Commits solving these issues in same order

  • http: Remove HTTPRequest::SetState() and introduce HTTPRequest::Load() - Removes the ability for other classes to directly modify the request state.
  • 2 refactors: Extract HTTPRemoteClient::TryReadRequestInternal() from a combination of HTTPRemoteClient::TryReadRequest() and HTTPRemoteClient::ReadRequest() (the latter is removed)
### Issues in order of importance #35829 made the fields of `HTTPRequest` & `HTTPRemoteClient` private, but still allows anyone with a reference to a request to update the internal state `enum`. https://github.com/bitcoin/bitcoin/pull/35829#discussion_r3860447518 `HTTPRemoteClient::TryReadRequest()` only needs to be a `static` method in order to forward a `shared_ptr` of a client to a new request. ### Commits solving these issues in same order * http: Remove `HTTPRequest::SetState()` and introduce `HTTPRequest::Load()` - Removes the ability for other classes to directly modify the request state. * 2 refactors: Extract `HTTPRemoteClient::TryReadRequestInternal()` from a combination of `HTTPRemoteClient::TryReadRequest()` and `HTTPRemoteClient::ReadRequest()` (the latter is removed)
DrahtBot commented 2026-08-31 07:59:01 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK pinheadmz
Concept ACK jeanpablojp
Stale ACK janb84, winterrdog

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

No conflicts as of last run.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36124 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36124.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36124#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [pinheadmz](https://github.com/bitcoin/bitcoin/pull/36124#pullrequestreview-5698746466) | | Concept ACK | [jeanpablojp](https://github.com/bitcoin/bitcoin/pull/36124#pullrequestreview-5070443277) | | Stale ACK | [janb84](https://github.com/bitcoin/bitcoin/pull/36124#pullrequestreview-5102409506), [winterrdog](https://github.com/bitcoin/bitcoin/pull/36124#pullrequestreview-5574076817) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts No conflicts as of last run. <!--5faf32d7da4f0f540f40219e4f7537a3-->
jeanpablojp (Migrated from github.com) reviewed 2026-08-31 19:38:51 +00:00
jeanpablojp (Migrated from github.com) left a comment

Concept ACK

I ran the flattened ShouldDisconnect() against the version in master over every combination of the flags it reads, with the client inside and outside the idle window and the timeout on and off. Same return value in all 64. The only difference is that master logs the idle timeout even for a client that is already flagged for disconnect.

Concept ACK I ran the flattened `ShouldDisconnect()` against the version in master over every combination of the flags it reads, with the client inside and outside the idle window and the timeout on and off. Same return value in all 64. The only difference is that master logs the idle timeout even for a client that is already flagged for disconnect.
jeanpablojp (Migrated from github.com) commented 2026-08-31 19:38:51 +00:00

The unit tests run ShouldDisconnect() but assert nothing about its first two branches. I broke each one and the suite stayed green both times. interface_http.py does reach both, but it blocks on the socket instead of failing. The test below covers both branches, and the new log line with them.

test for both branches and the new log line
@@ -746,6 +746,38 @@ BOOST_AUTO_TEST_CASE(http_request_state_tests)
     }
 }
 
+BOOST_AUTO_TEST_CASE(http_should_disconnect_tests)
+{
+    struct Client : HTTPRemoteClient {
+        Client() : HTTPRemoteClient{/*id=*/0, /*addr=*/CService(), /*socket=*/CreateSock(0, 0, 0)} {}
+        using HTTPRemoteClient::MutateRecvBuffer;
+    };
+    constexpr auto timeout{30s};
+    const auto now{Now<SteadySeconds>()};
+
+    // Nothing to disconnect for yet.
+    auto idle{std::make_shared<Client>()};
+    BOOST_CHECK(!idle->ShouldDisconnect(now, timeout, /*disconnect_all=*/false));
+    // A shutdown waits for a connection that is still busy, and it starts busy.
+    BOOST_CHECK(!idle->ShouldDisconnect(now, timeout, /*disconnect_all=*/true));
+    // Past -rpcservertimeout, which a timeout of 0 disables.
+    BOOST_CHECK(idle->ShouldDisconnect(now + timeout + 1s, timeout, /*disconnect_all=*/false));
+    BOOST_CHECK(!idle->ShouldDisconnect(now + timeout + 1s, 0s, /*disconnect_all=*/false));
+
+    // A request handed to a worker holds the idle timeout off until the reply is sent.
+    auto busy{std::make_shared<Client>()};
+    busy->MutateRecvBuffer().append("GET / HTTP/1.0\n\n");
+    auto request{HTTPRemoteClient::TryReadRequest(busy)};
+    BOOST_REQUIRE(request);
+    BOOST_CHECK(!busy->ShouldDisconnect(now + timeout + 1s, timeout, /*disconnect_all=*/false));
+
+    // A malformed request flags the client, and that outranks the rest.
+    auto bad{std::make_shared<Client>()};
+    bad->MutateRecvBuffer().append("GET / HTTP/1.0\nInvalid header with no colon\n\n");
+    BOOST_CHECK(!HTTPRemoteClient::TryReadRequest(bad));
+    BOOST_CHECK(bad->ShouldDisconnect(now, 0s, /*disconnect_all=*/false));
+}
+
 BOOST_AUTO_TEST_CASE(http_server_socket_tests)
 {
     // Hard code the timestamp for the Date header in the HTTP response
@@ -791,6 +823,9 @@ BOOST_AUTO_TEST_CASE(http_server_socket_tests)
     // Create a mock client with pre-loaded request data and add it to the local CreateSock queue.
     // Keep a handle for the mock client's send and receive pipes so we can examine
     // the data it "receives".
+    // No keep-alive, so the server closes once the reply is flushed, and says so.
+    DebugLogHelper find_close{"Done sending to client without keep-alive"};
+
     std::shared_ptr<DynSock::Pipes> mock_client_socket_pipes{ConnectClient(std::as_bytes(std::span(full_request)))};
 
     // Wait up to a minute to find and connect the client in the I/O loop
The unit tests run `ShouldDisconnect()` but assert nothing about its first two branches. I broke each one and the suite stayed green both times. `interface_http.py` does reach both, but it blocks on the socket instead of failing. The test below covers both branches, and the new log line with them. <details> <summary>test for both branches and the new log line</summary> ```diff @@ -746,6 +746,38 @@ BOOST_AUTO_TEST_CASE(http_request_state_tests) } } +BOOST_AUTO_TEST_CASE(http_should_disconnect_tests) +{ + struct Client : HTTPRemoteClient { + Client() : HTTPRemoteClient{/*id=*/0, /*addr=*/CService(), /*socket=*/CreateSock(0, 0, 0)} {} + using HTTPRemoteClient::MutateRecvBuffer; + }; + constexpr auto timeout{30s}; + const auto now{Now<SteadySeconds>()}; + + // Nothing to disconnect for yet. + auto idle{std::make_shared<Client>()}; + BOOST_CHECK(!idle->ShouldDisconnect(now, timeout, /*disconnect_all=*/false)); + // A shutdown waits for a connection that is still busy, and it starts busy. + BOOST_CHECK(!idle->ShouldDisconnect(now, timeout, /*disconnect_all=*/true)); + // Past -rpcservertimeout, which a timeout of 0 disables. + BOOST_CHECK(idle->ShouldDisconnect(now + timeout + 1s, timeout, /*disconnect_all=*/false)); + BOOST_CHECK(!idle->ShouldDisconnect(now + timeout + 1s, 0s, /*disconnect_all=*/false)); + + // A request handed to a worker holds the idle timeout off until the reply is sent. + auto busy{std::make_shared<Client>()}; + busy->MutateRecvBuffer().append("GET / HTTP/1.0\n\n"); + auto request{HTTPRemoteClient::TryReadRequest(busy)}; + BOOST_REQUIRE(request); + BOOST_CHECK(!busy->ShouldDisconnect(now + timeout + 1s, timeout, /*disconnect_all=*/false)); + + // A malformed request flags the client, and that outranks the rest. + auto bad{std::make_shared<Client>()}; + bad->MutateRecvBuffer().append("GET / HTTP/1.0\nInvalid header with no colon\n\n"); + BOOST_CHECK(!HTTPRemoteClient::TryReadRequest(bad)); + BOOST_CHECK(bad->ShouldDisconnect(now, 0s, /*disconnect_all=*/false)); +} + BOOST_AUTO_TEST_CASE(http_server_socket_tests) { // Hard code the timestamp for the Date header in the HTTP response @@ -791,6 +823,9 @@ BOOST_AUTO_TEST_CASE(http_server_socket_tests) // Create a mock client with pre-loaded request data and add it to the local CreateSock queue. // Keep a handle for the mock client's send and receive pipes so we can examine // the data it "receives". + // No keep-alive, so the server closes once the reply is flushed, and says so. + DebugLogHelper find_close{"Done sending to client without keep-alive"}; + std::shared_ptr<DynSock::Pipes> mock_client_socket_pipes{ConnectClient(std::as_bytes(std::span(full_request)))}; // Wait up to a minute to find and connect the client in the I/O loop ``` </details>
winterrdog (Migrated from github.com) reviewed 2026-09-01 09:21:31 +00:00
winterrdog (Migrated from github.com) left a comment

Concept ACK

Concept ACK
winterrdog (Migrated from github.com) reviewed 2026-09-01 15:58:27 +00:00
Lines 1211-1212
winterrdog (Migrated from github.com) commented 2026-09-01 15:58:17 +00:00

Note

i think NONFATAL_UNREACHABLE will do just fine. do not mind the comment below 🤝


do you think some runtime safety like assert(false) (in debug builds) would be useful here ?

e.g. similar to how it's done:
github.com/bitcoin/bitcoin@dc0395c585/src/index/blockfilterindex.cpp (L64-L71)

or here:
github.com/bitcoin/bitcoin@dc0395c585/src/bitcoin-cli.cpp (L430-L445)

> [!NOTE] > i think `NONFATAL_UNREACHABLE` will do just fine. do not mind the comment below 🤝 --- do you think some runtime safety like `assert(false)` (in debug builds) would be useful here ? e.g. similar to how it's done: https://github.com/bitcoin/bitcoin/blob/dc0395c5858a1d55239b82a834e5075cf2069219/src/index/blockfilterindex.cpp#L64-L71 or here: https://github.com/bitcoin/bitcoin/blob/dc0395c5858a1d55239b82a834e5075cf2069219/src/bitcoin-cli.cpp#L430-L445
hodlinator (Migrated from github.com) reviewed 2026-09-02 10:07:52 +00:00
hodlinator (Migrated from github.com) commented 2026-09-02 10:07:52 +00:00

Thanks! Added the checks in slightly extended form.

Thanks! Added the checks in slightly extended form.
janb84 (Migrated from github.com) reviewed 2026-09-02 15:08:24 +00:00
janb84 (Migrated from github.com) left a comment

concept ACK 907d7342b60dfa00ad81e235eccb5808b9c13da6

The removal of the SetState() makes it a better design (imho), makes the convention based "rule" not to arbitrary set the state, to a a compiler-enforced fact

Found a few possible NITS.

concept ACK 907d7342b60dfa00ad81e235eccb5808b9c13da6 The removal of the `SetState()` makes it a better design (imho), makes the convention based "rule" not to arbitrary set the state, to a a compiler-enforced fact Found a few possible NITS.
janb84 (Migrated from github.com) commented 2026-09-02 14:21:20 +00:00

NIT: would it not help the readability to move this function closer to the other load* helpers ? ~ L 378

NIT: would it not help the readability to move this function closer to the other load* helpers ? ~ L 378
janb84 (Migrated from github.com) commented 2026-09-02 15:07:51 +00:00

NIT. On error it does not return true. Why not make it void? non-test code already checks getstate() and doing the same in the tests makes the test slightly more strict. The bool loosy communicates 5 states in a bool

     * @returns     true    If the request was fully parsed or already complete
NIT. On error it does not return `true`. Why not make it void? non-test code already checks `getstate()` and doing the same in the tests makes the test slightly more strict. The bool loosy communicates 5 states in a bool ```suggestion * @returns true If the request was fully parsed or already complete ```
winterrdog (Migrated from github.com) reviewed 2026-09-03 08:07:28 +00:00
winterrdog (Migrated from github.com) commented 2026-09-03 08:07:28 +00:00

nit: this comment still refers to LoadControlData/LoadHeaders/LoadBody as the call sequence above, but those were replaced by a single Load() call. since the helpers are private now too, it is not immediately clear to a reader where this logic comes from

**nit**: this comment still refers to `LoadControlData`/`LoadHeaders`/`LoadBody` as the call sequence above, but those were replaced by a single `Load()` call. since the helpers are private now too, it is not immediately clear to a reader where this logic comes from
hodlinator (Migrated from github.com) reviewed 2026-09-03 09:36:58 +00:00
hodlinator (Migrated from github.com) left a comment

Thanks for the feedback so far! Pushes after 907d7342b60dfa00ad81e235eccb5808b9c13da6 address some nits and expands http_should_disconnect_tests to more completely verify optimistic send behavior.

Thanks for the feedback so far! Pushes after 907d7342b60dfa00ad81e235eccb5808b9c13da6 address some nits and expands `http_should_disconnect_tests` to more completely verify optimistic send behavior.
hodlinator (Migrated from github.com) commented 2026-09-03 09:07:06 +00:00

re https://github.com/bitcoin/bitcoin/pull/36124#discussion_r3915112397:
The order of methods in httpserver.cpp is wildly out of sync with the header. I prefer to punt on this for now, to keep the number of commits down.

re https://github.com/bitcoin/bitcoin/pull/36124#discussion_r3915112397: The order of methods in httpserver.cpp is wildly out of sync with the header. I prefer to punt on this for now, to keep the number of commits down.
hodlinator (Migrated from github.com) commented 2026-09-03 09:08:04 +00:00

re https://github.com/bitcoin/bitcoin/pull/36124#discussion_r3915573840:
Removed docstring for now as I switched to returning state which seems self-explanatory.

re https://github.com/bitcoin/bitcoin/pull/36124#discussion_r3915573840: Removed docstring for now as I switched to returning state which seems self-explanatory.
hodlinator (Migrated from github.com) reviewed 2026-09-03 10:45:48 +00:00
hodlinator (Migrated from github.com) left a comment

Decided to split out two PRs from this one as they are quite independent. See #36159 and #36160.

Decided to split out two PRs from this one as they are quite independent. See #36159 and #36160.
hodlinator (Migrated from github.com) commented 2026-09-03 10:44:03 +00:00

Added co-authorship in #36159.

Added co-authorship in #36159.
janb84 (Migrated from github.com) reviewed 2026-09-03 13:19:19 +00:00
janb84 (Migrated from github.com) left a comment

(re) ACK c43d544b16b61e3182467dba7355cdaa372204c6

returning the state and not a bool at the load() function, is the better way to go imho :) Have re-reviewed the PR because of the split-off; build tested etc.

In the commit message, is an API change a behaviour change? super micro nit.
The load() documentation block has no @return anymore, is state super clear to everyone ?

(re) ACK c43d544b16b61e3182467dba7355cdaa372204c6 returning the state and not a bool at the `load()` function, is the better way to go imho :) Have re-reviewed the PR because of the split-off; build tested etc. In the commit message, is an API change a behaviour change? super micro nit. The `load()` documentation block has no @return anymore, is state super clear to everyone ?
winterrdog commented 2026-09-05 20:21:56 +00:00 (Migrated from github.com)

is state super clear to everyone ?

had not noticed this. i think we can add the @return with some light
documentation.

State is self-explanatory as a type, but it does not tell a caller that
Load() never returns Error (it throws instead), or that the other values
mean "keep calling with more data" vs "done", sth that is specific to
Load()'s contract. secondly, it keeps consistency with the @throws below
and the Doxygen style used elsewhere

> is state super clear to everyone ? had not noticed this. i think we can add the `@return` with some _light_ documentation. `State` is self-explanatory as a type, but it does not tell a caller that `Load()` never returns `Error` (it throws instead), or that the other values mean "_keep calling with more data_" vs "_done_", sth that is specific to `Load()`'s contract. secondly, it keeps consistency with the `@throws` below and the Doxygen style used elsewhere
hodlinator commented 2026-09-05 21:00:03 +00:00 (Migrated from github.com)

Latest push modifies the initial Load() commit only.

re https://github.com/bitcoin/bitcoin/pull/36124#pullrequestreview-5102409506:

In the commit message, is an API change a behaviour change?

Good point, fixed.

re https://github.com/bitcoin/bitcoin/pull/36124#pullrequestreview-5102409506 + https://github.com/bitcoin/bitcoin/pull/36124#issuecomment-5554537521:

is state super clear to everyone ?

had not noticed this. i think we can add the @return with some light documentation.

State is self-explanatory as a type, but it does not tell a caller that Load() never returns Error (it throws instead), or that the other values mean "keep calling with more data" vs "done", sth that is specific to Load()'s contract. secondly, it keeps consistency with the @throws below and the Doxygen style used elsewhere

Added back @returns. It is true that Load() (re-)throws the first time it sets Error, but subsequent calls will return Error. The return value is only read in unit tests, so not sure if it's worth elaborating further in the doc-string.

Latest push modifies the initial `Load()` commit only. re https://github.com/bitcoin/bitcoin/pull/36124#pullrequestreview-5102409506: > In the commit message, is an API change a behaviour change? Good point, fixed. re https://github.com/bitcoin/bitcoin/pull/36124#pullrequestreview-5102409506 + https://github.com/bitcoin/bitcoin/pull/36124#issuecomment-5554537521: > > is state super clear to everyone ? > > had not noticed this. i think we can add the `@return` with some _light_ documentation. > > `State` is self-explanatory as a type, but it does not tell a caller that `Load()` never returns `Error` (it throws instead), or that the other values mean "_keep calling with more data_" vs "_done_", sth that is specific to `Load()`'s contract. secondly, it keeps consistency with the `@throws` below and the Doxygen style used elsewhere Added back `@returns`. It is true that `Load()` (re-)throws the first time it sets `Error`, but subsequent calls will return `Error`. The return value is only read in unit tests, so not sure if it's worth elaborating further in the doc-string.
winterrdog commented 2026-09-05 21:24:33 +00:00 (Migrated from github.com)

tACK 62796e659f

successfully built and tested on this toolchain: Debian/clang++-18/x86_64

tACK 62796e659fb79a0c6f1749677ec480a80ec26e6d successfully built and tested on this toolchain: Debian/`clang++-18`/`x86_64`
DrahtBot commented 2026-09-10 16:07:45 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-09-16 08:55:55 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-09-25 22:24:37 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
First-time contributor

I found no actionable issues in this static review.


Previous findings
Resolved findings
[Minor · resolved] A complete request can remain undispatched after the receive buffer empties

The early return at line 1101 skips the completion and dispatch check, not just parsing. In the base version, ReadRequest() returned early on an empty receive buffer, but TryReadRequest() still checked whether m_req was complete and dispatched it once the send buffer fell to MAX_BODY_SIZE or below.

This occurs when a pipelined request finishes parsing while earlier responses leave more than MAX_BODY_SIZE (32 MiB) in the send buffer, and parsing consumes the entire receive buffer. Line 1153 then retains the complete request in m_req. Once the send buffer drains, later calls return nullptr at line 1101. GenerateWaitSockets polls only for receives for this client, so the request remains unanswered until the client sends more bytes or the idle timeout closes the connection (m_req_busy is false).

Skip only the load/erase step when the buffer is empty, for example by initializing req_state from m_req->GetState(), so the throttle check still runs on every iteration. Add a unit test that holds a complete request under send pressure, drains the send buffer, and expects dispatch without new input.

No checked-in client that pipelines a request behind a response larger than 32 MiB was identified, so production impact is unconfirmed.

Location: src/httpserver.cpp:1101 (head).

Previous reports of the same concern:

  • src/httpserver.cpp:1101. Fixed. First reported at c84da5e53aa1661a89d522667e7f05c6f6f88a3b. Last checked at 6a5212fb97c2c332fc3cb901f8e9a110622ef841. This is the same mechanism and consequence as 890:2:finding:1. An empty-buffer early return skipped dispatch of a complete request held back by send backpressure, so the request stayed unanswered. At head, the empty-buffer guard covers only the Load/erase block (cpp:1102-1116), and the Complete-state check and throttle run on every call (cpp:1143-1152). Both records are fixed by the same change.
  • src/httpserver.cpp:1101. Fixed. First reported at 656ddb44ba0db001d503cce52db5ac6e6db897f1. Last checked at 6a5212fb97c2c332fc3cb901f8e9a110622ef841. The reported regression was an early return nullptr on an empty receive buffer, placed before the Complete/throttle dispatch check. At head, the !m_recv_buffer.empty() guard wraps only the Load/erase step (cpp:1102-1116). Control always reaches m_req->GetState() == HTTPRequest::State::Complete and the MAX_BODY_SIZE throttle (cpp:1143-1152). SocketHandlerConnected calls TryReadRequest() for every client on every iteration (cpp:919-923). A complete request held back by send backpressure is therefore dispatched on a later iteration once the send buffer drains, with no new input needed. This matches base, where ReadRequest()'s empty-buffer return did not skip the caller's state check.

Reviewed: 6a5212fb97c2 · Full review report · Previous reports

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:87bdde6e11c8200ebab55606962dbcbbed1f25d8bebf674c6c6e659db1fe52cc:8f5adaa231eb1aff4d179f52d5ea908b8cc3066455d0b32a1baa87e2b34c9f86 --> <!-- ralph-base:9bf4815b94b9eaf8807f4e569091778da6c338d5 --> <!-- ralph-head:6a5212fb97c2c332fc3cb901f8e9a110622ef841 --> <!-- ralph-case:c9924e3d43edb6848152e395d691b747a5fd013b7642bab992ad3f2d634d1e19 --> I found no actionable issues in this static review. --- <details> <summary>Previous findings</summary> <details> <summary>Resolved findings</summary> <details> <summary>[Minor · resolved] A complete request can remain undispatched after the receive buffer empties</summary> The early return at line 1101 skips the completion and dispatch check, not just parsing. In the base version, `ReadRequest()` returned early on an empty receive buffer, but `TryReadRequest()` still checked whether `m_req` was complete and dispatched it once the send buffer fell to `MAX_BODY_SIZE` or below. This occurs when a pipelined request finishes parsing while earlier responses leave more than `MAX_BODY_SIZE` (32 MiB) in the send buffer, and parsing consumes the entire receive buffer. Line 1153 then retains the complete request in `m_req`. Once the send buffer drains, later calls return `nullptr` at line 1101. `GenerateWaitSockets` polls only for receives for this client, so the request remains unanswered until the client sends more bytes or the idle timeout closes the connection (`m_req_busy` is false). Skip only the load/erase step when the buffer is empty, for example by initializing `req_state` from `m_req->GetState()`, so the throttle check still runs on every iteration. Add a unit test that holds a complete request under send pressure, drains the send buffer, and expects dispatch without new input. No checked-in client that pipelines a request behind a response larger than 32 MiB was identified, so production impact is unconfirmed. Location: [`src/httpserver.cpp:1101`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/6a5212fb97c2c332fc3cb901f8e9a110622ef841/src/httpserver.cpp#L1101>) (head). Previous reports of the same concern: - src/httpserver.cpp:1101. Fixed. First reported at `c84da5e53aa1661a89d522667e7f05c6f6f88a3b`. Last checked at `6a5212fb97c2c332fc3cb901f8e9a110622ef841`. This is the same mechanism and consequence as 890:2:finding:1. An empty-buffer early return skipped dispatch of a complete request held back by send backpressure, so the request stayed unanswered. At head, the empty-buffer guard covers only the Load/erase block (cpp:1102-1116), and the Complete-state check and throttle run on every call (cpp:1143-1152). Both records are fixed by the same change. - src/httpserver.cpp:1101. Fixed. First reported at `656ddb44ba0db001d503cce52db5ac6e6db897f1`. Last checked at `6a5212fb97c2c332fc3cb901f8e9a110622ef841`. The reported regression was an early `return nullptr` on an empty receive buffer, placed before the Complete/throttle dispatch check. At head, the `!m_recv_buffer.empty()` guard wraps only the Load/erase step (cpp:1102-1116). Control always reaches `m_req->GetState() == HTTPRequest::State::Complete` and the `MAX_BODY_SIZE` throttle (cpp:1143-1152). `SocketHandlerConnected` calls `TryReadRequest()` for every client on every iteration (cpp:919-923). A complete request held back by send backpressure is therefore dispatched on a later iteration once the send buffer drains, with no new input needed. This matches base, where `ReadRequest()`'s empty-buffer return did not skip the caller's state check. </details> </details> </details> <!-- Review tier: sensitive --> --- Reviewed: [`6a5212fb97c2`](<https://git.fish.foo/bitcoin/bitcoin/commit/6a5212fb97c2c332fc3cb901f8e9a110622ef841>) · [Full review report](<https://review.fish.foo/traces/36124-6a5212fb97c2c332fc3cb901f8e9a110622ef841-1669-8.html>) · [Previous reports](<https://review.fish.foo/traces/36124/>)
winterrdog (Migrated from github.com) reviewed 2026-10-17 09:15:05 +00:00
Lines 558-565
winterrdog (Migrated from github.com) commented 2026-10-15 10:08:39 +00:00

in commit c84da5e53a

mostly a concern..

on a 2nd look, i have started to get some reservations about folding ReadRequest into TryReadRequestInternal. was it mainly removed to simplify things, or was there a problem with keeping it separate ?

ReadRequest gave us one place to clean up m_recv_buffer after a failed parse. now, each catch block has to remember to do that itself, so it is easy for someone adding a new error case later to forget. keeping the cleanup in one place felt like a nice and easy safety net

unless there is a reason i am missing, i would lean towards keeping a thin ReadRequest just for the cleanup. it gives us one less thing to worry about when adding new error cases. open to be convinced otherwise. i am mostly trying to understand the direction you want to go

> in commit c84da5e53aa1661a89d522667e7f05c6f6f88a3b mostly a concern.. on a 2nd look, i have started to get some reservations about folding `ReadRequest` into `TryReadRequestInternal`. was it mainly removed to simplify things, or was there a problem with keeping it separate ? `ReadRequest` gave us one place to clean up `m_recv_buffer` after a failed parse. now, each `catch` block has to remember to do that itself, so it is easy for someone adding a new error case later to forget. keeping the cleanup in one place felt like a nice and easy safety net unless there is a reason i am missing, i would lean towards keeping a thin `ReadRequest` just for the cleanup. it gives us one less thing to worry about when adding new error cases. open to be convinced otherwise. i am mostly trying to understand the direction you want to go
hodlinator (Migrated from github.com) reviewed 2026-10-17 13:01:02 +00:00
Lines 558-565
hodlinator (Migrated from github.com) commented 2026-10-17 13:01:02 +00:00

Could potentially add an inner try/catch-block:

--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -1104,7 +1104,12 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal()
     HTTPRequest::State req_state{HTTPRequest::State::Error};
     try {
         // Read data from the buffer into the current request
-        req_state = m_req->Load(reader);
+        try {
+            req_state = m_req->Load(reader);
+        } catch (...) {
+            m_recv_buffer.clear();
+            throw;
+        }
 
         // Remove the bytes read out of the buffer.
         m_recv_buffer.erase(
@@ -1119,7 +1124,6 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal()
             e.what());
 
         WriteNoStoreErrorReply(*m_req, HTTP_CONTENT_TOO_LARGE);
-        m_recv_buffer.clear();
         m_disconnect = true;
         return nullptr;
     } catch (const std::runtime_error& e) {
@@ -1132,7 +1136,6 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal()
 
         // We failed to read a complete request from the buffer
         WriteNoStoreErrorReply(*m_req, HTTP_BAD_REQUEST);
-        m_recv_buffer.clear();
         m_disconnect = true;
         return nullptr;
     }

Would prefer doing that over bringing back HTTPRemoteClient::ReadRequest(). WDYT?

Could potentially add an inner `try`/`catch`-block: ```diff --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -1104,7 +1104,12 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal() HTTPRequest::State req_state{HTTPRequest::State::Error}; try { // Read data from the buffer into the current request - req_state = m_req->Load(reader); + try { + req_state = m_req->Load(reader); + } catch (...) { + m_recv_buffer.clear(); + throw; + } // Remove the bytes read out of the buffer. m_recv_buffer.erase( @@ -1119,7 +1124,6 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal() e.what()); WriteNoStoreErrorReply(*m_req, HTTP_CONTENT_TOO_LARGE); - m_recv_buffer.clear(); m_disconnect = true; return nullptr; } catch (const std::runtime_error& e) { @@ -1132,7 +1136,6 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal() // We failed to read a complete request from the buffer WriteNoStoreErrorReply(*m_req, HTTP_BAD_REQUEST); - m_recv_buffer.clear(); m_disconnect = true; return nullptr; } ``` Would prefer doing that over bringing back `HTTPRemoteClient::ReadRequest()`. WDYT?
winterrdog (Migrated from github.com) reviewed 2026-10-19 07:16:01 +00:00
Lines 558-565
winterrdog (Migrated from github.com) commented 2026-10-19 07:16:01 +00:00

i think that will do. let's run with it

i had 2 alternatives, but both introduced a helper, which i understand you would rather avoid here


also, i think the reader can be scoped to the outer try-catch instead of function scope, since that is the only scope it is used in, thus ending up with sth like this:

a/src/httpserver.cpp b/src/httpserver.cpp index 8c9cb5b3ca..5927b16223 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -1099,12 +1099,17 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequest(const std::shared_
 std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal()
 {
     if (m_recv_buffer.empty()) return nullptr;
-    LineReader reader(m_recv_buffer, MAX_HEADERS_SIZE);

     HTTPRequest::State req_state{HTTPRequest::State::Error};
     try {
         // Read data from the buffer into the current request
-        req_state = m_req->Load(reader);
+        LineReader reader(m_recv_buffer, MAX_HEADERS_SIZE);
+        try {
+            req_state = m_req->Load(reader);
+        } catch (...) {
+            m_recv_buffer.clear();
+            throw;
+        }

         // Remove the bytes read out of the buffer.
         m_recv_buffer.erase(
@@ -1119,7 +1124,6 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal()
             e.what());

         WriteNoStoreErrorReply(*m_req, HTTP_CONTENT_TOO_LARGE);
-        m_recv_buffer.clear();
         m_disconnect = true;
         return nullptr;
     } catch (const std::runtime_error& e) {
@@ -1132,7 +1136,6 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal()

         // We failed to read a complete request from the buffer
         WriteNoStoreErrorReply(*m_req, HTTP_BAD_REQUEST);
-        m_recv_buffer.clear();
         m_disconnect = true;
         return nullptr;
     }
i think that will do. let's run with it i had 2 alternatives, but both introduced a helper, which i understand you would rather avoid here --- also, i think the `reader` can be scoped to the outer `try`-`catch` instead of function scope, since that is the only scope it is used in, thus ending up with sth like this: ```diff diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 8c9cb5b3ca..5927b16223 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -1099,12 +1099,17 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequest(const std::shared_ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal() { if (m_recv_buffer.empty()) return nullptr; - LineReader reader(m_recv_buffer, MAX_HEADERS_SIZE); HTTPRequest::State req_state{HTTPRequest::State::Error}; try { // Read data from the buffer into the current request - req_state = m_req->Load(reader); + LineReader reader(m_recv_buffer, MAX_HEADERS_SIZE); + try { + req_state = m_req->Load(reader); + } catch (...) { + m_recv_buffer.clear(); + throw; + } // Remove the bytes read out of the buffer. m_recv_buffer.erase( @@ -1119,7 +1124,6 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal() e.what()); WriteNoStoreErrorReply(*m_req, HTTP_CONTENT_TOO_LARGE); - m_recv_buffer.clear(); m_disconnect = true; return nullptr; } catch (const std::runtime_error& e) { @@ -1132,7 +1136,6 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal() // We failed to read a complete request from the buffer WriteNoStoreErrorReply(*m_req, HTTP_BAD_REQUEST); - m_recv_buffer.clear(); m_disconnect = true; return nullptr; } ```
hodlinator (Migrated from github.com) reviewed 2026-10-19 07:32:58 +00:00
Lines 549-556
hodlinator (Migrated from github.com) commented 2026-10-19 07:32:58 +00:00

Nice! Narrowed the scope of reader in latest push.

Nice! Narrowed the scope of `reader` in latest push.
winterrdog (Migrated from github.com) reviewed 2026-10-19 15:42:14 +00:00
winterrdog (Migrated from github.com) left a comment

reACK 656ddb44ba

LGTM!

reACK 656ddb44ba0db001d503cce52db5ac6e6db897f1 LGTM!
pinheadmz (Migrated from github.com) reviewed 2026-10-27 17:39:42 +00:00
pinheadmz (Migrated from github.com) left a comment

concept ACK

"Ralph" caught something that I think needs to be addressed: https://review.fish.foo/traces/36124-656ddb44ba0db001d503cce52db5ac6e6db897f1-890-2.html

Edge case:

  1. m_send_buffer is full (for some reason), so m_req gets held back (throttled) and is not dispatched to a worker
  2. m_recv_buffer is empty because client sent one request and its now in m_req
  3. this returns early every I/O loop and m_req never(*) gets dispatched, even after the send buffer drains:
std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal()
{
    if (m_recv_buffer.empty()) return nullptr;

(*) = if the client sends more data it will unclog the jam because then m_recv_buffer won't be empty anymore.

Suggested fix from Claude: skip only the parsing when the buffer is empty, and start req_state from the request's current state. This way a Complete request still gets dispatched to a worker.

  HTTPRequest::State req_state{m_req->GetState()};
  try {
      if (!m_recv_buffer.empty()) {
          LineReader reader(m_recv_buffer, MAX_HEADERS_SIZE);
          ...
      }   
  }   
concept ACK "Ralph" caught something that I think needs to be addressed: https://review.fish.foo/traces/36124-656ddb44ba0db001d503cce52db5ac6e6db897f1-890-2.html Edge case: 1. `m_send_buffer` is full (for some reason), so `m_req` gets held back (throttled) and is not dispatched to a worker 2. `m_recv_buffer` is empty because client sent one request and its now in `m_req` 3. this returns early every I/O loop and `m_req` never(*) gets dispatched, even after the send buffer drains: ```cpp std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequestInternal() { if (m_recv_buffer.empty()) return nullptr; ``` (*) = if the client sends more data it will unclog the jam because then `m_recv_buffer` won't be empty anymore. Suggested fix from Claude: skip only the parsing when the buffer is empty, and start req_state from the request's current state. This way a `Complete` request still gets dispatched to a worker. ```cpp HTTPRequest::State req_state{m_req->GetState()}; try { if (!m_recv_buffer.empty()) { LineReader reader(m_recv_buffer, MAX_HEADERS_SIZE); ... } } ```
pinheadmz (Migrated from github.com) commented 2026-10-27 17:06:47 +00:00

b6deeac911

nit: why remove the doxygen param?

b6deeac911e5db6c14f4fe6653bddd329a8e3eed nit: why remove the doxygen param?
hodlinator (Migrated from github.com) reviewed 2026-10-27 19:26:37 +00:00
hodlinator (Migrated from github.com) left a comment

Thank you @pinheadmz & Ralph for catching the accidental behavior change/bug. Applied suggestion, making the last commit more of a pure refactor.

Thank you @pinheadmz & Ralph for catching the accidental behavior change/bug. Applied suggestion, making the last commit more of a pure refactor.
hodlinator (Migrated from github.com) commented 2026-10-27 19:20:59 +00:00

Was keeping it for the now-private Load*() methods. In the latest push I've instead moved it to the public method and rephrased it to be more informative instead of describing the LineReader type.

Was keeping it for the now-private `Load*()` methods. In the latest push I've instead moved it to the public method and rephrased it to be more informative instead of describing the `LineReader` type.
pinheadmz commented 2026-10-28 16:16:51 +00:00 (Migrated from github.com)

doxygen nit, totally ignorable

Turns out I had the grouping syntax wrong. Groups need @name to work, otherwise the description is only attached to the first item.

fixed:

diff --git a/src/httpserver.h b/src/httpserver.h
index cff876abb8..bbe7a7c79d 100644
--- a/src/httpserver.h
+++ b/src/httpserver.h
@@ -132,6 +132,7 @@ private:
 
 struct HTTPVersion {
     /**
+     * @name Protocol version
      * Default HTTP protocol version 1.1 is used by error responses
      * when a request is unreadable.
      */
@@ -199,6 +200,7 @@ public:
 
 private:
     /**
+     * @name Request parsers
      * Methods that attempt to parse HTTP request fields line-by-line
      * from a receive buffer.
      * @returns     true    If the request field was parsed.
Screenshot 2026-10-28 at 12 14 45 PM Screenshot 2026-10-28 at 12 14 36 PM
doxygen nit, totally ignorable Turns out I had the grouping syntax wrong. Groups need `@name` to work, otherwise the description is only attached to the first item. fixed: ```diff diff --git a/src/httpserver.h b/src/httpserver.h index cff876abb8..bbe7a7c79d 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -132,6 +132,7 @@ private: struct HTTPVersion { /** + * @name Protocol version * Default HTTP protocol version 1.1 is used by error responses * when a request is unreadable. */ @@ -199,6 +200,7 @@ public: private: /** + * @name Request parsers * Methods that attempt to parse HTTP request fields line-by-line * from a receive buffer. * @returns true If the request field was parsed. ``` <img width="698" height="180" alt="Screenshot 2026-10-28 at 12 14 45 PM" src="https://git.fish.foo/attachments/55920073-77c4-4aec-935d-dd45bb004b56" /> <img width="828" height="314" alt="Screenshot 2026-10-28 at 12 14 36 PM" src="https://git.fish.foo/attachments/26b61ae9-7fb4-4a8e-88f4-3d11939afa01" />
pinheadmz (Migrated from github.com) approved these changes 2026-10-28 16:19:00 +00:00
pinheadmz (Migrated from github.com) left a comment

ACK 148210fe99

Clean refactor, technically a little granular unit test coverage lost from private-izing internal methods but it makes for cleaner classes.

Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

ACK 148210fe99bb54583fd47f2c39bf0b9390161185
-----BEGIN PGP SIGNATURE-----

iQJPBAEBCAA5FiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmriIDEbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMCwzAAoJEOfimEtiick66N8QALEtD02xBq+MIOB5FIrj
NyxK4JmDLwfYuCo2Qap6GYIRQrDHgsxPmZzpjwqcQg39PqNhTvfHB91qB8SvB4Uv
OJoUyhhGwzWRj8GRzgJj5cbj+XazxGpYf9zQUSZbjXSmiX3wecOp7LdEjVpNzKxs
va/qMjdTUqSfEcRY1vSuCfDCZYKMoioyXvYidOsuErHnwGkHWHpA8llV0L3jNqmz
QNibmLF/fv5WANaIE5JuDQ6M4rfMa10zJ6QLsMRCTPF6BOWya5gXCY5XswiLh0CQ
RMQIxTOyn6cBPaR8vw159cHfruv6XN6lZoeKjbF+u/DCRZz4j/k3DI8LyefKN4K7
IIC10Wqxp+0welsSn/sqk64A5tYCAzFr1a00vodJU/VjSQBn3lUh3sR4Mx+/LQLK
jpOUSQg9maseCDoxC7aWjvFHhSpJsS8izALyLKT5bFb8vIpeuITo1x2bbciq91kP
3tIedAEGK8KfstNIz+Dk2GgCxZSUkziAKJvJ3uMFERQHRg7A9rI2DKU0VObA+ntn
vdEocdYmvcy937SqumDhtfNvnjDE8guOBzey33C2IfmNo3Z8XTCzPOZmiq81fiJ/
mDYaZ/HC324XZqQhuzzGsigE3C/ekkMwP6qYIOcqFZC3qEL2+cc0SQ7x8RiyIejj
627R1cmfGJw5GaZnfO/KE27R
=JgGp
-----END PGP SIGNATURE-----

pinheadmz's public key is on openpgp.org

ACK 148210fe99bb54583fd47f2c39bf0b9390161185 Clean refactor, technically a little granular unit test coverage lost from private-izing internal methods but it makes for cleaner classes. <details><summary>Show Signature</summary> ``` -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 ACK 148210fe99bb54583fd47f2c39bf0b9390161185 -----BEGIN PGP SIGNATURE----- iQJPBAEBCAA5FiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmriIDEbFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMCwzAAoJEOfimEtiick66N8QALEtD02xBq+MIOB5FIrj NyxK4JmDLwfYuCo2Qap6GYIRQrDHgsxPmZzpjwqcQg39PqNhTvfHB91qB8SvB4Uv OJoUyhhGwzWRj8GRzgJj5cbj+XazxGpYf9zQUSZbjXSmiX3wecOp7LdEjVpNzKxs va/qMjdTUqSfEcRY1vSuCfDCZYKMoioyXvYidOsuErHnwGkHWHpA8llV0L3jNqmz QNibmLF/fv5WANaIE5JuDQ6M4rfMa10zJ6QLsMRCTPF6BOWya5gXCY5XswiLh0CQ RMQIxTOyn6cBPaR8vw159cHfruv6XN6lZoeKjbF+u/DCRZz4j/k3DI8LyefKN4K7 IIC10Wqxp+0welsSn/sqk64A5tYCAzFr1a00vodJU/VjSQBn3lUh3sR4Mx+/LQLK jpOUSQg9maseCDoxC7aWjvFHhSpJsS8izALyLKT5bFb8vIpeuITo1x2bbciq91kP 3tIedAEGK8KfstNIz+Dk2GgCxZSUkziAKJvJ3uMFERQHRg7A9rI2DKU0VObA+ntn vdEocdYmvcy937SqumDhtfNvnjDE8guOBzey33C2IfmNo3Z8XTCzPOZmiq81fiJ/ mDYaZ/HC324XZqQhuzzGsigE3C/ekkMwP6qYIOcqFZC3qEL2+cc0SQ7x8RiyIejj 627R1cmfGJw5GaZnfO/KE27R =JgGp -----END PGP SIGNATURE----- ``` pinheadmz's public key is [on openpgp.org](https://keys.openpgp.org/vks/v1/by-fingerprint/E61773CD6E01040E2F1BD78CE7E2984B6289C93A) </details>
hodlinator (Migrated from github.com) reviewed 2026-10-28 19:51:14 +00:00
hodlinator (Migrated from github.com) commented 2026-10-28 19:51:14 +00:00

inline comment thread in response to @pinheadmz https://github.com/bitcoin/bitcoin/pull/36124#issuecomment-6474351472:

Found a couple of more groupings:

commit 94afe512f028f56510a1362ee447383fa7bfa88a (HEAD -> 2026/08/http_refactors)
Author: Hodlinator <[email protected]>
Date:   Wed Oct 28 20:29:07 2026 +0100

    doc: Add missing @name to activate grouping syntax

diff --git a/src/httpserver.h b/src/httpserver.h
index cff876abb8..b4c18e7bcb 100644
--- a/src/httpserver.h
+++ b/src/httpserver.h
@@ -132,6 +132,7 @@ private:
 
 struct HTTPVersion {
     /**
+     * @name Protocol version
      * Default HTTP protocol version 1.1 is used by error responses
      * when a request is unreadable.
      */
@@ -199,6 +200,7 @@ public:
 
 private:
     /**
+     * @name Request parsers
      * Methods that attempt to parse HTTP request fields line-by-line
      * from a receive buffer.
      * @returns     true    If the request field was parsed.
@@ -408,7 +410,8 @@ private:
      */
     std::thread m_thread_socket_handler;
 
-    /*
+    /**
+     * @name Request dispatch
      * What to do with HTTP requests once received, validated and parsed.
      * Set in main thread by server start and interrupt but read in
      * worker threads.
@@ -578,6 +581,7 @@ private:
     std::atomic_bool m_req_busy{false};
 
     /**
+     * @name Response data
      * Response data destined for this client.
      * Written to by http worker threads, read and erased by HTTPServer I/O thread
      */

Not entirely happy with how these fields are separated from the others, see screenshot:
Image

But if you agree I can push that commit on top.

inline comment thread in response to @pinheadmz https://github.com/bitcoin/bitcoin/pull/36124#issuecomment-6474351472: Found a couple of more groupings: ```diff commit 94afe512f028f56510a1362ee447383fa7bfa88a (HEAD -> 2026/08/http_refactors) Author: Hodlinator <172445034+[email protected]> Date: Wed Oct 28 20:29:07 2026 +0100 doc: Add missing @name to activate grouping syntax diff --git a/src/httpserver.h b/src/httpserver.h index cff876abb8..b4c18e7bcb 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -132,6 +132,7 @@ private: struct HTTPVersion { /** + * @name Protocol version * Default HTTP protocol version 1.1 is used by error responses * when a request is unreadable. */ @@ -199,6 +200,7 @@ public: private: /** + * @name Request parsers * Methods that attempt to parse HTTP request fields line-by-line * from a receive buffer. * @returns true If the request field was parsed. @@ -408,7 +410,8 @@ private: */ std::thread m_thread_socket_handler; - /* + /** + * @name Request dispatch * What to do with HTTP requests once received, validated and parsed. * Set in main thread by server start and interrupt but read in * worker threads. @@ -578,6 +581,7 @@ private: std::atomic_bool m_req_busy{false}; /** + * @name Response data * Response data destined for this client. * Written to by http worker threads, read and erased by HTTPServer I/O thread */ ``` Not entirely happy with how these fields are separated from the others, see screenshot: <img width="1308" height="1380" alt="Image" src="https://git.fish.foo/attachments/47da11e0-7b3a-4fb3-92f1-9633785cec42" /> But if you agree I can push that commit on top.
pinheadmz (Migrated from github.com) reviewed 2026-10-28 19:59:46 +00:00
pinheadmz (Migrated from github.com) commented 2026-10-28 19:59:46 +00:00

Too picky for me ;-) I think future devs are more likely to read the .cpp file than the doxygen html anyway so as long as it looks ok in the code, i'm good with it. Happy to re-ack if you decide to change it though.

Too picky for me ;-) I think future devs are more likely to read the .cpp file than the doxygen html anyway so as long as it looks ok in the code, i'm good with it. Happy to re-ack if you decide to change it though.
hodlinator (Migrated from github.com) reviewed 2026-10-29 07:32:28 +00:00
hodlinator (Migrated from github.com) commented 2026-10-29 07:32:28 +00:00

Since you offered to re-ACK, I pushed the change. People are bound to consume the comments more through code as you say, rather than through this specific doxygen layout, so it feels more complete for it to be correct.

Since you offered to re-ACK, I pushed the change. People are bound to consume the comments more through code as you say, rather than through this specific doxygen layout, so it feels more complete for it to be correct.
pinheadmz (Migrated from github.com) approved these changes 2026-10-29 13:47:10 +00:00
pinheadmz (Migrated from github.com) left a comment

ACK 6a5212fb97

Only doxygen changes since last review, thanks for cleaning that all up <3

Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

ACK 6a5212fb97c2c332fc3cb901f8e9a110622ef841
-----BEGIN PGP SIGNATURE-----

iQJPBAEBCAA5FiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmrjTjQbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMCwzAAoJEOfimEtiick61L0P/RiOzFWc2550oNsQJQUo
SjqcDQcfztHzPhhUopnoR7xTvC1JdBcMrBANnXJBE9ZIcKL12/sffpCcTZscwK+v
m4SYWsihpLnIxx1vnyaokJbIdqqWxZsl+fBg0CUpIIh85hOCMRmht7WWb/pJnhWs
BMsLwhpIoh4WgzU1ctWFqWlLGjfFLeskx2JjVPWSIlur+ThnN3MfcQi99LfKx9qi
E41sKPwnY1wOmEWMCilhuZy1uwqdvV/qElGGEjn55D2gi4j41uaxnqBS/nsuNaQi
V5jB/WJ9GiRCLByNqqKSEjlEciVdbR2XEbZ+SYSFw7oaIJQ+953QCR+sGvgAOCrm
BzLHGG0UF8ZuE9nRhGSBu0gwTV2welFx+hO75FqWZpYbOBv4/l8rjIjvYBECo/df
7wGepZBDUNgXJDCInBJmfnLin6VutvQL90sMegc7D/vPYNoIt+HjizvKmOTGlnT6
MKldDakZjILgh4PRoft4OG9qaiq7n6k8n0UuUzn8ZS5Cx97ODzs+Q38ZzSP1F0P3
ImRxPCfnZFIdIjJ1Amaqt/SYp0sW6iBgTcnPbQyKr83smvuHzPSQwTBVbRi/eozt
oiZfQJxFzrtXqP1xofNCue0fUVH7iUSMtnxNCVZfayGwnFc66v0V9IGezz24t3mA
pIS2YXrhHkwlhsp7BeqeBfpp
=rUPo
-----END PGP SIGNATURE-----

pinheadmz's public key is on openpgp.org

ACK 6a5212fb97c2c332fc3cb901f8e9a110622ef841 Only doxygen changes since last review, thanks for cleaning that all up <3 <details><summary>Show Signature</summary> ``` -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 ACK 6a5212fb97c2c332fc3cb901f8e9a110622ef841 -----BEGIN PGP SIGNATURE----- iQJPBAEBCAA5FiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmrjTjQbFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMCwzAAoJEOfimEtiick61L0P/RiOzFWc2550oNsQJQUo SjqcDQcfztHzPhhUopnoR7xTvC1JdBcMrBANnXJBE9ZIcKL12/sffpCcTZscwK+v m4SYWsihpLnIxx1vnyaokJbIdqqWxZsl+fBg0CUpIIh85hOCMRmht7WWb/pJnhWs BMsLwhpIoh4WgzU1ctWFqWlLGjfFLeskx2JjVPWSIlur+ThnN3MfcQi99LfKx9qi E41sKPwnY1wOmEWMCilhuZy1uwqdvV/qElGGEjn55D2gi4j41uaxnqBS/nsuNaQi V5jB/WJ9GiRCLByNqqKSEjlEciVdbR2XEbZ+SYSFw7oaIJQ+953QCR+sGvgAOCrm BzLHGG0UF8ZuE9nRhGSBu0gwTV2welFx+hO75FqWZpYbOBv4/l8rjIjvYBECo/df 7wGepZBDUNgXJDCInBJmfnLin6VutvQL90sMegc7D/vPYNoIt+HjizvKmOTGlnT6 MKldDakZjILgh4PRoft4OG9qaiq7n6k8n0UuUzn8ZS5Cx97ODzs+Q38ZzSP1F0P3 ImRxPCfnZFIdIjJ1Amaqt/SYp0sW6iBgTcnPbQyKr83smvuHzPSQwTBVbRi/eozt oiZfQJxFzrtXqP1xofNCue0fUVH7iUSMtnxNCVZfayGwnFc66v0V9IGezz24t3mA pIS2YXrhHkwlhsp7BeqeBfpp =rUPo -----END PGP SIGNATURE----- ``` pinheadmz's public key is [on openpgp.org](https://keys.openpgp.org/vks/v1/by-fingerprint/E61773CD6E01040E2F1BD78CE7E2984B6289C93A) </details>
winterrdog (Migrated from github.com) reviewed 2026-10-29 15:08:18 +00:00
winterrdog (Migrated from github.com) left a comment

Post-merge ACK 6a5212fb97

Post-merge ACK 6a5212fb97c2c332fc3cb901f8e9a110622ef841
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36124
No description provided.