Fix http request issue when path empty from url

Ensure path can be use for http request directly
This commit is contained in:
halx99 2023-01-04 21:26:01 +08:00
parent 28eb9e1886
commit 427ae694bd
1 changed files with 5 additions and 4 deletions

View File

@ -174,7 +174,7 @@ bool Uri::doParse(std::string_view str)
}
bool hasScheme = true;
;
std::string copied(str);
if (copied.find("://") == std::string::npos)
{
@ -258,6 +258,10 @@ bool Uri::doParse(std::string_view str)
_authority.append(::toString(getPort()));
}
// Ensure path can be use for http request directly
if (_path.empty())
_path.push_back('/');
// Assign path etc part
_pathEtc = _path;
if (!_query.empty())
@ -314,9 +318,6 @@ bool Uri::doParse(std::string_view str)
else
_isCustomPort = _port != 0;
if (_path.empty())
_path.push_back('/');
return true;
}