From 66b73866f8b3aa92c894b1f9f53012ae8504d7ad Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Wed, 12 Oct 2022 22:01:40 +0200 Subject: [PATCH] Fix bug with large HTTP requests in osrm-routed --- CHANGELOG.md | 2 ++ src/server/connection.cpp | 17 ++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 638bec2d7..8c9fb36d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased - Changes from 5.27.0 + - Misc: + - FIXED: Fix bug with large HTTP requests leading to Bad Request in osrm-routed. [#6403](https://github.com/Project-OSRM/osrm-backend/pull/6403) - Routing: - CHANGED: Add support for surface=metal,grass_paver,woodchips in bicyle profile. [#6395](https://github.com/Project-OSRM/osrm-backend/pull/6395) diff --git a/src/server/connection.cpp b/src/server/connection.cpp index 5c6ca0cad..b6e8c7935 100644 --- a/src/server/connection.cpp +++ b/src/server/connection.cpp @@ -12,7 +12,8 @@ namespace osrm namespace server { -namespace { +namespace +{ const size_t CHUNK_SIZE = 8192; } // namespace @@ -64,7 +65,8 @@ void Connection::start() } } -void Connection::handle_read(const boost::system::error_code &error, std::size_t /*bytes_transferred*/) +void Connection::handle_read(const boost::system::error_code &error, + std::size_t /*bytes_transferred*/) { if (error) { @@ -95,11 +97,12 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t const auto current_size = incoming_data_buffer.size(); incoming_data_buffer.resize(incoming_data_buffer.size() + CHUNK_SIZE); // we don't have a result yet, so continue reading - TCP_socket.async_read_some(boost::asio::buffer(incoming_data_buffer.data() + current_size, CHUNK_SIZE), - boost::bind(&Connection::handle_read, - this->shared_from_this(), - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); + TCP_socket.async_read_some( + boost::asio::buffer(incoming_data_buffer.data() + current_size, CHUNK_SIZE), + boost::bind(&Connection::handle_read, + this->shared_from_this(), + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); } else {