aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2014-04-17 18:18:02 +0900
committeripknHama <ipknhama@gmail.com>2014-04-17 18:19:06 +0900
commitaf6bc11fb4360ca8a1f244283e51065ee38ffc80 (patch)
treed60fc78b54a116b9521041ee98c62bef9ca0ba5f
parent9ee37ce4bf664166807ff02b61d2e18181c4c1f9 (diff)
downloadcrow-af6bc11fb4360ca8a1f244283e51065ee38ffc80.tar.gz
crow-af6bc11fb4360ca8a1f244283e51065ee38ffc80.zip
resolve linking problem
-rw-r--r--common.h8
-rw-r--r--http_connection.h50
-rw-r--r--http_response.h22
3 files changed, 37 insertions, 43 deletions
diff --git a/common.h b/common.h
index c028ee4..d222738 100644
--- a/common.h
+++ b/common.h
@@ -45,25 +45,25 @@ namespace flask
};
template<>
- int64_t routing_params::get<int64_t>(unsigned index) const
+ inline int64_t routing_params::get<int64_t>(unsigned index) const
{
return int_params[index];
}
template<>
- uint64_t routing_params::get<uint64_t>(unsigned index) const
+ inline uint64_t routing_params::get<uint64_t>(unsigned index) const
{
return uint_params[index];
}
template<>
- double routing_params::get<double>(unsigned index) const
+ inline double routing_params::get<double>(unsigned index) const
{
return double_params[index];
}
template<>
- std::string routing_params::get<std::string>(unsigned index) const
+ inline std::string routing_params::get<std::string>(unsigned index) const
{
return string_params[index];
}
diff --git a/http_connection.h b/http_connection.h
index a1a810c..3e1ae62 100644
--- a/http_connection.h
+++ b/http_connection.h
@@ -29,6 +29,28 @@ namespace flask
void handle()
{
+ static 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"},
+ };
+
request req = parser_.to_request();
res = handler_->handle(req);
@@ -45,7 +67,7 @@ namespace flask
buffers_.emplace_back(status.data(), status.size());
}
- if (res.code > 400 && res.body.empty())
+ if (res.code >= 400 && res.body.empty())
res.body = statusCodes[res.code].substr(9);
bool has_content_length = false;
@@ -103,18 +125,16 @@ namespace flask
if (!ec)
{
bool ret = parser_.feed(buffer_.data(), bytes_transferred);
- if (ret)
- do_read();
- else
- {
- socket_.close();
-
- life_--;
- if ((int)life_ == 0)
- {
- delete this;
- }
- }
+ if (ret)
+ do_read();
+ else
+ {
+ socket_.close();
+
+ life_--;
+ if ((int)life_ == 0)
+ delete this;
+ }
}
else
{
@@ -123,9 +143,7 @@ namespace flask
life_--;
if ((int)life_ == 0)
- {
delete this;
- }
}
});
}
@@ -153,9 +171,7 @@ namespace flask
socket_.close();
life_--;
if ((int)life_ == 0)
- {
delete this;
- }
}
});
}
diff --git a/http_response.h b/http_response.h
index 9cbfd02..f0acd9e 100644
--- a/http_response.h
+++ b/http_response.h
@@ -4,28 +4,6 @@
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
{
std::string body;