Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
881d4b6
test: cover common HTTP attacks and common malformed requests
pinheadmz Apr 30, 2026
0cdbb19
util/string: use string_view in LineReader
pinheadmz May 19, 2026
5aa3629
util/string: LineReader should only trim \r or \r\n
pinheadmz May 8, 2026
89c54ae
http: enclose libevent-dependent code in a namespace
pinheadmz Sep 30, 2024
68b5d28
http: Implement HTTPHeaders class
pinheadmz Sep 30, 2024
ad50aa4
http: Implement HTTPResponse class
pinheadmz Oct 16, 2024
9463e98
http: Implement HTTPRequest class
pinheadmz Oct 16, 2024
f5bc018
http: Introduce HTTPServer class and implement binding to listening s…
pinheadmz Jun 4, 2025
5a3aa1a
HTTPServer: implement and test AcceptConnection()
pinheadmz Jun 4, 2025
a85286c
HTTPServer: generate sequential Ids for each newly accepted connection
pinheadmz Jun 4, 2025
4ef4ebd
http: Introduce HTTPRemoteClient class
pinheadmz Nov 19, 2025
3c5226a
HTTPServer: start an I/O loop in a new thread and accept connections
pinheadmz Jun 12, 2025
80e1cfe
HTTPServer: read requests from connected clients
pinheadmz Oct 31, 2024
6734bcd
HTTPserver: support "chunked" Transfer-Encoding
pinheadmz Mar 12, 2025
cdf7199
HTTPServer: compose and send replies to connected clients
pinheadmz Dec 11, 2024
a69bb9e
HTTPServer: disconnect clients
pinheadmz Mar 3, 2025
5ef1b80
Allow http workers to send data optimistically as an optimization
pinheadmz Mar 1, 2025
7ee7df9
HTTPServer: use a queue to pipeline requests from each connected client
pinheadmz Apr 3, 2025
dd11b5e
define HTTP request methods at module level outside of class
pinheadmz Dec 11, 2024
f946ff5
Add helper methods to HTTPRequest to match original API
pinheadmz Dec 12, 2024
fec6b6b
refactor: split http_request_cb into libevent callback and dispatch
pinheadmz Dec 12, 2024
2ca645c
refactor: split HTTPBindAddresses into config parse and libevent setup
pinheadmz Jan 15, 2025
e5f242e
HTTPServer: implement control methods to match legacy API
pinheadmz Jan 15, 2025
cbb8d1f
HTTPServer: disconnect after idle timeout (-rpcservertimeout)
pinheadmz Mar 10, 2025
21c7542
http: switch servers from libevent to bitcoin
pinheadmz Jan 15, 2025
e427c22
fuzz: switch http_libevent::HTTPRequest to http_bitcoin::HTTPRequest
pinheadmz Mar 18, 2025
8c1eea0
http: remove libevent usage from this subsystem
pinheadmz Mar 13, 2025
39e9099
logging: deprecate libevent category
pinheadmz Apr 28, 2026
61020b3
doc: add release note for #35182 replace libevent HTTP server
pinheadmz May 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ and its `cs_KeyStore` lock for example).
: Parallel script validation threads for transactions in blocks.

- [ThreadHTTP (`b-http`)](https://doxygen.bitcoincore.org/httpserver_8cpp.html#http)
: Libevent thread to listen for RPC and REST connections.
: Thread to listen for RPC and REST connections.

- [HTTP worker threads (`b-http.xx`)](https://doxygen.bitcoincore.org/httpserver_8cpp.html#http_pool)
: Threads to service RPC and REST requests.
Expand All @@ -716,7 +716,7 @@ and its `cs_KeyStore` lock for example).
addrman and running asynchronous validationinterface callbacks.

- [TorControlThread (`b-torcontrol`)](https://doxygen.bitcoincore.org/class_tor_controller.html#torcontrol)
: Libevent thread for tor connections.
: Thread for tor connections.

- Net threads:

Expand Down
16 changes: 16 additions & 0 deletions doc/release-notes-35182.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
HTTP: RPC / REST
----------------

The HTTP server has been rewritten from scratch to replace libevent. (#35182)

`libevent` has been deprecated as a logging category and will be removed in
a future release. At that time configurations like `debugexclude=libevent` will
be invalid.

Certain HTTP edge cases will observe different behavior to be more RFC-compliant:

- Stricter enforcement of maximum headers size (8192 bytes)
- Reject requests with whitespace in header field-names
- "Line Folding" is rejected (whitespace at start of a header line)
- Tolerate `%` at the end of requested URLs
- Multiple "Content-Length" headers with different values are rejected
6 changes: 3 additions & 3 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void HTTPResponseHeaders::Read(util::LineReader& reader)
// Headers https://httpwg.org/specs/rfc9110.html#rfc.section.6.3
// A sequence of Field Lines https://httpwg.org/specs/rfc9110.html#rfc.section.5.2
while (auto maybe_line = reader.ReadLine()) {
const std::string& line = *maybe_line;
const std::string_view line = *maybe_line;

// An empty line indicates end of the headers section https://www.rfc-editor.org/rfc/rfc2616#section-4
if (line.empty()) return;
Expand Down Expand Up @@ -965,7 +965,7 @@ HTTPResponse HTTPClient::ReadResponse()
throw HTTPError{"Failed to read status line"};
}

const std::string& status_str = *status_line;
const std::string_view status_str = *status_line;
// Minimum status line is "HTTP/X.Y NNN" (e.g. "HTTP/1.1 200"), 12 characters.
if (status_str.size() < 12 || !status_str.starts_with("HTTP/")) {
throw HTTPError{"Invalid status line"};
Expand All @@ -976,7 +976,7 @@ HTTPResponse HTTPClient::ReadResponse()
throw HTTPError{"Invalid status line format"};
}

std::string status_code_str = status_str.substr(space1 + 1, 3);
const std::string_view status_code_str = status_str.substr(space1 + 1, 3);
auto status_code = ToIntegral<int>(status_code_str);
if (!status_code) {
throw HTTPError{"Invalid status code"};
Expand Down
5 changes: 2 additions & 3 deletions src/httprpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <string>
#include <vector>

using http_bitcoin::HTTPRequest;
using util::SplitString;
using util::TrimStringView;

Expand Down Expand Up @@ -196,7 +197,7 @@ UniValue ExecuteHTTPRPC(const UniValue& valRequest, JSONRPCRequest& jreq, HTTPSt
static void HTTPReq_JSONRPC(const std::any& context, HTTPRequest* req)
{
// JSONRPC handles only POST
if (req->GetRequestMethod() != HTTPRequest::POST) {
if (req->GetRequestMethod() != HTTPRequestMethod::POST) {
req->WriteReply(HTTP_BAD_METHOD, "JSONRPC server handles only POST requests");
return;
}
Expand Down Expand Up @@ -347,8 +348,6 @@ bool StartHTTPRPC(const std::any& context)
if (g_wallet_init_interface.HasWalletSupport()) {
RegisterHTTPHandler("/wallet/", false, handle_rpc);
}
struct event_base* eventBase = EventBase();
assert(eventBase);
return true;
}

Expand Down
Loading
Loading