Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcdaemon: increase max HTTP request body limit #1934

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
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
10 changes: 4 additions & 6 deletions silkworm/rpc/http/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ Task<bool> Connection::do_read() {
SILK_TRACE << "Connection::do_read going to read...";

boost::beast::http::request_parser<boost::beast::http::string_body> parser;
auto bytes_transferred = co_await boost::beast::http::async_read(socket_, data_, parser, boost::asio::use_awaitable);
parser.body_limit(kMaxPayloadSize);

SILK_TRACE << "Connection::do_read bytes_read: " << bytes_transferred << " [" << parser.get() << "]";
const auto bytes_transferred = co_await boost::beast::http::async_read(socket_, data_, parser, boost::asio::use_awaitable);
SILK_TRACE << "Connection::do_read bytes_read: " << bytes_transferred << " message: " << parser.get();

if (!parser.is_done()) {
co_return true;
Expand Down Expand Up @@ -185,14 +186,11 @@ Task<void> Connection::handle_actual_request(const boost::beast::http::request<b
co_return;
}

// Check HTTP method and content type [max body size is limited using beast::http::request_parser::body_limit in do_read]
if (!is_method_allowed(req.method())) {
co_await do_write("method not allowed\n", boost::beast::http::status::method_not_allowed);
co_return;
}
if (req.has_content_length() && req.body().length() > kMaxPayloadSize) {
co_await do_write("content length too large\n", boost::beast::http::status::payload_too_large);
co_return;
}
if (req.method() != boost::beast::http::verb::options && req.method() != boost::beast::http::verb::get) {
if (!is_accepted_content_type(req[boost::beast::http::field::content_type])) {
co_await do_write("invalid content type\n, only application/json is supported\n", boost::beast::http::status::bad_request);
Expand Down
Loading