Skip to content

Commit 92690e4

Browse files
author
Sebastiano Merlino
committed
Added get single cookie method
1 parent b3786d8 commit 92690e4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/httpserver/http_request.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,22 @@ class http_request
204204
else
205205
result = "";
206206
}
207+
const std::string get_cookie(const std::string& key) const
208+
{
209+
std::map<std::string, std::string>::const_iterator it = this->cookies.find(key);
210+
if(it != this->cookies.end())
211+
return it->second;
212+
else
213+
return "";
214+
}
215+
void get_cookie(const std::string& key, std::string& result) const
216+
{
217+
std::map<std::string, std::string>::const_iterator it = this->cookies.find(key);
218+
if(it != this->cookies.end())
219+
result = it->second;
220+
else
221+
result = "";
222+
}
207223
/**
208224
* Method used to get a specific footer passed with the request.
209225
* @param key the specific footer to get the value from

0 commit comments

Comments
 (0)