mirror of
https://github.com/matrix-construct/construct
synced 2024-05-20 03:43:47 +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.
|
/// receiving dynamic content. Supply an empty unique_buffer instance.
|
||||||
unique_const_buffer *out {nullptr};
|
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.
|
/// Timeout for the yielding/synchronous calls of this interface.
|
||||||
seconds timeout {20s};
|
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)
|
if(!opts.remote)
|
||||||
opts.remote = net::hostport{uri};
|
opts.remote = net::hostport{uri};
|
||||||
|
|
||||||
const unique_mutable_buffer buf
|
const bool need_alloc
|
||||||
{
|
{
|
||||||
empty(opts.sout.head) || empty(opts.sin.head)?
|
empty(opts.buf)
|
||||||
16_KiB: 0_KiB
|
&& (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))
|
if(empty(opts.sout.head))
|
||||||
{
|
{
|
||||||
assert(opts.remote);
|
assert(opts.remote);
|
||||||
|
@ -80,13 +92,25 @@ ircd::rest::request::request(const mutable_buffer &out,
|
||||||
if(!opts.remote)
|
if(!opts.remote)
|
||||||
opts.remote = net::hostport{uri};
|
opts.remote = net::hostport{uri};
|
||||||
|
|
||||||
const unique_mutable_buffer buf
|
const bool need_alloc
|
||||||
{
|
{
|
||||||
empty(opts.sout.head) || empty(opts.sin.head)?
|
empty(opts.buf)
|
||||||
16_KiB: 0_KiB
|
&& (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))
|
if(empty(opts.sout.head))
|
||||||
{
|
{
|
||||||
assert(opts.remote);
|
assert(opts.remote);
|
||||||
|
|
Loading…
Reference in a new issue