From 0fbebf8e039c242208697108feddb5a0744d9867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Sun, 8 Dec 2019 01:04:03 -0500 Subject: [PATCH] http: cleanup, fix handling error when no logger is set --- src/http.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/http.cpp b/src/http.cpp index aadab647..c6698a48 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -758,11 +758,12 @@ Request::connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, HandlerCb cb) this_.terminate(ec); return; } - else if (ec and this_.logger_) - this_.logger_->e("[http:request:%i] connect: failed with all endpoints", this_.id_); - else { + else if (ec) { 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(); auto port = endpoint.port(); @@ -783,8 +784,8 @@ Request::connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, HandlerCb cb) return; if (ec and logger) logger->e("[http:request:%i] handshake error: %s", id, ec.message().c_str()); - else if (logger) - logger->d("[http:request:%i] handshake success", id); + //else if (logger) + // logger->d("[http:request:%i] handshake success", id); if (cb) cb(ec); }); @@ -889,8 +890,8 @@ Request::handle_request(const asio::error_code& ec) terminate(asio::error::not_connected); return; } - if (logger_) - logger_->d("[http:request:%i] send success", id_); + // if (logger_) + // logger_->d("[http:request:%i] send success", id_); // read response notify_state_change(State::RECEIVING); -- GitLab