diff options
author | ipknHama <ipknhama@gmail.com> | 2014-04-01 21:25:16 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2014-04-01 21:25:16 +0900 |
commit | 7056550bbb3a46b5f1ea077999cc3cd374af4b9e (patch) | |
tree | f9126fa815f8c9c1aa1f9a946f881558823560f0 /http_response.h | |
parent | 4b8c67e2300205200f4f846400d73a03cb3da854 (diff) | |
download | crow-7056550bbb3a46b5f1ea077999cc3cd374af4b9e.tar.gz crow-7056550bbb3a46b5f1ea077999cc3cd374af4b9e.zip |
working http server
Diffstat (limited to 'http_response.h')
-rw-r--r-- | http_response.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/http_response.h b/http_response.h new file mode 100644 index 0000000..1221dd2 --- /dev/null +++ b/http_response.h @@ -0,0 +1,40 @@ +#pragma once +#include <string> +#include <unordered_map> + +namespace flask +{ + std::unordered_map<int, std::string> statusCodes = { + {200, "HTTP/1.1 200 OK\r\n"}, + {201, "HTTP/1.1 201 Created\r\n"}, + {202, "HTTP/1.1 202 Accepted\r\n"}, + {204, "HTTP/1.1 204 No Content\r\n"}, + + {300, "HTTP/1.1 300 Multiple Choices\r\n"}, + {301, "HTTP/1.1 301 Moved Permanently\r\n"}, + {302, "HTTP/1.1 302 Moved Temporarily\r\n"}, + {304, "HTTP/1.1 304 Not Modified\r\n"}, + + {400, "HTTP/1.1 400 Bad Request\r\n"}, + {401, "HTTP/1.1 401 Unauthorized\r\n"}, + {403, "HTTP/1.1 403 Forbidden\r\n"}, + {404, "HTTP/1.1 404 Not Found\r\n"}, + + {500, "HTTP/1.1 500 Internal Server Error\r\n"}, + {501, "HTTP/1.1 501 Not Implemented\r\n"}, + {502, "HTTP/1.1 502 Bad Gateway\r\n"}, + {503, "HTTP/1.1 503 Service Unavailable\r\n"}, + }; + + struct response + { + int status = 200; + std::string body; + std::unordered_map<std::string, std::string> headers; + response() {} + response(const std::string& body) : body(body) {} + response(std::string&& body) : body(std::move(body)) {} + response(const std::string& body, int status) : body(body), status(status) {} + response(std::string&& body, int status) : body(std::move(body)), status(status) {} + }; +} |