mirror of
https://github.com/XRPLF/rippled.git
synced 2026-02-04 05:55:25 +00:00
Compare commits
5 Commits
develop
...
copilot/co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae624ab894 | ||
|
|
21ac390a37 | ||
|
|
86aca89bc4 | ||
|
|
b26dd49fb6 | ||
|
|
0969281538 |
@@ -11,6 +11,7 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@@ -179,7 +180,7 @@ split_commas(FwdIt first, FwdIt last)
|
|||||||
|
|
||||||
template <class Result = std::vector<std::string>>
|
template <class Result = std::vector<std::string>>
|
||||||
Result
|
Result
|
||||||
split_commas(boost::beast::string_view const& s)
|
split_commas(std::string_view const& s)
|
||||||
{
|
{
|
||||||
return split_commas(s.begin(), s.end());
|
return split_commas(s.begin(), s.end());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
#ifndef XRPL_JSON_OUTPUT_H_INCLUDED
|
#ifndef XRPL_JSON_OUTPUT_H_INCLUDED
|
||||||
#define XRPL_JSON_OUTPUT_H_INCLUDED
|
#define XRPL_JSON_OUTPUT_H_INCLUDED
|
||||||
|
|
||||||
#include <boost/beast/core/string.hpp>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
class Value;
|
class Value;
|
||||||
|
|
||||||
using Output = std::function<void(boost::beast::string_view const&)>;
|
using Output = std::function<void(std::string_view const&)>;
|
||||||
|
|
||||||
inline Output
|
inline Output
|
||||||
stringOutput(std::string& s)
|
stringOutput(std::string& s)
|
||||||
{
|
{
|
||||||
return [&](boost::beast::string_view const& b) { s.append(b.data(), b.size()); };
|
return [&](std::string_view const& b) { s.append(b.data(), b.size()); };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes a minimal representation of a Json value to an Output in O(n) time.
|
/** Writes a minimal representation of a Json value to an Output in O(n) time.
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ private:
|
|||||||
bool ping_active_ = false;
|
bool ping_active_ = false;
|
||||||
boost::beast::websocket::ping_data payload_;
|
boost::beast::websocket::ping_data payload_;
|
||||||
error_code ec_;
|
error_code ec_;
|
||||||
std::function<void(boost::beast::websocket::frame_type, boost::beast::string_view)> control_callback_;
|
std::function<void(boost::beast::websocket::frame_type, std::string_view)> control_callback_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <class Body, class Headers>
|
template <class Body, class Headers>
|
||||||
@@ -137,7 +138,7 @@ protected:
|
|||||||
on_ping(error_code const& ec);
|
on_ping(error_code const& ec);
|
||||||
|
|
||||||
void
|
void
|
||||||
on_ping_pong(boost::beast::websocket::frame_type kind, boost::beast::string_view payload);
|
on_ping_pong(boost::beast::websocket::frame_type kind, std::string_view payload);
|
||||||
|
|
||||||
void
|
void
|
||||||
on_timer(error_code ec);
|
on_timer(error_code ec);
|
||||||
@@ -390,11 +391,11 @@ BaseWSPeer<Handler, Impl>::on_ping(error_code const& ec)
|
|||||||
|
|
||||||
template <class Handler, class Impl>
|
template <class Handler, class Impl>
|
||||||
void
|
void
|
||||||
BaseWSPeer<Handler, Impl>::on_ping_pong(boost::beast::websocket::frame_type kind, boost::beast::string_view payload)
|
BaseWSPeer<Handler, Impl>::on_ping_pong(boost::beast::websocket::frame_type kind, std::string_view payload)
|
||||||
{
|
{
|
||||||
if (kind == boost::beast::websocket::frame_type::pong)
|
if (kind == boost::beast::websocket::frame_type::pong)
|
||||||
{
|
{
|
||||||
boost::beast::string_view p(payload_.begin());
|
std::string_view p(payload_.begin(), payload_.size());
|
||||||
if (payload == p)
|
if (payload == p)
|
||||||
{
|
{
|
||||||
close_on_timer_ = false;
|
close_on_timer_ = false;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -87,14 +88,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
output(boost::beast::string_view const& bytes)
|
output(std::string_view const& bytes)
|
||||||
{
|
{
|
||||||
markStarted();
|
markStarted();
|
||||||
output_(bytes);
|
output_(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
stringOutput(boost::beast::string_view const& bytes)
|
stringOutput(std::string_view const& bytes)
|
||||||
{
|
{
|
||||||
markStarted();
|
markStarted();
|
||||||
std::size_t position = 0, writtenUntil = 0;
|
std::size_t position = 0, writtenUntil = 0;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ to_string(ProtocolVersion const& p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ProtocolVersion>
|
std::vector<ProtocolVersion>
|
||||||
parseProtocolVersions(boost::beast::string_view const& value)
|
parseProtocolVersions(std::string_view const& value)
|
||||||
{
|
{
|
||||||
static boost::regex re(
|
static boost::regex re(
|
||||||
"^" // start of line
|
"^" // start of line
|
||||||
@@ -127,7 +127,7 @@ negotiateProtocolVersion(std::vector<ProtocolVersion> const& versions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ProtocolVersion>
|
std::optional<ProtocolVersion>
|
||||||
negotiateProtocolVersion(boost::beast::string_view const& versions)
|
negotiateProtocolVersion(std::string_view const& versions)
|
||||||
{
|
{
|
||||||
auto const them = parseProtocolVersions(versions);
|
auto const them = parseProtocolVersions(versions);
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#ifndef XRPL_OVERLAY_PROTOCOLVERSION_H_INCLUDED
|
#ifndef XRPL_OVERLAY_PROTOCOLVERSION_H_INCLUDED
|
||||||
#define XRPL_OVERLAY_PROTOCOLVERSION_H_INCLUDED
|
#define XRPL_OVERLAY_PROTOCOLVERSION_H_INCLUDED
|
||||||
|
|
||||||
#include <boost/beast/core/string.hpp>
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -40,7 +39,7 @@ to_string(ProtocolVersion const& p);
|
|||||||
no duplicates and will be sorted in ascending protocol order.
|
no duplicates and will be sorted in ascending protocol order.
|
||||||
*/
|
*/
|
||||||
std::vector<ProtocolVersion>
|
std::vector<ProtocolVersion>
|
||||||
parseProtocolVersions(boost::beast::string_view const& s);
|
parseProtocolVersions(std::string_view const& s);
|
||||||
|
|
||||||
/** Given a list of supported protocol versions, choose the one we prefer. */
|
/** Given a list of supported protocol versions, choose the one we prefer. */
|
||||||
std::optional<ProtocolVersion>
|
std::optional<ProtocolVersion>
|
||||||
@@ -48,7 +47,7 @@ negotiateProtocolVersion(std::vector<ProtocolVersion> const& versions);
|
|||||||
|
|
||||||
/** Given a list of supported protocol versions, choose the one we prefer. */
|
/** Given a list of supported protocol versions, choose the one we prefer. */
|
||||||
std::optional<ProtocolVersion>
|
std::optional<ProtocolVersion>
|
||||||
negotiateProtocolVersion(boost::beast::string_view const& versions);
|
negotiateProtocolVersion(std::string_view const& versions);
|
||||||
|
|
||||||
/** The list of all the protocol versions we support. */
|
/** The list of all the protocol versions we support. */
|
||||||
std::string const&
|
std::string const&
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|
||||||
@@ -227,7 +228,7 @@ ServerHandler::onHandoff(
|
|||||||
static inline Json::Output
|
static inline Json::Output
|
||||||
makeOutput(Session& session)
|
makeOutput(Session& session)
|
||||||
{
|
{
|
||||||
return [&](boost::beast::string_view const& b) { session.write(b.data(), b.size()); };
|
return [&](std::string_view const& b) { session.write(b.data(), b.size()); };
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::map<std::string, std::string>
|
static std::map<std::string, std::string>
|
||||||
@@ -511,11 +512,14 @@ ServerHandler::processSession(std::shared_ptr<Session> const& session, std::shar
|
|||||||
makeOutput(*session),
|
makeOutput(*session),
|
||||||
coro,
|
coro,
|
||||||
forwardedFor(session->request()),
|
forwardedFor(session->request()),
|
||||||
[&] {
|
[&]() -> std::string_view {
|
||||||
auto const iter = session->request().find("X-User");
|
auto const iter = session->request().find("X-User");
|
||||||
if (iter != session->request().end())
|
if (iter != session->request().end())
|
||||||
return iter->value();
|
{
|
||||||
return boost::beast::string_view{};
|
auto const val = iter->value();
|
||||||
|
return std::string_view(val.data(), val.size());
|
||||||
|
}
|
||||||
|
return std::string_view{};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
if (beast::rfc2616::is_keep_alive(session->request()))
|
if (beast::rfc2616::is_keep_alive(session->request()))
|
||||||
|
|||||||
Reference in New Issue
Block a user