minor cleanup
This commit is contained in:
parent
cdf7114f2d
commit
fe90ba9d57
1 changed files with 8 additions and 9 deletions
|
|
@ -18,8 +18,7 @@ namespace SimpleWeb {
|
||||||
std::smatch path_match;
|
std::smatch path_match;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<std::string, std::unordered_map<std::string,
|
typedef std::map<std::string, std::unordered_map<std::string, std::function<void(std::ostream&, Request&)> > > resource_type;
|
||||||
std::function<void(std::ostream&, Request&)> > > resource_type;
|
|
||||||
|
|
||||||
template <class socket_type>
|
template <class socket_type>
|
||||||
class ServerBase {
|
class ServerBase {
|
||||||
|
|
@ -70,9 +69,9 @@ namespace SimpleWeb {
|
||||||
//Created in start()
|
//Created in start()
|
||||||
std::vector<resource_type::iterator> all_resources;
|
std::vector<resource_type::iterator> all_resources;
|
||||||
|
|
||||||
ServerBase(unsigned short port, size_t num_threads, size_t timeout_request, size_t timeout_send_or_receive) : endpoint(boost::asio::ip::tcp::v4(), port),
|
ServerBase(unsigned short port, size_t num_threads, size_t timeout_request, size_t timeout_send_or_receive) :
|
||||||
acceptor(m_io_service, endpoint), num_threads(num_threads), timeout_request(timeout_request),
|
endpoint(boost::asio::ip::tcp::v4(), port), acceptor(m_io_service, endpoint), num_threads(num_threads),
|
||||||
timeout_content(timeout_send_or_receive) {}
|
timeout_request(timeout_request), timeout_content(timeout_send_or_receive) {}
|
||||||
|
|
||||||
virtual void accept()=0;
|
virtual void accept()=0;
|
||||||
|
|
||||||
|
|
@ -231,15 +230,15 @@ namespace SimpleWeb {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<boost::asio::deadline_timer> set_timeout_on_socket(std::shared_ptr<HTTP> socket, size_t seconds) {
|
std::shared_ptr<boost::asio::deadline_timer> set_timeout_on_socket(std::shared_ptr<HTTP> socket, size_t seconds) {
|
||||||
std::shared_ptr<boost::asio::deadline_timer> timeout(new boost::asio::deadline_timer(m_io_service));
|
std::shared_ptr<boost::asio::deadline_timer> timer(new boost::asio::deadline_timer(m_io_service));
|
||||||
timeout->expires_from_now(boost::posix_time::seconds(seconds));
|
timer->expires_from_now(boost::posix_time::seconds(seconds));
|
||||||
timeout->async_wait([socket](const boost::system::error_code& ec){
|
timer->async_wait([socket](const boost::system::error_code& ec){
|
||||||
if(!ec) {
|
if(!ec) {
|
||||||
socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both);
|
socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both);
|
||||||
socket->close();
|
socket->close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return timeout;
|
return timer;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue