mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Update to Beast 1.0.0-b34:
Merge commit 'd8dea963fa5dc26b4be699ce6d4bf699a429ca92' into develop
This commit is contained in:
@@ -15,6 +15,8 @@ add_executable (http-crawl
|
||||
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(http-crawl ${Boost_LIBRARIES} Threads::Threads)
|
||||
else()
|
||||
target_link_libraries(http-crawl ${Boost_LIBRARIES})
|
||||
endif()
|
||||
|
||||
add_executable (http-server
|
||||
@@ -29,8 +31,11 @@ add_executable (http-server
|
||||
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(http-server ${Boost_LIBRARIES} Threads::Threads)
|
||||
else()
|
||||
target_link_libraries(http-server ${Boost_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
add_executable (http-example
|
||||
${BEAST_INCLUDES}
|
||||
${EXTRAS_INCLUDES}
|
||||
@@ -39,8 +44,11 @@ add_executable (http-example
|
||||
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(http-example ${Boost_LIBRARIES} Threads::Threads)
|
||||
else()
|
||||
target_link_libraries(http-example ${Boost_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
add_executable (websocket-echo
|
||||
${BEAST_INCLUDES}
|
||||
websocket_async_echo_server.hpp
|
||||
@@ -50,8 +58,11 @@ add_executable (websocket-echo
|
||||
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(websocket-echo ${Boost_LIBRARIES} Threads::Threads)
|
||||
else()
|
||||
target_link_libraries(websocket-echo ${Boost_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
add_executable (websocket-example
|
||||
${BEAST_INCLUDES}
|
||||
${EXTRAS_INCLUDES}
|
||||
@@ -60,4 +71,6 @@ add_executable (websocket-example
|
||||
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(websocket-example ${Boost_LIBRARIES} Threads::Threads)
|
||||
else()
|
||||
target_link_libraries(websocket-example ${Boost_LIBRARIES})
|
||||
endif()
|
||||
|
||||
@@ -10,10 +10,9 @@
|
||||
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/resume_context.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/logic/tribool.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -38,7 +37,8 @@ struct file_body
|
||||
writer& operator=(writer const&) = delete;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
writer(message<isRequest, file_body, Fields> const& m) noexcept
|
||||
writer(message<isRequest,
|
||||
file_body, Fields> const& m) noexcept
|
||||
: path_(m.body)
|
||||
{
|
||||
}
|
||||
@@ -54,8 +54,8 @@ struct file_body
|
||||
{
|
||||
file_ = fopen(path_.c_str(), "rb");
|
||||
if(! file_)
|
||||
ec = boost::system::errc::make_error_code(
|
||||
static_cast<boost::system::errc::errc_t>(errno));
|
||||
ec = error_code{errno,
|
||||
system_category()};
|
||||
else
|
||||
size_ = boost::filesystem::file_size(path_);
|
||||
}
|
||||
@@ -67,19 +67,25 @@ struct file_body
|
||||
}
|
||||
|
||||
template<class WriteFunction>
|
||||
boost::tribool
|
||||
write(resume_context&&, error_code&,
|
||||
WriteFunction&& wf) noexcept
|
||||
bool
|
||||
write(error_code& ec, WriteFunction&& wf) noexcept
|
||||
{
|
||||
if(size_ - offset_ < sizeof(buf_))
|
||||
buf_len_ = static_cast<std::size_t>(
|
||||
size_ - offset_);
|
||||
else
|
||||
buf_len_ = sizeof(buf_);
|
||||
auto const nread = fread(buf_, 1, sizeof(buf_), file_);
|
||||
(void)nread;
|
||||
offset_ += buf_len_;
|
||||
wf(boost::asio::buffer(buf_, buf_len_));
|
||||
auto const nread = fread(
|
||||
buf_, 1, sizeof(buf_), file_);
|
||||
if(ferror(file_))
|
||||
{
|
||||
ec = error_code(errno,
|
||||
system_category());
|
||||
return true;
|
||||
}
|
||||
BOOST_ASSERT(nread != 0);
|
||||
offset_ += nread;
|
||||
wf(boost::asio::buffer(buf_, nread));
|
||||
return offset_ >= size_;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user