0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd::http: Move closure from response::head; use string_view literal.

This commit is contained in:
Jason Volk 2020-03-11 15:44:17 -07:00
parent 5552f69d5b
commit 62108e2c26

View file

@ -498,38 +498,58 @@ ircd::http::response::response(window_buffer &out,
writeline(out); writeline(out);
} }
namespace ircd::http
{
static void assign(response::head &, const header &);
}
ircd::http::response::head::head(parse::capstan &pc, ircd::http::response::head::head(parse::capstan &pc,
const headers::closure &c) const headers::closure &c)
:line::response{pc} :line::response{pc}
,headers ,headers
{ {
http::headers{pc, [this, &c](const auto &h) http::headers
{ {
if(iequals(h.first, "content-type"s)) pc, [this, &c](const auto &header)
this->content_type = h.second; {
assign(*this, header);
else if(iequals(h.first, "content-length"s)) if(c)
this->content_length = parser.content_length(h.second); c(header);
}
else if(iequals(h.first, "content-range"s)) }
this->content_range = h.second;
else if(iequals(h.first, "accept-range"s))
this->content_range = h.second;
else if(iequals(h.first, "transfer-encoding"s))
this->transfer_encoding = h.second;
else if(iequals(h.first, "server"s))
this->server = h.second;
if(c)
c(h);
}}
} }
{ {
} }
void
ircd::http::assign(response::head &head,
const header &header)
{
const auto &[key, val]
{
header
};
if(iequals(key, "content-type"_sv))
head.content_type = val;
else if(iequals(key, "content-length"_sv))
head.content_length = parser.content_length(val);
else if(iequals(key, "content-range"_sv))
head.content_range = val;
else if(iequals(key, "accept-range"_sv))
head.content_range = val;
else if(iequals(key, "transfer-encoding"_sv))
head.transfer_encoding = val;
else if(iequals(key, "server"_sv))
head.server = val;
}
ircd::http::response::chunk::chunk(parse::capstan &pc) ircd::http::response::chunk::chunk(parse::capstan &pc)
try try
:line{pc} :line{pc}