diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-04-13 16:16:06 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-04-13 16:16:06 +0200 |
commit | 5b3022c4a0e81ff23ce4ebc2ec7b03e32f7a719e (patch) | |
tree | 3f58cc9b9a161e89d0d8e341473714a2acf5ed08 /response.cpp | |
parent | 4732dc63657f4c6fc342f7674f7dc7c666b293dc (diff) |
webbox (WIP)
Diffstat (limited to 'response.cpp')
-rw-r--r-- | response.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/response.cpp b/response.cpp index ffd72b6..a70a694 100644 --- a/response.cpp +++ b/response.cpp @@ -80,6 +80,8 @@ std::unordered_map<std::string, std::function<std::string(RequestContext&)>> Get {"content_length", [](RequestContext& req_ctx) { return std::to_string(req_ctx.GetReq().body().size()); }}, + {"content_type", [](RequestContext& req_ctx) { return std::string{req_ctx.GetReq()["content_type"]}; }}, // TODO: does this work? + {"method", [](RequestContext& req_ctx) { return std::string{req_ctx.GetReq().method_string()};}}, }; @@ -123,8 +125,10 @@ void SetResponseHeader(const std::string& key, const std::string& value, respons res.result(unsigned(stoul(value))); } else if (key == "server") { // Server name/version string res.set(http::field::server, value); - } else if (key == "content_type") { // e.g. text/html + } else if (key == "content_type") { // e.g. text/html res.set(http::field::content_type, value); + } else if (key == "content_disposition") { // e.g. attachment; ... + res.set(http::field::content_disposition, value); } else throw std::runtime_error("Unsupported response field: "s + key); } |