@@ -163,6 +163,7 @@ class http_response
163163 filename (b.filename),
164164 headers (b.headers),
165165 footers (b.footers),
166+ cookies (b.cookies),
166167 topics (b.topics),
167168 keepalive_secs (b.keepalive_secs),
168169 keepalive_msg (b.keepalive_msg),
@@ -184,6 +185,7 @@ class http_response
184185 filename = b.filename ;
185186 headers = b.headers ;
186187 footers = b.footers ;
188+ cookies = b.cookies ;
187189 topics = b.topics ;
188190 keepalive_secs = b.keepalive_secs ;
189191 keepalive_msg = b.keepalive_msg ;
@@ -258,6 +260,14 @@ class http_response
258260 {
259261 result = this ->footers [key];
260262 }
263+ const std::string get_cookie (const std::string& key)
264+ {
265+ return this ->cookies [key];
266+ }
267+ void get_cookie (const std::string& key, std::string& result)
268+ {
269+ result = this ->cookies [key];
270+ }
261271 /* *
262272 * Method used to set an header value by key.
263273 * @param key The name identifying the header
@@ -276,6 +286,10 @@ class http_response
276286 {
277287 this ->footers [key] = value;
278288 }
289+ void set_cookie (const std::string& key, const std::string& value)
290+ {
291+ this ->cookies [key] = value;
292+ }
279293 /* *
280294 * Method used to set the content type for the request. This is a shortcut of setting the corresponding header.
281295 * @param content_type the content type to use for the request
@@ -292,6 +306,14 @@ class http_response
292306 {
293307 this ->headers .erase (key);
294308 }
309+ void remove_footer (const std::string& key)
310+ {
311+ this ->footers .erase (key);
312+ }
313+ void remove_cookie (const std::string& key)
314+ {
315+ this ->cookies .erase (key);
316+ }
295317 /* *
296318 * Method used to get all headers passed with the request.
297319 * @return a map<string,string> containing all headers.
@@ -309,6 +331,11 @@ class http_response
309331 size_t get_footers (std::vector<std::pair<std::string, std::string> >& result);
310332#ifndef SWIG
311333 size_t get_footers (std::map<std::string, std::string, header_comparator>& result);
334+ #endif
335+ const std::vector<std::pair<std::string, std::string> > get_cookies ();
336+ size_t get_cookies (std::vector<std::pair<std::string, std::string> >& result);
337+ #ifndef SWIG
338+ size_t get_cookies (std::map<std::string, std::string, header_comparator>& result);
312339#endif
313340 /* *
314341 * Method used to set all headers of the response.
@@ -330,6 +357,12 @@ class http_response
330357 for (it = footers.begin (); it != footers.end (); ++it)
331358 this ->footers [it->first ] = it->second ;
332359 }
360+ void set_cookies (const std::map<std::string, std::string>& cookies)
361+ {
362+ std::map<std::string, std::string>::const_iterator it;
363+ for (it = cookies.begin (); it != cookies.end (); ++it)
364+ this ->cookies [it->first ] = it->second ;
365+ }
333366 /* *
334367 * Method used to set the response code of the response
335368 * @param response_code the response code to set
@@ -392,6 +425,7 @@ class http_response
392425 std::string filename;
393426 std::map<std::string, std::string, header_comparator> headers;
394427 std::map<std::string, std::string, header_comparator> footers;
428+ std::map<std::string, std::string, header_comparator> cookies;
395429 std::vector<std::string> topics;
396430 int keepalive_secs;
397431 std::string keepalive_msg;
0 commit comments