diff options
author | ipknHama <ipknhama@gmail.com> | 2014-05-02 18:22:02 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2014-07-09 14:08:02 +0900 |
commit | 23f9b528586610c43be8bccbe50e978afd47dfec (patch) | |
tree | f124d0f19990bf94ff2f79520ad7df50780468ea /http_connection.h | |
parent | 31d2e07bc2e8660f6a8e4fe5f29b5d3b9e275ed1 (diff) | |
download | crow-23f9b528586610c43be8bccbe50e978afd47dfec.tar.gz crow-23f9b528586610c43be8bccbe50e978afd47dfec.zip |
fix old naming, check for host header
Diffstat (limited to 'http_connection.h')
-rw-r--r-- | http_connection.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/http_connection.h b/http_connection.h index 4d39641..5da294d 100644 --- a/http_connection.h +++ b/http_connection.h @@ -58,6 +58,8 @@ namespace crow {503, "HTTP/1.1 503 Service Unavailable\r\n"}, }; + bool is_invalid_request = false; + request req = parser_.to_request(); if (parser_.http_major == 1 && parser_.http_minor == 0) { @@ -65,14 +67,22 @@ namespace crow if (!(req.headers.count("connection") && boost::iequals(req.headers["connection"],"Keep-Alive"))) close_connection_ = true; } - else + else if (parser_.http_major == 1 && parser_.http_minor == 1) { // HTTP/1.1 if (req.headers.count("connection") && req.headers["connection"] == "close") close_connection_ = true; + if (!req.headers.count("host")) + { + is_invalid_request = true; + res = response(400); + } } - res = handler_->handle(req); + if (!is_invalid_request) + { + res = handler_->handle(req); + } CROW_LOG_INFO << "HTTP/" << parser_.http_major << "." << parser_.http_minor << ' ' << method_name(req.method) << " " << req.url |