server_http.hpp fails to complie on g++ 7.1
Created by: sergeken
compiling server_http.hpp with g++ 7.1 gives the following error messages: ../../Prometheus/src/web_services/server_http.hpp:278:44: error: uninitialized variable ‘content_length’ in ‘constexpr’ function unsigned long long content_length; ^~~~~~~~~~~~~~
Changing the try-catch block as following fixes the issue.
if(it!=request->header.end()) {
try {
unsigned long long content_length = stoull(it->second);
if(content_length>num_additional_bytes) {
//Set timeout on the following boost::asio::async-read or write function
auto timer=this->get_timeout_timer(socket, config.timeout_content);
boost::asio::async_read(*socket, request->streambuf,
boost::asio::transfer_exactly(content_length-num_additional_bytes),
[this, socket, request, timer]
(const boost::system::error_code& ec, size_t /*bytes_transferred*/) {
if(timer)
timer->cancel();
if(!ec)
this->find_resource(socket, request);
else if(on_error)
on_error(request, ec);
});
}
else
this->find_resource(socket, request);
}
catch(const std::exception &e) {
if(on_error)
on_error(request, boost::system::error_code(boost::system::errc::protocol_error, boost::system::generic_category()));
return;
}
}