mirror of
https://github.com/matrix-construct/construct
synced 2024-11-10 20:11:07 +01:00
ircd::resource: Ignore empty chunk from user by default unless explicit.
This commit is contained in:
parent
4e6ed85d27
commit
8cb5b78807
2 changed files with 7 additions and 3 deletions
|
@ -41,7 +41,7 @@ struct ircd::resource::response::chunked
|
|||
client *c {nullptr};
|
||||
unique_buffer<mutable_buffer> buf;
|
||||
|
||||
size_t write(const const_buffer &chunk);
|
||||
size_t write(const const_buffer &chunk, const bool &ignore_empty = true);
|
||||
const_buffer flush(const const_buffer &);
|
||||
bool finish();
|
||||
|
||||
|
|
|
@ -862,7 +862,7 @@ ircd::resource::response::chunked::finish()
|
|||
if(!c)
|
||||
return false;
|
||||
|
||||
write(const_buffer{});
|
||||
write(const_buffer{}, false);
|
||||
c = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
@ -879,7 +879,8 @@ ircd::resource::response::chunked::flush(const const_buffer &buf)
|
|||
}
|
||||
|
||||
size_t
|
||||
ircd::resource::response::chunked::write(const const_buffer &chunk)
|
||||
ircd::resource::response::chunked::write(const const_buffer &chunk,
|
||||
const bool &ignore_empty)
|
||||
try
|
||||
{
|
||||
size_t ret{0};
|
||||
|
@ -887,6 +888,9 @@ try
|
|||
if(!c)
|
||||
return ret;
|
||||
|
||||
if(ignore_empty && empty(chunk))
|
||||
return ret;
|
||||
|
||||
//TODO: bring iov from net::socket -> net::write_() -> client::write_()
|
||||
char headbuf[32];
|
||||
ret += c->write_all(http::writechunk(headbuf, size(chunk)));
|
||||
|
|
Loading…
Reference in a new issue