0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

ircd::http: Utils to read and write chunk size line.

This commit is contained in:
Jason Volk 2018-03-18 21:09:42 -07:00
parent 9723eec4e8
commit daae800cc1
2 changed files with 21 additions and 0 deletions

View file

@ -32,6 +32,8 @@ namespace ircd::http
void write(window_buffer &, const vector_view<const header> &);
size_t serialized(const vector_view<const header> &);
std::string strung(const vector_view<const header> &);
void writechunk(window_buffer &, const size_t &size);
const_buffer writechunk(const mutable_buffer &, const size_t &size);
}
//

View file

@ -570,6 +570,25 @@ ircd::http::parser::content_length(const string_view &str)
return ret;
}
ircd::const_buffer
ircd::http::writechunk(const mutable_buffer &buf,
const size_t &chunk_size)
{
window_buffer wb{buf};
writechunk(wb, chunk_size);
return wb.completed();
}
void
ircd::http::writechunk(window_buffer &buf,
const size_t &chunk_size)
{
writeline(buf, [&chunk_size](const mutable_buffer &out) -> size_t
{
return ::snprintf(data(out), size(out), "%lx", chunk_size);
});
}
std::string
ircd::http::strung(const vector_view<const header> &headers)
{