20 #ifndef RIPPLE_SERVER_PLAINHTTPPEER_H_INCLUDED
21 #define RIPPLE_SERVER_PLAINHTTPPEER_H_INCLUDED
23 #include <ripple/beast/rfc2616.h>
24 #include <ripple/server/impl/BaseHTTPPeer.h>
25 #include <ripple/server/impl/PlainWSPeer.h>
26 #include <boost/beast/core/tcp_stream.hpp>
31 template <
class Handler>
46 template <
class ConstBufferSequence>
50 boost::asio::io_context& ioc,
53 ConstBufferSequence
const& buffers,
72 template <
class Handler>
73 template <
class ConstBufferSequence>
77 boost::asio::io_context& ioc,
80 ConstBufferSequence
const& buffers,
89 , stream_(
std::move(stream))
90 , socket_(stream_.socket())
96 if (remote_endpoint.address().is_loopback())
97 socket_.set_option(boost::asio::ip::tcp::no_delay{
true});
100 template <
class Handler>
104 if (!this->handler_.onAccept(this->session(), this->remote_address_))
112 if (!socket_.is_open())
119 this->shared_from_this(),
120 std::placeholders::_1));
123 template <
class Handler>
127 auto ws = this->ios().template emplace<PlainWSPeer<Handler>>(
130 this->remote_address_,
131 std::move(this->message_),
137 template <
class Handler>
141 ++this->request_count_;
142 auto const what = this->handler_.onHandoff(
143 this->session(), std::move(this->message_), this->remote_address_);
146 boost::system::error_code ec;
150 if (!what.keep_alive)
151 socket_.shutdown(socket_type::shutdown_receive, ec);
153 return this->fail(ec,
"request");
154 return this->write(what.response, what.keep_alive);
159 socket_.shutdown(socket_type::shutdown_receive, ec);
161 return this->fail(ec,
"request");
163 this->handler_.onRequest(this->session());
166 template <
class Handler>
170 boost::system::error_code ec;
171 socket_.shutdown(socket_type::shutdown_send, ec);