mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::http: Preserve leading slash from user's URL so we can use it for X-Matrix auth.
This commit is contained in:
parent
87b62002dd
commit
115940e803
3 changed files with 6 additions and 8 deletions
|
@ -180,7 +180,7 @@ struct ircd::http::grammar
|
|||
};
|
||||
|
||||
rule<string_view> method { token ,"method" };
|
||||
rule<string_view> path { -slash >> raw[*(char_ - query_illegal)] ,"path" };
|
||||
rule<string_view> path { raw[-slash >> *(char_ - query_illegal)] ,"path" };
|
||||
rule<string_view> fragment { pound >> -token ,"fragment" };
|
||||
rule<string_view> version { token ,"version" };
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ ircd::resource::find(string_view path)
|
|||
{
|
||||
--it;
|
||||
if(it == begin(resources) || !startswith(path, rstrip(it->first, '/')))
|
||||
return *resources.at(string_view{});
|
||||
return *resources.at("/");
|
||||
}
|
||||
catch(const std::out_of_range &e)
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@ init_0()
|
|||
// TODO: XXX
|
||||
for(const auto &file : fs::ls_recursive("/home/jason/charybdis/charybdis/modules/static"))
|
||||
{
|
||||
const auto name(tokens_after(file, "/", 5));
|
||||
const auto name(tokens_after(file, '/', 5));
|
||||
files.emplace(std::string(name), file);
|
||||
}
|
||||
}
|
||||
|
@ -53,16 +53,14 @@ get_root(client &client, const resource::request &request)
|
|||
request.head.path?: "index.html"
|
||||
};
|
||||
|
||||
auto it(files.find(path));
|
||||
auto it(files.find(lstrip(path, '/')));
|
||||
if(it == end(files))
|
||||
throw http::error{http::NOT_FOUND};
|
||||
|
||||
const auto &filename(it->second);
|
||||
std::ifstream file(filename);
|
||||
std::noskipws(file);
|
||||
const std::string content
|
||||
{
|
||||
std::istream_iterator<char>{file}, std::istream_iterator<char>{}
|
||||
ircd::fs::read(filename)
|
||||
};
|
||||
|
||||
string_view content_type; switch(hash(rsplit(filename, '.').second))
|
||||
|
@ -89,7 +87,7 @@ get_root(client &client, const resource::request &request)
|
|||
|
||||
resource root_resource
|
||||
{
|
||||
"", "Root resource",
|
||||
"/", "Root resource",
|
||||
{
|
||||
root_resource.DIRECTORY
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue