uri encode utils
This commit is contained in:
parent
45572ba95b
commit
a09ff469ee
@ -16,7 +16,7 @@ URI::URI(const HttpRequest &request, const ServerConfig &serverConfig)
|
||||
: uriTrimmed_(utils::trim(request.getTarget(), "/")), config_(matchConfig(uriTrimmed_, serverConfig))
|
||||
{
|
||||
Log::trace(LOCATION);
|
||||
parseUri(request.getTarget());
|
||||
parseUri();
|
||||
Log::debug("Parsed URI: " + uriTrimmed_, {{"ConfigType", config_->getType()}});
|
||||
parseFullpath();
|
||||
|
||||
@ -47,7 +47,7 @@ const AConfig *URI::matchConfig(const std::string &uri, const ServerConfig &serv
|
||||
return bestMatch;
|
||||
}
|
||||
|
||||
void URI::parseUri(const std::string &uri)
|
||||
void URI::parseUri()
|
||||
{
|
||||
if (config_->getType() == "server")
|
||||
{
|
||||
@ -57,9 +57,8 @@ void URI::parseUri(const std::string &uri)
|
||||
{
|
||||
auto const *locConfig = dynamic_cast<LocationConfig const *>(config_);
|
||||
std::string locTrimmed = utils::trim(locConfig->getPath(), "/");
|
||||
std::string uriTrimmed = utils::trim(uri, "/");
|
||||
|
||||
std::string uriSub = uriTrimmed.substr(locTrimmed.length());
|
||||
std::string uriSub = uriTrimmed_.substr(locTrimmed.length());
|
||||
fullPath_ = FileUtils::joinPath(locConfig->get<std::string>("root").value_or(""), uriSub);
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ class URI
|
||||
[[nodiscard]] const std::string &getAuthority() const noexcept;
|
||||
|
||||
private:
|
||||
void parseUri(const std::string &uri);
|
||||
void parseUri();
|
||||
void parseFullpath();
|
||||
|
||||
std::string uriTrimmed_;
|
||||
|
||||
@ -19,4 +19,6 @@ std::vector<std::string> split(const std::string &str, char delimiter);
|
||||
std::string implode(const std::vector<std::string> &elements, const std::string &delimiter);
|
||||
|
||||
uint32_t stateToEpoll(const ASocket::IoState &event);
|
||||
std::string uriEncode(const std::string &value);
|
||||
std::string uriDecode(const std::string &value);
|
||||
} // namespace utils
|
||||
Loading…
Reference in New Issue
Block a user