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