diff options
author | ipknHama <ipknhama@gmail.com> | 2014-09-11 06:32:41 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2014-09-11 06:32:41 +0900 |
commit | 9eb96b7f4c2e134e768555de2650823a863843ce (patch) | |
tree | 87797876b1a8bdf12f11d31e2fa28fc462075610 /include/http_response.h | |
parent | ab1063c046b363a37ccaf91c7dfb1fecd279be36 (diff) | |
download | crow-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.h | 22 |
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) {} |