From 26a4f0d859286ebfb431f2413dfe3c39e1aa589e Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 2 Jul 2019 12:23:18 +0300 Subject: [PATCH] MXS-2446 Provide access to used urls Makes it possible to later verify that results are for the urls one expects them to be. --- maxutils/maxbase/include/maxbase/http.hh | 12 ++++++++++++ maxutils/maxbase/src/http.cc | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/maxutils/maxbase/include/maxbase/http.hh b/maxutils/maxbase/include/maxbase/http.hh index fcf5a2e03..d38297cad 100644 --- a/maxutils/maxbase/include/maxbase/http.hh +++ b/maxutils/maxbase/include/maxbase/http.hh @@ -172,6 +172,8 @@ public: virtual long wait_no_more_than() const = 0; virtual const std::vector& results() const = 0; + + virtual const std::vector& urls() const = 0; }; /** @@ -258,6 +260,16 @@ public: return m_sImp->results(); } + /** + * The URLs the async operation was invoked with. + * + * @return Vector of urls. + */ + const std::vector& urls() const + { + return m_sImp->urls(); + } + public: Async(const std::shared_ptr& sImp) : m_sImp(sImp) diff --git a/maxutils/maxbase/src/http.cc b/maxutils/maxbase/src/http.cc index f6672eb42..c3853f296 100644 --- a/maxutils/maxbase/src/http.cc +++ b/maxutils/maxbase/src/http.cc @@ -197,14 +197,20 @@ public: return 0; } - const std::vector& results() const + const vector& results() const { return m_results; } + const vector& urls() const + { + return m_urls; + } + private: Async::status_t m_status; vector m_results; + vector m_urls; }; class HttpImp : public Async::Imp @@ -248,6 +254,8 @@ public: { mxb_assert(m_status == Async::ERROR); + m_urls = urls; + m_results.reserve(urls.size()); m_errbufs.reserve(urls.size()); @@ -417,11 +425,16 @@ public: return m_wait_no_more_than; } - const std::vector& results() const + const vector& results() const { return m_results; } + const vector& urls() const + { + return m_urls; + } + private: void update_timeout() { @@ -441,6 +454,7 @@ private: unordered_map m_curls; int m_still_running; long m_wait_no_more_than; + vector m_urls; }; }