diff --git a/map/booking_api.cpp b/map/booking_api.cpp index ec1568ab60..d852fc860c 100644 --- a/map/booking_api.cpp +++ b/map/booking_api.cpp @@ -1,7 +1,5 @@ #include "map/booking_api.hpp" -#include "platform/http_request.hpp" - #include "base/gmtime.hpp" #include "base/logging.hpp" @@ -47,7 +45,7 @@ void BookingApi::GetMinPrice(string const & hotelId, string const & currency, {"currency_code", currency}, {"arrival_date", dateArrival}, {"departure_date", dateDeparture}}); - auto const callback = [fn, currency](downloader::HttpRequest & answer) + auto const callback = [this, fn, currency](downloader::HttpRequest & answer) { string minPrice; @@ -96,9 +94,10 @@ void BookingApi::GetMinPrice(string const & hotelId, string const & currency, priceCurrency.clear(); } fn(minPrice, priceCurrency); + m_request.reset(); }; - downloader::HttpRequest::Get(url, callback); + m_request.reset(downloader::HttpRequest::Get(url, callback)); } string BookingApi::MakeApiUrl(string const & func, diff --git a/map/booking_api.hpp b/map/booking_api.hpp index 1cd45a012c..76fef16c7c 100644 --- a/map/booking_api.hpp +++ b/map/booking_api.hpp @@ -1,9 +1,11 @@ #pragma once +#include "platform/http_request.hpp" + #include "std/function.hpp" #include "std/initializer_list.hpp" -#include "std/map.hpp" #include "std/string.hpp" +#include "std/unique_ptr.hpp" #include "std/utility.hpp" class BookingApi @@ -21,5 +23,6 @@ public: function const & fn); protected: + unique_ptr m_request; string MakeApiUrl(string const & func, initializer_list> const & params); };