mirror of
https://github.com/matrix-construct/construct
synced 2025-03-17 06:50:23 +01:00
ircd::http: Add string views to make the raw head data available.
This commit is contained in:
parent
3a3dfe40d1
commit
b42ded1fc7
2 changed files with 38 additions and 0 deletions
|
@ -88,6 +88,8 @@ struct ircd::http::line::request
|
|||
string_view fragment;
|
||||
string_view version;
|
||||
|
||||
operator string_view() const; // full view of line
|
||||
|
||||
request(const line &);
|
||||
request() = default;
|
||||
};
|
||||
|
@ -226,6 +228,9 @@ struct ircd::http::request::head
|
|||
string_view uri; // full view of (path, query, fragmet)
|
||||
string_view headers; // full view of all headers
|
||||
|
||||
// full view of all head (request line and headers)
|
||||
operator string_view() const;
|
||||
|
||||
head(parse::capstan &pc, const headers::closure &c = {});
|
||||
head() = default;
|
||||
};
|
||||
|
|
33
ircd/http.cc
33
ircd/http.cc
|
@ -307,6 +307,24 @@ ircd::http::request::head::head(parse::capstan &pc,
|
|||
{
|
||||
}
|
||||
|
||||
ircd::http::request::head::operator
|
||||
string_view()
|
||||
const
|
||||
{
|
||||
const string_view request_line
|
||||
{
|
||||
static_cast<const line::request &>(*this)
|
||||
};
|
||||
|
||||
if(request_line.empty() || headers.empty())
|
||||
return request_line;
|
||||
|
||||
return string_view
|
||||
{
|
||||
request_line.begin(), headers.end()
|
||||
};
|
||||
}
|
||||
|
||||
ircd::http::response::response(window_buffer &out,
|
||||
const code &code,
|
||||
const size_t &content_length,
|
||||
|
@ -639,6 +657,21 @@ catch(const qi::expectation_failure<const char *> &e)
|
|||
throw_error(e);
|
||||
}
|
||||
|
||||
ircd::http::line::request::operator
|
||||
string_view()
|
||||
const
|
||||
{
|
||||
if(method.empty())
|
||||
return string_view{};
|
||||
|
||||
assert(!version.empty());
|
||||
assert(method.begin() < version.end());
|
||||
return string_view
|
||||
{
|
||||
method.begin(), version.end()
|
||||
};
|
||||
}
|
||||
|
||||
ircd::http::line::line(parse::capstan &pc)
|
||||
:string_view{[&pc]
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue