From 4f2bcfdf53b157a73700d33100000964e7b29946 Mon Sep 17 00:00:00 2001 From: canepat <16927169+canepat@users.noreply.github.com> Date: Mon, 25 Mar 2024 11:07:03 +0100 Subject: [PATCH] rpc: override max HTTP request body limit --- silkworm/rpc/http/connection.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/silkworm/rpc/http/connection.cpp b/silkworm/rpc/http/connection.cpp index dc33c6125b..cf27f922de 100644 --- a/silkworm/rpc/http/connection.cpp +++ b/silkworm/rpc/http/connection.cpp @@ -88,9 +88,10 @@ Task Connection::do_read() { SILK_TRACE << "Connection::do_read going to read..."; boost::beast::http::request_parser 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; @@ -185,14 +186,11 @@ Task Connection::handle_actual_request(const boost::beast::http::request 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);