Fix bug with large HTTP requests in osrm-routed

This commit is contained in:
Siarhei Fedartsou 2022-10-12 22:01:40 +02:00
parent 16b8a58fe0
commit 66b73866f8
2 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,7 @@
# Unreleased # Unreleased
- Changes from 5.27.0 - 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: - Routing:
- CHANGED: Add support for surface=metal,grass_paver,woodchips in bicyle profile. [#6395](https://github.com/Project-OSRM/osrm-backend/pull/6395) - CHANGED: Add support for surface=metal,grass_paver,woodchips in bicyle profile. [#6395](https://github.com/Project-OSRM/osrm-backend/pull/6395)

View File

@ -12,7 +12,8 @@ namespace osrm
namespace server namespace server
{ {
namespace { namespace
{
const size_t CHUNK_SIZE = 8192; const size_t CHUNK_SIZE = 8192;
} // namespace } // 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) if (error)
{ {
@ -95,7 +97,8 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t
const auto current_size = incoming_data_buffer.size(); const auto current_size = incoming_data_buffer.size();
incoming_data_buffer.resize(incoming_data_buffer.size() + CHUNK_SIZE); incoming_data_buffer.resize(incoming_data_buffer.size() + CHUNK_SIZE);
// we don't have a result yet, so continue reading // 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), TCP_socket.async_read_some(
boost::asio::buffer(incoming_data_buffer.data() + current_size, CHUNK_SIZE),
boost::bind(&Connection::handle_read, boost::bind(&Connection::handle_read,
this->shared_from_this(), this->shared_from_this(),
boost::asio::placeholders::error, boost::asio::placeholders::error,