forked from boostorg/beast
Refactor file_body for best practices
This commit is contained in:
@@ -311,18 +311,24 @@ public:
|
||||
BEAST_EXPECTS(p0.get().method() == verb::put,
|
||||
p0.get().method_string());
|
||||
{
|
||||
error_code ec;
|
||||
request_parser<file_body> p{std::move(p0)};
|
||||
p.get().body = path;
|
||||
p.get().body.open(path, "wb", ec);
|
||||
if(ec)
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
read(c.server, b, p);
|
||||
}
|
||||
}
|
||||
{
|
||||
error_code ec;
|
||||
response<file_body> res;
|
||||
res.version = 11;
|
||||
res.result(status::ok);
|
||||
res.insert(field::server, "test");
|
||||
res.body = path;
|
||||
res.prepare_payload();
|
||||
res.body.open(path, "rb", ec);
|
||||
if(ec)
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
res.set(field::content_length, res.body.size());
|
||||
write(c.server, res);
|
||||
}
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user