Skip to content
Snippets Groups Projects
Commit 0fbebf8e authored by Adrien Béraud's avatar Adrien Béraud
Browse files

http: cleanup, fix handling error when no logger is set

parent 24efa378
Branches
Tags
No related merge requests found
...@@ -758,11 +758,12 @@ Request::connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, HandlerCb cb) ...@@ -758,11 +758,12 @@ Request::connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, HandlerCb cb)
this_.terminate(ec); this_.terminate(ec);
return; return;
} }
else if (ec and this_.logger_) else if (ec) {
this_.logger_->e("[http:request:%i] connect: failed with all endpoints", this_.id_);
else {
if (this_.logger_) if (this_.logger_)
this_.logger_->d("[http:request:%i] connect success", this_.id_); this_.logger_->e("[http:request:%i] connect failed with all endpoints: %s", this_.id_, ec.message().c_str());
} else {
// if (this_.logger_)
// this_.logger_->d("[http:request:%i] connect success", this_.id_);
const auto& url = this_.get_url(); const auto& url = this_.get_url();
auto port = endpoint.port(); auto port = endpoint.port();
...@@ -783,8 +784,8 @@ Request::connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, HandlerCb cb) ...@@ -783,8 +784,8 @@ Request::connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, HandlerCb cb)
return; return;
if (ec and logger) if (ec and logger)
logger->e("[http:request:%i] handshake error: %s", id, ec.message().c_str()); logger->e("[http:request:%i] handshake error: %s", id, ec.message().c_str());
else if (logger) //else if (logger)
logger->d("[http:request:%i] handshake success", id); // logger->d("[http:request:%i] handshake success", id);
if (cb) if (cb)
cb(ec); cb(ec);
}); });
...@@ -889,8 +890,8 @@ Request::handle_request(const asio::error_code& ec) ...@@ -889,8 +890,8 @@ Request::handle_request(const asio::error_code& ec)
terminate(asio::error::not_connected); terminate(asio::error::not_connected);
return; return;
} }
if (logger_) // if (logger_)
logger_->d("[http:request:%i] send success", id_); // logger_->d("[http:request:%i] send success", id_);
// read response // read response
notify_state_change(State::RECEIVING); notify_state_change(State::RECEIVING);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment