file_body buffer size can be configured.

This commit is contained in:
Klemens
2022-12-17 16:12:31 +08:00
committed by Klemens Morgenstern
parent 99bceb5bff
commit 4ff4c79d5b
4 changed files with 17 additions and 6 deletions

View File

@@ -35,6 +35,13 @@ failure to do so may result in violations of ODR (One Definition Rule).
Enables the use of deprecated APIs within Beast.
]
]
[
[
BOOST_BEAST_FILE_BUFFER_SIZE
][
Sets the small buffer size for the file_body. Defaults to 4096.
]
]
]
[endsect]

View File

@@ -113,4 +113,8 @@ namespace net = boost::asio;
#endif
#ifndef BOOST_BEAST_FILE_BUFFER_SIZE
#define BOOST_BEAST_FILE_BUFFER_SIZE 4096
#endif
#endif

View File

@@ -234,9 +234,9 @@ size(value_type const& body)
template<class File>
class basic_file_body<File>::writer
{
value_type& body_; // The body we are reading from
std::uint64_t remain_; // The number of unread bytes
char buf_[4096]; // Small buffer for reading
value_type& body_; // The body we are reading from
std::uint64_t remain_; // The number of unread bytes
char buf_[BOOST_BEAST_FILE_BUFFER_SIZE]; // Small buffer for reading
public:
// The type of buffer sequence returned by `get`.

View File

@@ -124,9 +124,9 @@ struct basic_file_body<file_win32>
basic_file_body<file_win32>, Fields>& sr,
error_code& ec);
value_type& body_; // The body we are reading from
std::uint64_t pos_; // The current position in the file
char buf_[4096]; // Small buffer for reading
value_type& body_; // The body we are reading from
std::uint64_t pos_; // The current position in the file
char buf_[BOOST_BEAST_FILE_BUFFER_SIZE]; // Small buffer for reading
public:
using const_buffers_type =