mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Update for Beast changes
This commit is contained in:
@@ -221,7 +221,7 @@ ConnectAttempt::onHandshake (error_code ec)
|
||||
overlay_.setup().public_ip,
|
||||
beast::IPAddressConversion::from_asio(remote_endpoint_),
|
||||
app_);
|
||||
appendHello (req_.headers, hello);
|
||||
appendHello (req_.fields, hello);
|
||||
|
||||
setTimer();
|
||||
beast::http::async_write(stream_, req_,
|
||||
@@ -293,12 +293,12 @@ ConnectAttempt::makeRequest (bool crawl,
|
||||
m.method = "GET";
|
||||
m.url = "/";
|
||||
m.version = 11;
|
||||
m.headers.insert ("User-Agent", BuildInfo::getFullVersionString());
|
||||
m.headers.insert ("Upgrade", "RTXP/1.2");
|
||||
m.fields.insert ("User-Agent", BuildInfo::getFullVersionString());
|
||||
m.fields.insert ("Upgrade", "RTXP/1.2");
|
||||
//std::string("RTXP/") + to_string (BuildInfo::getCurrentProtocol()));
|
||||
m.headers.insert ("Connection", "Upgrade");
|
||||
m.headers.insert ("Connect-As", "Peer");
|
||||
m.headers.insert ("Crawl", crawl ? "public" : "private");
|
||||
m.fields.insert ("Connection", "Upgrade");
|
||||
m.fields.insert ("Connect-As", "Peer");
|
||||
m.fields.insert ("Crawl", crawl ? "public" : "private");
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ ConnectAttempt::processResponse()
|
||||
return close();
|
||||
}
|
||||
|
||||
auto hello = parseHello (false, response_.headers, journal_);
|
||||
auto hello = parseHello (false, response_.fields, journal_);
|
||||
if(! hello)
|
||||
return fail("processResponse: Bad TMHello");
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <ripple/beast/utility/WrappedSink.h>
|
||||
#include <beast/core/placeholders.hpp>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
#include <beast/http/message_v1.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/empty_body.hpp>
|
||||
#include <beast/http/parser_v1.hpp>
|
||||
#include <boost/asio/basic_waitable_timer.hpp>
|
||||
@@ -56,10 +56,10 @@ private:
|
||||
using endpoint_type = boost::asio::ip::tcp::endpoint;
|
||||
|
||||
using request_type =
|
||||
beast::http::request_v1<beast::http::empty_body>;
|
||||
beast::http::request<beast::http::empty_body>;
|
||||
|
||||
using response_type =
|
||||
beast::http::response_v1<beast::http::streambuf_body>;
|
||||
beast::http::response<beast::http::streambuf_body>;
|
||||
|
||||
Application& app_;
|
||||
std::uint32_t const id_;
|
||||
|
||||
@@ -219,7 +219,7 @@ OverlayImpl::onHandoff (std::unique_ptr <beast::asio::ssl_bundle>&& ssl_bundle,
|
||||
|
||||
{
|
||||
auto const types = beast::rfc2616::split_commas(
|
||||
request.headers["Connect-As"]);
|
||||
request.fields["Connect-As"]);
|
||||
if (std::find_if(types.begin(), types.end(),
|
||||
[](std::string const& s)
|
||||
{
|
||||
@@ -234,7 +234,7 @@ OverlayImpl::onHandoff (std::unique_ptr <beast::asio::ssl_bundle>&& ssl_bundle,
|
||||
}
|
||||
}
|
||||
|
||||
auto hello = parseHello (true, request.headers, journal);
|
||||
auto hello = parseHello (true, request.fields, journal);
|
||||
if(! hello)
|
||||
{
|
||||
m_peerFinder->on_closed(slot);
|
||||
@@ -319,7 +319,7 @@ OverlayImpl::isPeerUpgrade(http_request_type const& request)
|
||||
if (! is_upgrade(request))
|
||||
return false;
|
||||
auto const versions = parse_ProtocolVersions(
|
||||
request.headers["Upgrade"]);
|
||||
request.fields["Upgrade"]);
|
||||
if (versions.size() == 0)
|
||||
return false;
|
||||
return true;
|
||||
@@ -333,7 +333,7 @@ OverlayImpl::isPeerUpgrade(http_response_type const& response)
|
||||
if(response.status != 101)
|
||||
return false;
|
||||
auto const versions = parse_ProtocolVersions(
|
||||
response.headers["Upgrade"]);
|
||||
response.fields["Upgrade"]);
|
||||
if (versions.size() == 0)
|
||||
return false;
|
||||
return true;
|
||||
@@ -351,13 +351,13 @@ std::shared_ptr<Writer>
|
||||
OverlayImpl::makeRedirectResponse (PeerFinder::Slot::ptr const& slot,
|
||||
http_request_type const& request, address_type remote_address)
|
||||
{
|
||||
beast::http::response_v1<json_body> msg;
|
||||
beast::http::response<json_body> msg;
|
||||
msg.version = request.version;
|
||||
msg.status = 503;
|
||||
msg.reason = "Service Unavailable";
|
||||
msg.headers.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.headers.insert("Remote-Address", remote_address.to_string());
|
||||
msg.headers.insert("Content-Type", "application/json");
|
||||
msg.fields.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.fields.insert("Remote-Address", remote_address.to_string());
|
||||
msg.fields.insert("Content-Type", "application/json");
|
||||
msg.body = Json::objectValue;
|
||||
{
|
||||
auto const result = m_peerFinder->redirect(slot);
|
||||
@@ -375,12 +375,12 @@ OverlayImpl::makeErrorResponse (PeerFinder::Slot::ptr const& slot,
|
||||
address_type remote_address,
|
||||
std::string text)
|
||||
{
|
||||
beast::http::response_v1<beast::http::string_body> msg;
|
||||
beast::http::response<beast::http::string_body> msg;
|
||||
msg.version = request.version;
|
||||
msg.status = 400;
|
||||
msg.reason = "Bad Request";
|
||||
msg.headers.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.headers.insert("Remote-Address", remote_address.to_string());
|
||||
msg.fields.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.fields.insert("Remote-Address", remote_address.to_string());
|
||||
msg.body = text;
|
||||
prepare(msg, beast::http::connection::close);
|
||||
return std::make_shared<SimpleWriter>(msg);
|
||||
@@ -873,12 +873,12 @@ OverlayImpl::processRequest (http_request_type const& req,
|
||||
if (req.url != "/crawl")
|
||||
return false;
|
||||
|
||||
beast::http::response_v1<json_body> msg;
|
||||
beast::http::response<json_body> msg;
|
||||
msg.version = req.version;
|
||||
msg.status = 200;
|
||||
msg.reason = "OK";
|
||||
msg.headers.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.headers.insert("Content-Type", "application/json");
|
||||
msg.fields.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.fields.insert("Content-Type", "application/json");
|
||||
msg.body["overlay"] = crawl();
|
||||
prepare(msg, beast::http::connection::close);
|
||||
handoff.response = std::make_shared<SimpleWriter>(msg);
|
||||
|
||||
@@ -91,7 +91,7 @@ PeerImp::PeerImp (Application& app, id_t id, endpoint_type remote_endpoint,
|
||||
, fee_ (Resource::feeLightPeer)
|
||||
, slot_ (slot)
|
||||
, request_(std::move(request))
|
||||
, headers_(request_.headers)
|
||||
, headers_(request_.fields)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -652,14 +652,14 @@ PeerImp::makeResponse (bool crawl,
|
||||
resp.status = 101;
|
||||
resp.reason = "Switching Protocols";
|
||||
resp.version = req.version;
|
||||
resp.headers.insert("Connection", "Upgrade");
|
||||
resp.headers.insert("Upgrade", "RTXP/1.2");
|
||||
resp.headers.insert("Connect-AS", "Peer");
|
||||
resp.headers.insert("Server", BuildInfo::getFullVersionString());
|
||||
resp.headers.insert("Crawl", crawl ? "public" : "private");
|
||||
resp.fields.insert("Connection", "Upgrade");
|
||||
resp.fields.insert("Upgrade", "RTXP/1.2");
|
||||
resp.fields.insert("Connect-AS", "Peer");
|
||||
resp.fields.insert("Server", BuildInfo::getFullVersionString());
|
||||
resp.fields.insert("Crawl", crawl ? "public" : "private");
|
||||
protocol::TMHello hello = buildHello(sharedValue,
|
||||
overlay_.setup().public_ip, remote, app_);
|
||||
appendHello(resp.headers, hello);
|
||||
appendHello(resp.fields, hello);
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ private:
|
||||
beast::streambuf read_buffer_;
|
||||
http_request_type request_;
|
||||
http_response_type response_;
|
||||
beast::http::headers const& headers_;
|
||||
beast::http::fields const& headers_;
|
||||
beast::streambuf write_buffer_;
|
||||
std::queue<Message::pointer> send_queue_;
|
||||
bool gracefulClose_ = false;
|
||||
@@ -502,7 +502,7 @@ PeerImp::PeerImp (Application& app, std::unique_ptr<beast::asio::ssl_bundle>&& s
|
||||
, fee_ (Resource::feeLightPeer)
|
||||
, slot_ (std::move(slot))
|
||||
, response_(std::move(response))
|
||||
, headers_(response_.headers)
|
||||
, headers_(response_.fields)
|
||||
{
|
||||
read_buffer_.commit (boost::asio::buffer_copy(read_buffer_.prepare(
|
||||
boost::asio::buffer_size(buffers)), buffers));
|
||||
|
||||
@@ -154,7 +154,7 @@ buildHello (
|
||||
}
|
||||
|
||||
void
|
||||
appendHello (beast::http::headers& h,
|
||||
appendHello (beast::http::fields& h,
|
||||
protocol::TMHello const& hello)
|
||||
{
|
||||
//h.append ("Protocol-Versions",...
|
||||
@@ -222,7 +222,7 @@ parse_ProtocolVersions(boost::string_ref const& value)
|
||||
}
|
||||
|
||||
boost::optional<protocol::TMHello>
|
||||
parseHello (bool request, beast::http::headers const& h, beast::Journal journal)
|
||||
parseHello (bool request, beast::http::fields const& h, beast::Journal journal)
|
||||
{
|
||||
// protocol version in TMHello is obsolete,
|
||||
// it is supplanted by the values in the headers.
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <ripple/protocol/BuildInfo.h>
|
||||
#include <ripple/protocol/PublicKey.h>
|
||||
#include <ripple/protocol/UintTypes.h>
|
||||
#include <beast/http/headers.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <ripple/beast/utility/Journal.h>
|
||||
#include <utility>
|
||||
@@ -59,14 +58,14 @@ buildHello (uint256 const& sharedValue,
|
||||
|
||||
/** Insert HTTP headers based on the TMHello protocol message. */
|
||||
void
|
||||
appendHello (beast::http::headers& h, protocol::TMHello const& hello);
|
||||
appendHello (beast::http::fields& h, protocol::TMHello const& hello);
|
||||
|
||||
/** Parse HTTP headers into TMHello protocol message.
|
||||
@return A protocol message on success; an empty optional
|
||||
if the parsing failed.
|
||||
*/
|
||||
boost::optional<protocol::TMHello>
|
||||
parseHello (bool request, beast::http::headers const& h, beast::Journal journal);
|
||||
parseHello (bool request, beast::http::fields const& h, beast::Journal journal);
|
||||
|
||||
/** Validate and store the public key in the TMHello.
|
||||
This includes signature verification on the shared value.
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <ripple/server/SimpleWriter.h>
|
||||
#include <beast/core/detail/base64.hpp>
|
||||
#include <beast/http/headers.hpp>
|
||||
#include <beast/http/fields.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
@@ -61,7 +61,7 @@ isWebsocketUpgrade(
|
||||
{
|
||||
if (is_upgrade(request))
|
||||
return beast::detail::ci_equal(
|
||||
request.headers["Upgrade"], "websocket");
|
||||
request.fields["Upgrade"], "websocket");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -81,19 +81,19 @@ unauthorizedResponse(
|
||||
{
|
||||
using namespace beast::http;
|
||||
Handoff handoff;
|
||||
response_v1<string_body> msg;
|
||||
response<string_body> msg;
|
||||
msg.version = request.version;
|
||||
msg.status = 401;
|
||||
msg.reason = "Unauthorized";
|
||||
msg.headers.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.headers.insert("Content-Type", "text/html");
|
||||
msg.fields.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.fields.insert("Content-Type", "text/html");
|
||||
msg.body = "Invalid protocol.";
|
||||
prepare(msg, beast::http::connection::close);
|
||||
handoff.response = std::make_shared<SimpleWriter>(msg);
|
||||
return handoff;
|
||||
}
|
||||
|
||||
// VFALCO TODO Rewrite to use beast::http::headers
|
||||
// VFALCO TODO Rewrite to use beast::http::fields
|
||||
static
|
||||
bool
|
||||
authorized (
|
||||
@@ -269,7 +269,7 @@ Json::Output makeOutput (Session& session)
|
||||
// HACK!
|
||||
static
|
||||
std::map<std::string, std::string>
|
||||
build_map(beast::http::headers const& h)
|
||||
build_map(beast::http::fields const& h)
|
||||
{
|
||||
std::map <std::string, std::string> c;
|
||||
for (auto const& e : h)
|
||||
@@ -311,7 +311,7 @@ ServerHandlerImp::onRequest (Session& session)
|
||||
|
||||
// Check user/password authorization
|
||||
if (! authorized (
|
||||
session.port(), build_map(session.request().headers)))
|
||||
session.port(), build_map(session.request().fields)))
|
||||
{
|
||||
HTTPReply (403, "Forbidden", makeOutput (session), app_.journal ("RPC"));
|
||||
session.close (true);
|
||||
@@ -507,18 +507,18 @@ ServerHandlerImp::processSession (std::shared_ptr<Session> const& session,
|
||||
[&]
|
||||
{
|
||||
auto const iter =
|
||||
session->request().headers.find(
|
||||
session->request().fields.find(
|
||||
"X-Forwarded-For");
|
||||
if(iter != session->request().headers.end())
|
||||
if(iter != session->request().fields.end())
|
||||
return iter->second;
|
||||
return std::string{};
|
||||
}(),
|
||||
[&]
|
||||
{
|
||||
auto const iter =
|
||||
session->request().headers.find(
|
||||
session->request().fields.find(
|
||||
"X-User");
|
||||
if(iter != session->request().headers.end())
|
||||
if(iter != session->request().fields.end())
|
||||
return iter->second;
|
||||
return std::string{};
|
||||
}());
|
||||
@@ -728,7 +728,7 @@ ServerHandlerImp::statusResponse(
|
||||
{
|
||||
using namespace beast::http;
|
||||
Handoff handoff;
|
||||
response_v1<string_body> msg;
|
||||
response<string_body> msg;
|
||||
std::string reason;
|
||||
if (app_.serverOkay(reason))
|
||||
{
|
||||
@@ -747,8 +747,8 @@ ServerHandlerImp::statusResponse(
|
||||
reason + "</BODY></HTML>";
|
||||
}
|
||||
msg.version = request.version;
|
||||
msg.headers.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.headers.insert("Content-Type", "text/html");
|
||||
msg.fields.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.fields.insert("Content-Type", "text/html");
|
||||
prepare(msg, beast::http::connection::close);
|
||||
handoff.response = std::make_shared<SimpleWriter>(msg);
|
||||
return handoff;
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
: InfoSub(source)
|
||||
, ws_(ws)
|
||||
{
|
||||
auto const& h = ws->request().headers;
|
||||
auto const& h = ws->request().fields;
|
||||
auto it = h.find("X-User");
|
||||
if (it != h.end() &&
|
||||
isIdentified(
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
#include <beast/http/body_type.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -36,10 +36,10 @@ struct json_body
|
||||
beast::streambuf sb_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Headers>
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(beast::http::message<
|
||||
isRequest, json_body, Headers> const& m)
|
||||
isRequest, json_body, Fields> const& m) noexcept
|
||||
{
|
||||
stream(m.body,
|
||||
[&](void const* data, std::size_t n)
|
||||
@@ -50,22 +50,22 @@ struct json_body
|
||||
}
|
||||
|
||||
void
|
||||
init(beast::error_code&)
|
||||
init(beast::error_code&) noexcept
|
||||
{
|
||||
}
|
||||
|
||||
std::uint64_t
|
||||
content_length() const
|
||||
content_length() const noexcept
|
||||
{
|
||||
return sb_.size();
|
||||
}
|
||||
|
||||
template<class Write>
|
||||
template<class Writef>
|
||||
boost::tribool
|
||||
operator()(beast::http::resume_context&&,
|
||||
beast::error_code&, Write&& write)
|
||||
write(beast::http::resume_context&&,
|
||||
beast::error_code&, Writef&& wf) noexcept
|
||||
{
|
||||
write(sb_.data());
|
||||
wf(sb_.data());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,17 +21,17 @@
|
||||
#define RIPPLE_SERVER_HANDOFF_H_INCLUDED
|
||||
|
||||
#include <ripple/server/Writer.h>
|
||||
#include <beast/http/message_v1.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/streambuf_body.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
using http_request_type =
|
||||
beast::http::request_v1<beast::http::streambuf_body>;
|
||||
beast::http::request<beast::http::streambuf_body>;
|
||||
|
||||
using http_response_type =
|
||||
beast::http::response_v1<beast::http::streambuf_body>;
|
||||
beast::http::response<beast::http::streambuf_body>;
|
||||
|
||||
/** Used to indicate the result of a server connection handoff. */
|
||||
struct Handoff
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <ripple/server/Writer.h>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
#include <beast/core/write_dynabuf.hpp>
|
||||
#include <beast/http/message_v1.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <utility>
|
||||
|
||||
@@ -37,7 +37,7 @@ class SimpleWriter : public Writer
|
||||
public:
|
||||
template<bool isRequest, class Body, class Headers>
|
||||
explicit
|
||||
SimpleWriter(beast::http::message_v1<
|
||||
SimpleWriter(beast::http::message<
|
||||
isRequest, Body, Headers> const& msg)
|
||||
{
|
||||
beast::write(sb_, msg);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <ripple/protocol/BuildInfo.h>
|
||||
#include <beast/websocket.hpp>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
#include <beast/http/message_v1.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace ripple {
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_address,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
beast::http::request<Body, Headers>&& request,
|
||||
boost::asio::io_service& io_service,
|
||||
beast::Journal journal);
|
||||
|
||||
@@ -112,7 +112,7 @@ protected:
|
||||
void
|
||||
operator()(beast::http::message<true, Body, Headers>& req)
|
||||
{
|
||||
req.headers.replace("User-Agent",
|
||||
req.fields.replace("User-Agent",
|
||||
BuildInfo::getFullVersionString());
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ protected:
|
||||
void
|
||||
operator()(beast::http::message<false, Body, Headers>& resp)
|
||||
{
|
||||
resp.headers.replace("Server",
|
||||
resp.fields.replace("Server",
|
||||
BuildInfo::getFullVersionString());
|
||||
}
|
||||
};
|
||||
@@ -175,7 +175,7 @@ BaseWSPeer(
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_address,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
beast::http::request<Body, Headers>&& request,
|
||||
boost::asio::io_service& io_service,
|
||||
beast::Journal journal)
|
||||
: BasePeer<Handler, Impl>(port, handler, remote_address,
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_address,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
beast::http::request<Body, Headers>&& request,
|
||||
socket_type&& socket,
|
||||
beast::Journal journal);
|
||||
|
||||
@@ -66,7 +66,7 @@ PlainWSPeer(
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_address,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
beast::http::request<Body, Headers>&& request,
|
||||
socket_type&& socket,
|
||||
beast::Journal journal)
|
||||
: BaseWSPeer<Handler, PlainWSPeer>(port, handler, remote_address,
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_endpoint,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
beast::http::request<Body, Headers>&& request,
|
||||
std::unique_ptr<
|
||||
beast::asio::ssl_bundle>&& ssl_bundle,
|
||||
beast::Journal journal);
|
||||
@@ -76,7 +76,7 @@ SSLWSPeer(
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_endpoint,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
beast::http::request<Body, Headers>&& request,
|
||||
std::unique_ptr<
|
||||
beast::asio::ssl_bundle>&& ssl_bundle,
|
||||
beast::Journal journal)
|
||||
|
||||
@@ -84,18 +84,18 @@ class ServerStatus_test :
|
||||
{
|
||||
using namespace boost::asio;
|
||||
using namespace beast::http;
|
||||
request_v1<string_body> req;
|
||||
request<string_body> req;
|
||||
|
||||
req.url = "/";
|
||||
req.version = 11;
|
||||
req.headers.insert("Host", host + ":" + to_string(port));
|
||||
req.headers.insert("User-Agent", "test");
|
||||
req.fields.insert("Host", host + ":" + to_string(port));
|
||||
req.fields.insert("User-Agent", "test");
|
||||
req.method = "GET";
|
||||
req.headers.insert("Upgrade", "websocket");
|
||||
req.fields.insert("Upgrade", "websocket");
|
||||
beast::websocket::detail::maskgen maskgen;
|
||||
std::string key = beast::websocket::detail::make_sec_ws_key(maskgen);
|
||||
req.headers.insert("Sec-WebSocket-Key", key);
|
||||
req.headers.insert("Sec-WebSocket-Version", "13");
|
||||
req.fields.insert("Sec-WebSocket-Key", key);
|
||||
req.fields.insert("Sec-WebSocket-Version", "13");
|
||||
prepare(req, connection::upgrade);
|
||||
return req;
|
||||
}
|
||||
@@ -107,12 +107,12 @@ class ServerStatus_test :
|
||||
{
|
||||
using namespace boost::asio;
|
||||
using namespace beast::http;
|
||||
request_v1<string_body> req;
|
||||
request<string_body> req;
|
||||
|
||||
req.url = "/";
|
||||
req.version = 11;
|
||||
req.headers.insert("Host", host + ":" + to_string(port));
|
||||
req.headers.insert("User-Agent", "test");
|
||||
req.fields.insert("Host", host + ":" + to_string(port));
|
||||
req.fields.insert("User-Agent", "test");
|
||||
if(body.empty())
|
||||
{
|
||||
req.method = "GET";
|
||||
@@ -120,7 +120,7 @@ class ServerStatus_test :
|
||||
else
|
||||
{
|
||||
req.method = "POST";
|
||||
req.headers.insert("Content-Type", "application/json; charset=UTF-8");
|
||||
req.fields.insert("Content-Type", "application/json; charset=UTF-8");
|
||||
req.body = body;
|
||||
}
|
||||
prepare(req);
|
||||
@@ -131,11 +131,11 @@ class ServerStatus_test :
|
||||
void
|
||||
doRequest(
|
||||
boost::asio::yield_context& yield,
|
||||
beast::http::request_v1<beast::http::string_body> const& req,
|
||||
beast::http::request<beast::http::string_body> const& req,
|
||||
std::string const& host,
|
||||
uint16_t port,
|
||||
bool secure,
|
||||
beast::http::response_v1<beast::http::string_body>& resp,
|
||||
beast::http::response<beast::http::string_body>& resp,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
using namespace boost::asio;
|
||||
@@ -190,7 +190,7 @@ class ServerStatus_test :
|
||||
test::jtx::Env& env,
|
||||
boost::asio::yield_context& yield,
|
||||
bool secure,
|
||||
beast::http::response_v1<beast::http::string_body>& resp,
|
||||
beast::http::response<beast::http::string_body>& resp,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
auto const port = env.app().config()["port_ws"].
|
||||
@@ -207,7 +207,7 @@ class ServerStatus_test :
|
||||
test::jtx::Env& env,
|
||||
boost::asio::yield_context& yield,
|
||||
bool secure,
|
||||
beast::http::response_v1<beast::http::string_body>& resp,
|
||||
beast::http::response<beast::http::string_body>& resp,
|
||||
boost::system::error_code& ec,
|
||||
std::string const& body = "")
|
||||
{
|
||||
@@ -285,7 +285,7 @@ class ServerStatus_test :
|
||||
//non-secure request
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
beast::http::response_v1<beast::http::string_body> resp;
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
doWSRequest(env, yield, false, resp, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
@@ -295,7 +295,7 @@ class ServerStatus_test :
|
||||
//secure request
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
beast::http::response_v1<beast::http::string_body> resp;
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
doWSRequest(env, yield, true, resp, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
@@ -320,7 +320,7 @@ class ServerStatus_test :
|
||||
//non-secure request
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
beast::http::response_v1<beast::http::string_body> resp;
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
doHTTPRequest(env, yield, false, resp, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
@@ -330,7 +330,7 @@ class ServerStatus_test :
|
||||
//secure request
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
beast::http::response_v1<beast::http::string_body> resp;
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
doHTTPRequest(env, yield, true, resp, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
@@ -359,7 +359,7 @@ class ServerStatus_test :
|
||||
get<std::string>("ip");
|
||||
|
||||
boost::system::error_code ec;
|
||||
response_v1<string_body> resp;
|
||||
response<string_body> resp;
|
||||
auto req = makeWSUpgrade(*ip, *port);
|
||||
|
||||
//truncate the request message to near the value of the version header
|
||||
@@ -400,7 +400,7 @@ class ServerStatus_test :
|
||||
using namespace jtx;
|
||||
Env env {*this, makeConfig(server_protocol)};
|
||||
|
||||
beast::http::response_v1<beast::http::string_body> resp;
|
||||
beast::http::response<beast::http::string_body> resp;
|
||||
boost::system::error_code ec;
|
||||
// The essence of this test is to have a client and server configured
|
||||
// out-of-phase with respect to ssl (secure client and insecure server
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/server/Port.h>
|
||||
#include <beast/http/message_v1.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/streambuf_body.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
@@ -108,12 +108,12 @@ public:
|
||||
using namespace boost::asio;
|
||||
using namespace std::string_literals;
|
||||
|
||||
request_v1<string_body> req;
|
||||
request<string_body> req;
|
||||
req.method = "POST";
|
||||
req.url = "/";
|
||||
req.version = 11;
|
||||
req.headers.insert("Content-Type", "application/json; charset=UTF-8");
|
||||
req.headers.insert("Host",
|
||||
req.fields.insert("Content-Type", "application/json; charset=UTF-8");
|
||||
req.fields.insert("Host",
|
||||
ep_.address().to_string() + ":" + std::to_string(ep_.port()));
|
||||
{
|
||||
Json::Value jr;
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
prepare(req);
|
||||
write(stream_, req);
|
||||
|
||||
response_v1<streambuf_body> res;
|
||||
response<streambuf_body> res;
|
||||
read(stream_, bin_, res);
|
||||
|
||||
Json::Reader jr;
|
||||
|
||||
Reference in New Issue
Block a user