Added option for verify_file in Server-constructor, and certification/key file and verify_file for Client-constructor (Warning: not tested). Also moved set_timeout_on_socket to the ServerBase.

This commit is contained in:
eidheim 2014-11-01 18:18:00 +01:00
commit db365340bf
3 changed files with 28 additions and 28 deletions

View file

@ -87,7 +87,17 @@ namespace SimpleWeb {
virtual void accept()=0;
virtual std::shared_ptr<boost::asio::deadline_timer> set_timeout_on_socket(std::shared_ptr<socket_type> socket, size_t seconds)=0;
std::shared_ptr<boost::asio::deadline_timer> set_timeout_on_socket(std::shared_ptr<socket_type> socket, size_t seconds) {
std::shared_ptr<boost::asio::deadline_timer> timer(new boost::asio::deadline_timer(m_io_service));
timer->expires_from_now(boost::posix_time::seconds(seconds));
timer->async_wait([socket](const boost::system::error_code& ec){
if(!ec) {
socket->lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both);
socket->lowest_layer().close();
}
});
return timer;
}
void read_request_and_content(std::shared_ptr<socket_type> socket) {
//Create new streambuf (Request::streambuf) for async_read_until()
@ -226,18 +236,6 @@ 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> timer(new boost::asio::deadline_timer(m_io_service));
timer->expires_from_now(boost::posix_time::seconds(seconds));
timer->async_wait([socket](const boost::system::error_code& ec){
if(!ec) {
socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both);
socket->close();
}
});
return timer;
}
};
}
#endif /* SERVER_HTTP_HPP */