mirror of
https://github.com/matrix-construct/construct
synced 2024-05-30 08:43:48 +02:00
ircd::rest: Add option to supply temporary/headers buffer in lieu of allocating.
This commit is contained in:
parent
dc13381822
commit
02e09728a5
|
@ -100,6 +100,10 @@ struct ircd::rest::opts
|
|||
/// receiving dynamic content. Supply an empty unique_buffer instance.
|
||||
unique_const_buffer *out {nullptr};
|
||||
|
||||
/// Optionally supply the temporary buffer for headers in/out in lieu of
|
||||
/// any internally allocated.
|
||||
mutable_buffer buf;
|
||||
|
||||
/// Timeout for the yielding/synchronous calls of this interface.
|
||||
seconds timeout {20s};
|
||||
|
||||
|
|
40
ircd/rest.cc
40
ircd/rest.cc
|
@ -14,13 +14,25 @@ ircd::rest::request::request(const rfc3986::uri &uri,
|
|||
if(!opts.remote)
|
||||
opts.remote = net::hostport{uri};
|
||||
|
||||
const unique_mutable_buffer buf
|
||||
const bool need_alloc
|
||||
{
|
||||
empty(opts.sout.head) || empty(opts.sin.head)?
|
||||
16_KiB: 0_KiB
|
||||
empty(opts.buf)
|
||||
&& (empty(opts.sout.head) || empty(opts.sin.head))
|
||||
};
|
||||
|
||||
const unique_mutable_buffer _buf
|
||||
{
|
||||
need_alloc? 16_KiB: 0_KiB
|
||||
};
|
||||
|
||||
if(!empty(_buf))
|
||||
opts.buf = _buf;
|
||||
|
||||
window_buffer window
|
||||
{
|
||||
opts.buf
|
||||
};
|
||||
|
||||
window_buffer window{buf};
|
||||
if(empty(opts.sout.head))
|
||||
{
|
||||
assert(opts.remote);
|
||||
|
@ -80,13 +92,25 @@ ircd::rest::request::request(const mutable_buffer &out,
|
|||
if(!opts.remote)
|
||||
opts.remote = net::hostport{uri};
|
||||
|
||||
const unique_mutable_buffer buf
|
||||
const bool need_alloc
|
||||
{
|
||||
empty(opts.sout.head) || empty(opts.sin.head)?
|
||||
16_KiB: 0_KiB
|
||||
empty(opts.buf)
|
||||
&& (empty(opts.sout.head) || empty(opts.sin.head))
|
||||
};
|
||||
|
||||
const unique_mutable_buffer _buf
|
||||
{
|
||||
need_alloc? 16_KiB: 0_KiB
|
||||
};
|
||||
|
||||
if(!empty(_buf))
|
||||
opts.buf = _buf;
|
||||
|
||||
window_buffer window
|
||||
{
|
||||
opts.buf
|
||||
};
|
||||
|
||||
window_buffer window{buf};
|
||||
if(empty(opts.sout.head))
|
||||
{
|
||||
assert(opts.remote);
|
||||
|
|
Loading…
Reference in a new issue