Skip to content

Commit fc56858

Browse files
committed
route_params::send is in Boost.Http
1 parent 0ea6d15 commit fc56858

File tree

1 file changed

+0
-51
lines changed

1 file changed

+0
-51
lines changed

include/boost/beast2/server/route_handler_corosio.hpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -41,57 +41,6 @@ class corosio_route_params
4141
{
4242
}
4343

44-
http::route_task
45-
send(std::string_view body) override
46-
{
47-
// Auto-detect Content-Type if not already set
48-
if(! res.exists(http::field::content_type))
49-
{
50-
if(! body.empty() && body[0] == '<')
51-
res.set(http::field::content_type,
52-
"text/html; charset=utf-8");
53-
else
54-
res.set(http::field::content_type,
55-
"text/plain; charset=utf-8");
56-
}
57-
58-
// Set Content-Length if not already set
59-
if(! res.exists(http::field::content_length))
60-
res.set_payload_size(body.size());
61-
62-
// Start the serializer with the response and body
63-
serializer.start(res,
64-
http::string_body(std::string(body)));
65-
66-
// Write the response to the socket
67-
while(! serializer.is_done())
68-
{
69-
auto rv = serializer.prepare();
70-
if(! rv)
71-
co_return rv.error();
72-
73-
auto bufs = *rv;
74-
75-
// Write all buffers
76-
for(auto const& buf : bufs)
77-
{
78-
auto [ec, n] = co_await stream.write_some(
79-
capy::const_buffer(buf.data(), buf.size()));
80-
if(ec)
81-
co_return ec;
82-
}
83-
84-
// Calculate total size written
85-
std::size_t written = 0;
86-
for(auto const& buf : bufs)
87-
written += buf.size();
88-
89-
serializer.consume(written);
90-
}
91-
92-
co_return {};
93-
}
94-
9544
http::route_task
9645
end() override
9746
{

0 commit comments

Comments
 (0)