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

how can I get cookies sent by clients ? #60

Open
jagernicolas opened this issue Jul 24, 2020 · 2 comments
Open

how can I get cookies sent by clients ? #60

jagernicolas opened this issue Jul 24, 2020 · 2 comments

Comments

@jagernicolas
Copy link

from,

auto httpEnterCallback = [&port](const HTTPParser& httpParser,
            const HttpSession::Ptr& session) {
...
});

I try to access cookies, however I haven' t found any method for that.

In the meantime I have seen that HttpRequest has setCookie, I would excpect a symetrical method getCookie somewhere I can access when I receive a request from a client.

@IronsDu
Copy link
Owner

IronsDu commented Jul 24, 2020

Please use httpParser.getValue("cookie") access cookies http header.

@IronsDu
Copy link
Owner

IronsDu commented Jul 24, 2020

const std::string& getValue(const std::string& key) const
{
const static std::string emptystr("");
auto it = mHeadValues.find(key);
if (it != mHeadValues.end())
{
return (*it).second;
}
else
{
return emptystr;
}
}

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

No branches or pull requests

2 participants