Problem with casting in server_http.hpp file
When you give the server a GET / HTTP/notANumber
it crashes and sends a invalid argument. This happens because of string to float conversion in the server_http.hpp file.
OS: Ubuntu 18.04
To recreate:
telnet localhost 8080
GET / HTTP/someword
terminate called after throwing an instance of 'std::invalid_argument'
what(): stof
Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffff705f8b1 in __GI_abort () at abort.c:79
#2 0x00007ffff76b4957 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff76baae6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff76bab21 in std::terminate() ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff76bad54 in __cxa_throw ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff76b67eb in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00005555556625b3 in float __gnu_cxx::__stoa<float, float, char>(float (*)(char const*, char**), char const*, char const*, unsigned long*) ()
#8 0x0000555555655a5a in std::__cxx11::stof(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long*) ()
#9 0x000055555566f55f in SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::write(std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Session> const&, std::function<void (std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response>, std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Request>)>&)::{lambda(SimpleWeb::ServerBase<boost::asio::basic_str---Type <return> to continue, or q <return> to quit---
am_socket_service<boost::asio::ip::tcp> > >::Response*)#1}::operator()(SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response*) const::{lambda(boost::system::error_code const&)#1}::operator()(boost::system::error_code const) const ()
#10 0x000055555567b594 in std::_Function_handler<void (boost::system::error_code const&), SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::write(std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Session> const&, std::function<void (std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response>, std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Request>)>&)::{lambda(SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response*)#1}::operator()(SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response*) const::{lambda(boost::system::error_code const&)#1}>::_M_invoke(std::_Any_data const&, boost::system::error_code const&) ()
#11 0x000055555567b719 in std::function<void (boost::system::error_code const&)>::operator()(boost::system::error_code const&) const ()
#12 0x000055555567516b in SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}::operator()(boost::system::error_code const&, unsigned long) const ()
#13 0x00005555556870f7 in boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}>::operator()(boost::system::error_code const&, unsigned long) ()
#14 0x0000555555683a0f in boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >::operator()(boost::system::error_code const&, unsigned long, int) ()
#15 0x00005555556af46e in boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>::operator()() ()
#16 0x00005555556ae3b3 in void boost::asio::asio_handler_invoke<boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long> >(boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const---Type <return> to continue, or q <return> to quit---
_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>&, ...) ()
#17 0x00005555556ac61f in void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>, {lambda(boost::system::error_code const&, unsigned long)#1}>(boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>&, {lambda(boost::system::error_code const&, unsigned long)#1}&) ()
#18 0x00005555556aa71b in void boost::asio::detail::asio_handler_invoke<boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>, std::allocator<char>, {lambda(boost::system::error_code const&, unsigned long)#1}>(boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>&, boost::asio::detail::write_streambuf_handler<std::allocator<char>, {lambda(boost::system::error_code const&, unsigned long)#1}>*) ()
#19 0x00005555556a71fb in void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}>(boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boo---Type <return> to continue, or q <return> to quit---
st::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>&, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}&) ()
#20 0x00005555556a1790 in void boost::asio::detail::asio_handler_invoke<boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}>(boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>&, boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}>*) ()
#21 0x000055555569c910 in void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >(boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>&, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}>&) ()
#22 0x00005555556983aa in boost::asio::detail::reactive_socket_send_op<boost::asio::const_buffers_1, boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::tra---Type <return> to continue, or q <return> to quit---
nsfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> > >::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long) ()
#23 0x0000555555658170 in boost::asio::detail::task_io_service_operation::complete(boost::asio::detail::task_io_service&, boost::system::error_code const&, unsigned long) ()
#24 0x000055555565b0f5 in boost::asio::detail::task_io_service::do_run_one(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&, boost::asio::detail::task_io_service_thread_info&, boost::system::error_code const&) ()
#25 0x000055555565aab1 in boost::asio::detail::task_io_service::run(boost::system::error_code&) ()
#26 0x000055555565b3b4 in boost::asio::io_service::run() ()
#27 0x000055555566722d in SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::start(std::function<void (unsigned short)> const&) ()
#28 0x0000555555654fd3 in main ()