aboutsummaryrefslogtreecommitdiffstats
path: root/include/http_response.h
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2014-09-11 06:32:41 +0900
committeripknHama <ipknhama@gmail.com>2014-09-11 06:32:41 +0900
commit9eb96b7f4c2e134e768555de2650823a863843ce (patch)
tree87797876b1a8bdf12f11d31e2fa28fc462075610 /include/http_response.h
parentab1063c046b363a37ccaf91c7dfb1fecd279be36 (diff)
downloadcrow-9eb96b7f4c2e134e768555de2650823a863843ce.tar.gz
crow-9eb96b7f4c2e134e768555de2650823a863843ce.zip
Implement example CookieParser middleware and test
Diffstat (limited to 'include/http_response.h')
-rw-r--r--include/http_response.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/include/http_response.h b/include/http_response.h
index bc468b7..69c6d72 100644
--- a/include/http_response.h
+++ b/include/http_response.h
@@ -2,6 +2,8 @@
#include <string>
#include <unordered_map>
#include "json.h"
+#include "http_request.h"
+#include "ci_map.h"
namespace crow
{
@@ -15,7 +17,25 @@ namespace crow
std::string body;
json::wvalue json_value;
int code{200};
- std::unordered_map<std::string, std::string> headers;
+
+ // `headers' stores HTTP headers.
+ ci_map headers;
+
+ void set_header(std::string key, std::string value)
+ {
+ headers.erase(key);
+ headers.emplace(std::move(key), std::move(value));
+ }
+ void add_header(std::string key, std::string value)
+ {
+ headers.emplace(std::move(key), std::move(value));
+ }
+
+ const std::string& get_header_value(const std::string& key)
+ {
+ return crow::get_header_value(headers, key);
+ }
+
response() {}
explicit response(int code) : code(code) {}