mirror of
https://github.com/matrix-construct/construct
synced 2024-05-29 00:03:45 +02:00
ircd:Ⓜ️:resource: Abstract request::version to ircd::request::agent.
This commit is contained in:
parent
24cf3569a9
commit
93a7575352
|
@ -49,7 +49,6 @@ struct ircd::m::resource::request
|
|||
pair<string_view> authorization; // proffering any
|
||||
string_view access_token; // proffering user
|
||||
m::request::x_matrix x_matrix; // proferring server
|
||||
pair<string_view> version; // enumeration
|
||||
|
||||
string_view node_id; // authenticated server
|
||||
m::user::id user_id; // authenticated user or bridge pup
|
||||
|
|
|
@ -19,10 +19,15 @@ struct ircd::resource::request
|
|||
http::request::head head;
|
||||
string_view content;
|
||||
http::query::string query;
|
||||
pair<string_view> agent;
|
||||
string_view params;
|
||||
vector_view<string_view> parv;
|
||||
string_view param[8];
|
||||
|
||||
private:
|
||||
static pair<string_view> parse_agent(const http::request::head &) noexcept;
|
||||
|
||||
public:
|
||||
request(const http::request::head &, const string_view &content) noexcept;
|
||||
request() = default;
|
||||
};
|
||||
|
@ -35,6 +40,7 @@ struct ircd::resource::request::object
|
|||
const http::request::head &head;
|
||||
const string_view &content;
|
||||
const http::query::string &query;
|
||||
const pair<string_view> &agent;
|
||||
const string_view ¶ms;
|
||||
const vector_view<string_view> &parv;
|
||||
const json::object &body;
|
||||
|
@ -51,6 +57,7 @@ noexcept
|
|||
,head{r.head}
|
||||
,content{r.content}
|
||||
,query{r.query}
|
||||
,agent{r.agent}
|
||||
,params{r.params}
|
||||
,parv{r.parv}
|
||||
,body{r}
|
||||
|
|
|
@ -762,7 +762,37 @@ noexcept
|
|||
{
|
||||
this->head.query
|
||||
}
|
||||
,agent
|
||||
{
|
||||
parse_agent(this->head)
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
[[gnu::visibility("internal")]]
|
||||
ircd::pair<ircd::string_view>
|
||||
ircd::resource::request::parse_agent(const http::request::head &head)
|
||||
noexcept
|
||||
{
|
||||
const auto &user_agent
|
||||
{
|
||||
head.user_agent
|
||||
};
|
||||
|
||||
const auto &[primary, info]
|
||||
{
|
||||
split(user_agent, ' ')
|
||||
};
|
||||
|
||||
const auto &[name, agent]
|
||||
{
|
||||
split(primary, '/')
|
||||
};
|
||||
|
||||
return
|
||||
{
|
||||
name, agent
|
||||
};
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace ircd::m
|
|||
extern conf::item<bool> x_matrix_verify_origin;
|
||||
extern conf::item<bool> x_matrix_verify_destination;
|
||||
|
||||
static pair<string_view> parse_version(const resource::request &);
|
||||
static string_view authenticate_bridge(const resource::method &, const client &, resource::request &);
|
||||
static user::id authenticate_user(const resource::method &, const client &, resource::request &);
|
||||
static string_view authenticate_node(const resource::method &, const client &, resource::request &);
|
||||
|
@ -177,10 +176,6 @@ ircd::m::resource::request::request(const method &method,
|
|||
m::request::x_matrix{authorization.first, authorization.second}:
|
||||
m::request::x_matrix{}
|
||||
}
|
||||
,version
|
||||
{
|
||||
parse_version(*this)
|
||||
}
|
||||
,node_id
|
||||
{
|
||||
// Server X-Matrix header verified here. Similar to client auth, origin
|
||||
|
@ -435,27 +430,3 @@ catch(const std::exception &e)
|
|||
e.what()
|
||||
};
|
||||
}
|
||||
|
||||
ircd::pair<ircd::string_view>
|
||||
ircd::m::parse_version(const m::resource::request &request)
|
||||
{
|
||||
const auto &user_agent
|
||||
{
|
||||
request.head.user_agent
|
||||
};
|
||||
|
||||
const auto &[primary, info]
|
||||
{
|
||||
split(user_agent, ' ')
|
||||
};
|
||||
|
||||
const auto &[name, version]
|
||||
{
|
||||
split(primary, '/')
|
||||
};
|
||||
|
||||
return
|
||||
{
|
||||
name, version
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue