Refactor file_body for best practices

This commit is contained in:
Vinnie Falco
2017-07-20 08:15:29 -07:00
parent 56948edd27
commit 09df24ec62
5 changed files with 195 additions and 130 deletions
+9 -3
View File
@@ -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);
}
{