Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPRequest needs to be refactored #40

Open
mlanca-c opened this issue Apr 5, 2023 · 0 comments
Open

HTTPRequest needs to be refactored #40

mlanca-c opened this issue Apr 5, 2023 · 0 comments

Comments

@mlanca-c
Copy link
Collaborator

mlanca-c commented Apr 5, 2023

The class HTTPRequest has two problems:

  1. it isn't able to receive a string as a parameter
  2. it doesn't parse the URI or m_resource like we so desperately need (std::regex is from c++11 so a parsing here is necessary to get the host and port)

What I'm proposing here is to refactor this class and create a helper class named URI for the resource that resembles something like this:

struct Uri {

        Uri(std::string uri);
        ~Uri(void);

        std::string toStr(void);
        std::string pathWithRoot(std::string root);

        // std::string m_target;
        std::string m_scheme;
        std::string m_host;
        std::string m_path;
        std::string m_query;
};

and HTTPResponse (only the modifications)

    // (....)
        HTTPResponse(std::string req_str);

    // (....)
        shared_ptr<Uri> m_resource;

    // (....)
@mlanca-c mlanca-c mentioned this issue Apr 5, 2023
@mlanca-c mlanca-c linked a pull request Apr 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant