Added 2 url helpers to Request.

This commit is contained in:
Relintai 2021-11-01 00:38:26 +01:00
parent ad4e3bec3c
commit ef7b39bfb1
4 changed files with 37 additions and 0 deletions

View File

@ -200,6 +200,32 @@ void Request::push_path() {
_path_stack_pointer += 1;
}
std::string Request::get_url_root() const {
std::string path = "/";
for (uint32_t i = 0; i < _path_stack_pointer; ++i) {
path += _path_stack[i];
path += "/";
}
return path;
}
std::string Request::get_url_site() const {
std::string path = get_host();
for (uint32_t i = _path_stack_pointer; i < _path_stack.size(); ++i) {
path += _path_stack[i];
path += "/";
}
return path;
}
std::string Request::get_host() const {
return "";
}
void Request::update() {
}

View File

@ -60,6 +60,7 @@ public:
virtual void send_error(int error_code);
virtual void reset();
virtual std::string parser_get_path();
virtual std::string get_host() const;
void setup_url_stack();
std::string get_path() const;
@ -72,6 +73,10 @@ public:
void pop_path();
void push_path();
std::string get_url_root() const;
std::string get_url_site() const;
virtual void update();
virtual void pool();

View File

@ -80,6 +80,11 @@ std::string DRequest::parser_get_path() {
return request->getPath();
}
std::string DRequest::get_host() const {
//todo
return "/";
}
void DRequest::update() {
if (file_next) {
file_next = false;

View File

@ -33,6 +33,7 @@ public:
void send_file(const std::string &p_file_path);
void reset();
std::string parser_get_path();
std::string get_host() const;
void update();