From: Casey Bodley Date: Thu, 5 Jan 2023 16:30:03 +0000 (-0500) Subject: rgw/beast: fix interaction between keepalive and 100-continue X-Git-Tag: v17.2.6~85^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2018231ff42f9757a7d7e1c63e0e86ce97466765;p=ceph.git rgw/beast: fix interaction between keepalive and 100-continue if we reject a request with a "Expect: 100-continue" header before sending a "100 Continue" response, the keepalive logic should not try to read/discard request body before parsing the next request headers Fixes: https://tracker.ceph.com/issues/58286 Signed-off-by: Casey Bodley (cherry picked from commit 4358cf2a6a60d780791322f17cb216addd8ddae6) --- diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index d6001a67f16c..532ae0183d18 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -228,6 +228,8 @@ void handle_connection(boost::asio::io_context& context, return; } + bool expect_continue = (message[http::field::expect] == "100-continue"); + { auto lock = pause_mutex.async_lock_shared(yield[ec]); if (ec == boost::asio::error::operation_aborted) { @@ -283,6 +285,10 @@ void handle_connection(boost::asio::io_context& context, << log_header{message, http::field::range} << " latency=" << latency << dendl; } + + if (real_client.sent_100_continue()) { + expect_continue = false; + } } if (!parser.keep_alive()) { @@ -291,7 +297,7 @@ void handle_connection(boost::asio::io_context& context, // if we failed before reading the entire message, discard any remaining // bytes before reading the next - while (!parser.is_done()) { + while (!expect_continue && !parser.is_done()) { static std::array discard_buffer; auto& body = parser.get().body();