eidheim / Simple-Web-Server

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
MIT License
2.62k stars 755 forks source link

on_error was triggered with no error message #132

Open manageryzy opened 7 years ago

manageryzy commented 7 years ago
server.on_error = [](std::shared_ptr<HttpServer::Request> request, const boost::system::error_code& e)
{
    std::cout << "Error:" << std::endl << e.message() << std::endl << e.category().name() << std::endl ;
    return; 
};

this would output "Error:" with no error message sometimes

eidheim commented 7 years ago

If there is no message, on_error could be called either here: https://github.com/eidheim/Simple-Web-Server/blob/master/server_http.hpp#L342 or here: https://github.com/eidheim/Simple-Web-Server/blob/master/server_http.hpp#L476.

manageryzy commented 7 years ago
  asio::async_read_until(*socket, request->streambuf, "\r\n\r\n",
                     [this, socket, request, timer](const error_code& ec, size_t bytes_transferred)

in void read_request_and_content(const std::shared_ptr<socket_type> &socket) got ec true

if I try to print e.message, the console will not output anything more.

compiler: ICC 17 IDE: vs2015 boost: 1.62.0

eidheim commented 7 years ago

What error code type are you getting? Might be that not all error code types have messages, although that is a bit strange. It might also be an boost asio issue on Windows I'm thinking.

manageryzy commented 7 years ago

m_val = 0x400f7ea0 m_cat = 0x00000001400f7ea0 {NetNew.exe!std::_Func_impl<std::decay<lambda [] type at line 508171, col. 20>::type, std::allocator, void, std::shared_ptr<SimpleWeb::ServerBase::Request>, const SimpleWeb::error_code &>::Move(void *)} {...} boost::noncopyable::noncopyable = {...}

maybe this a bug of boost asio