Rewrite Host parsing

This commit is contained in:
R.Y.A.N 2025-03-08 21:26:49 +01:00
parent 22dd4500e4
commit 667052834b
Signed by: R.Y.A.N
GPG Key ID: 3BD93EABD1407B82

View File

@ -33,13 +33,13 @@ namespace seafire::protocol::rfc7230
host_t::
try_parse(std::vector<std::string> const& strings, std::error_code&)
{
std::string host_part;
std::optional<std::string> opt_port_part;
if (auto it = strings.rbegin(); it != strings.rend()) {
auto first = it->begin();
auto last = it->end();
std::string host_part;
std::optional<std::string> opt_port_part;
auto try_parse_host = [&](auto init)
{
auto c = init;
@ -73,12 +73,12 @@ namespace seafire::protocol::rfc7230
first = try_parse_host(first);
first = try_parse_port(first);
if (first != last) {
return std::nullopt;
if (first == last) {
return {{host_part, opt_port_part}};
}
}
return {{host_part, opt_port_part}};
return std::nullopt;
}
std::string