47 const size_t push_continuation_len = 20;
50 bool did_continuation =
false;
55 const std::string escaped_opt = lex.
next();
63 if (back()->size() + escaped_opt.size() + push_continuation_len + 1 >
FRAGMENT_SIZE)
65 did_continuation =
true;
70 back()->push_back(
',');
75 if (!empty() && did_continuation)
81 const std::string &prefix)
90 size_t total_size = 0;
91 for (
const auto &e : bv)
92 total_size += e->size();
99 static const char pc1[] =
",push-continuation 1";
100 static const char pc2[] =
",push-continuation 2";
103 const std::string prefix_comma = prefix +
',';
104 const size_t size = bv.size();
105 for (
size_t i = 0; i < size; ++i)
107 const Buffer &buf = *bv[i];
108 const char *pc = (i == size - 1) ? pc1 : pc2;
117 throw push_continuation_fragment_error(
"badly formatted fragments");
void push_back(const T &value)
Append a T object to the end of the array, resizing the array if necessary.
size_t size() const
Returns the size of the buffer in T objects.
void advance(const size_t delta)
Advances the buffer by the specified delta.
void set_size(const size_t size)
After an external method, operating on the array as a mutable unsigned char buffer,...
static void append_push_continuation(Buffer &buf, bool end)
OPENVPN_EXCEPTION(push_continuation_fragment_error)
PushContinuationFragment(const ConstBuffer &buf, const std::string &prefix)
void append_new_buffer(const std::string &prefix)
static BufferPtr defragment(const std::vector< BufferPtr > &bv, const std::string &prefix)
static bool should_fragment(const ConstBuffer &buf)
static constexpr size_t FRAGMENT_SIZE
static Ptr Create(ArgsT &&...args)
Creates a new instance of RcEnable with the given arguments.
bool starts_with(const STRING &str, const std::string &prefix)
bool ends_with(const STRING &str, const std::string &suffix)
void buf_append_string(Buffer &buf, const std::string &str)
RCPtr< BufferAllocatedRc > BufferPtr
server addresses push_back({address, port})