0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 19:28:52 +02:00

ircd::http: Parse range-request related headers as primaries.

This commit is contained in:
Jason Volk 2019-06-15 12:48:01 -07:00
parent 67c91288e6
commit 7666561f02
2 changed files with 30 additions and 6 deletions

View file

@ -230,6 +230,8 @@ struct ircd::http::request::head
string_view content_type;
string_view user_agent;
string_view upgrade;
string_view range;
string_view if_range;
size_t content_length {0};
string_view uri; // full view of (path, query, fragmet)
@ -266,8 +268,10 @@ struct ircd::http::response
struct ircd::http::response::head
:line::response
{
size_t content_length {0};
string_view content_type;
size_t content_length {0};
string_view content_range;
string_view accept_range;
string_view transfer_encoding;
string_view server;

View file

@ -304,23 +304,37 @@ ircd::http::request::head::head(parse::capstan &pc,
{
if(iequals(h.first, "host"_sv))
this->host = h.second;
else if(iequals(h.first, "expect"_sv))
this->expect = h.second;
else if(iequals(h.first, "te"_sv))
this->te = h.second;
else if(iequals(h.first, "content-length"_sv))
this->content_length = parser.content_length(h.second);
else if(iequals(h.first, "authorization"_sv))
this->authorization = h.second;
else if(iequals(h.first, "connection"_sv))
this->connection = h.second;
else if(iequals(h.first, "content-type"_sv))
this->content_type = h.second;
else if(iequals(h.first, "user-agent"_sv))
this->user_agent = h.second;
else if(iequals(h.first, "upgrade"_sv))
this->upgrade = h.second;
else if(iequals(h.first, "range"_sv))
this->range = h.second;
else if(iequals(h.first, "if-range"_sv))
this->if_range = h.second;
else if(iequals(h.first, "content-length"_sv))
this->content_length = parser.content_length(h.second);
if(c)
c(h);
}};
@ -463,11 +477,17 @@ ircd::http::response::head::head(parse::capstan &pc,
{
http::headers{pc, [this, &c](const auto &h)
{
if(iequals(h.first, "content-length"s))
if(iequals(h.first, "content-type"s))
this->content_type = h.second;
else if(iequals(h.first, "content-length"s))
this->content_length = parser.content_length(h.second);
else if(iequals(h.first, "content-type"s))
this->content_type = h.second;
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;