Rewrite Host parsing
This commit is contained in:
parent
22dd4500e4
commit
667052834b
@ -33,13 +33,13 @@ namespace seafire::protocol::rfc7230
|
|||||||
host_t::
|
host_t::
|
||||||
try_parse(std::vector<std::string> const& strings, std::error_code&)
|
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()) {
|
if (auto it = strings.rbegin(); it != strings.rend()) {
|
||||||
auto first = it->begin();
|
auto first = it->begin();
|
||||||
auto last = it->end();
|
auto last = it->end();
|
||||||
|
|
||||||
|
std::string host_part;
|
||||||
|
std::optional<std::string> opt_port_part;
|
||||||
|
|
||||||
auto try_parse_host = [&](auto init)
|
auto try_parse_host = [&](auto init)
|
||||||
{
|
{
|
||||||
auto c = init;
|
auto c = init;
|
||||||
@ -73,12 +73,12 @@ namespace seafire::protocol::rfc7230
|
|||||||
first = try_parse_host(first);
|
first = try_parse_host(first);
|
||||||
first = try_parse_port(first);
|
first = try_parse_port(first);
|
||||||
|
|
||||||
if (first != last) {
|
if (first == last) {
|
||||||
return std::nullopt;
|
return {{host_part, opt_port_part}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {{host_part, opt_port_part}};
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user