mirror of
https://github.com/matrix-construct/construct
synced 2024-09-28 11:48:54 +02:00
modules/media/preview_url: Quash TODO for rfc3986 uri parsing.
This commit is contained in:
parent
180963ca22
commit
70315e2459
1 changed files with 7 additions and 17 deletions
|
@ -92,26 +92,21 @@ request_url(const string_view &urle)
|
||||||
url::decode(buf, urle)
|
url::decode(buf, urle)
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto &host
|
const rfc3986::uri uri
|
||||||
{
|
{
|
||||||
between(url, "://", "/") //TODO: grammar / rfc3986.h
|
url
|
||||||
};
|
};
|
||||||
|
|
||||||
const string_view &service
|
const net::hostport remote
|
||||||
{
|
{
|
||||||
split(url, "://").first
|
uri
|
||||||
};
|
};
|
||||||
|
|
||||||
const string_view &path
|
if(empty(host(remote)) || empty(uri.path))
|
||||||
{
|
|
||||||
end(host), end(url)
|
|
||||||
};
|
|
||||||
|
|
||||||
if(empty(host) || empty(path))
|
|
||||||
throw m::error
|
throw m::error
|
||||||
{
|
{
|
||||||
http::BAD_REQUEST, "M_BAD_URL",
|
http::BAD_REQUEST, "M_BAD_URL",
|
||||||
"Something was wrong with the supplied URL."
|
"Required elements are missing from the supplied URL."
|
||||||
};
|
};
|
||||||
|
|
||||||
window_buffer wb
|
window_buffer wb
|
||||||
|
@ -121,7 +116,7 @@ request_url(const string_view &urle)
|
||||||
|
|
||||||
http::request
|
http::request
|
||||||
{
|
{
|
||||||
wb, host, "GET", path, 0, {},
|
wb, host(remote), "GET", uri.path, 0, {},
|
||||||
{
|
{
|
||||||
{ "User-Agent", info::user_agent },
|
{ "User-Agent", info::user_agent },
|
||||||
}
|
}
|
||||||
|
@ -137,11 +132,6 @@ request_url(const string_view &urle)
|
||||||
buf + size(url) + size(out_head)
|
buf + size(url) + size(out_head)
|
||||||
};
|
};
|
||||||
|
|
||||||
const net::hostport remote
|
|
||||||
{
|
|
||||||
host, service
|
|
||||||
};
|
|
||||||
|
|
||||||
server::request::opts sopts;
|
server::request::opts sopts;
|
||||||
sopts.http_exceptions = false;
|
sopts.http_exceptions = false;
|
||||||
server::request request
|
server::request request
|
||||||
|
|
Loading…
Reference in a new issue