diff options
author | ipknHama <ipknhama@gmail.com> | 2016-08-28 14:46:31 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2016-08-28 14:46:31 +0900 |
commit | 967adf0de55afcb52881cdb1a7b16788c7c283db (patch) | |
tree | dbe4fe620a136bdb462a4ad29e83d6d699b3b447 /include/http_connection.h | |
parent | 45f6d12fd382662675000fb1c60909287733127c (diff) | |
download | crow-967adf0de55afcb52881cdb1a7b16788c7c283db.tar.gz crow-967adf0de55afcb52881cdb1a7b16788c7c283db.zip |
Add websocket feature
Diffstat (limited to 'include/http_connection.h')
-rw-r--r-- | include/http_connection.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/http_connection.h b/include/http_connection.h index 2bc6906..5517521 100644 --- a/include/http_connection.h +++ b/include/http_connection.h @@ -256,6 +256,7 @@ namespace crow req_ = std::move(parser_.to_request()); request& req = req_; + if (parser_.check_version(1, 0)) { // HTTP/1.0 @@ -282,6 +283,20 @@ namespace crow is_invalid_request = true; res = response(400); } + if (parser_.is_upgrade()) + { + if (req.get_header_value("upgrade") == "h2c") + { + // TODO HTTP/2 + // currently, ignore upgrade header + } + else + { + close_connection_ = true; + handler_->handle_upgrade(req, res, std::move(adaptor_)); + return; + } + } } CROW_LOG_INFO << "Request: " << boost::lexical_cast<std::string>(adaptor_.remote_endpoint()) << " " << this << " HTTP/" << parser_.http_major << "." << parser_.http_minor << ' ' @@ -296,6 +311,7 @@ namespace crow ctx_ = detail::context<Middlewares...>(); req.middleware_context = (void*)&ctx_; + req.io_service = &adaptor_.get_io_service(); detail::middleware_call_helper<0, decltype(ctx_), decltype(*middlewares_), Middlewares...>(*middlewares_, req, res, ctx_); if (!res.completed_) |