diff --git a/dbms/src/Dictionaries/HTTPDictionarySource.cpp b/dbms/src/Dictionaries/HTTPDictionarySource.cpp index 58c11bac3ab..9099d7de72c 100644 --- a/dbms/src/Dictionaries/HTTPDictionarySource.cpp +++ b/dbms/src/Dictionaries/HTTPDictionarySource.cpp @@ -29,19 +29,6 @@ HTTPDictionarySource::HTTPDictionarySource(const DictionaryStructure & dict_stru context(context), timeouts(ConnectionTimeouts::getHTTPTimeouts(context.getSettingsRef())) { - if (update_field.empty()) - return; - - std::string tmp_update_field; - Poco::URI::encode(update_field, "&", tmp_update_field); - update_field = tmp_update_field; - - std::string::size_type option = url.substr(0, url.find("#", 0)).find("?"); - - if (option == std::string::npos) - update_field = '?' + update_field; - else - update_field = '&' + update_field; } HTTPDictionarySource::HTTPDictionarySource(const HTTPDictionarySource & other) @@ -57,7 +44,7 @@ HTTPDictionarySource::HTTPDictionarySource(const HTTPDictionarySource & other) { } -std::string HTTPDictionarySource::getUpdateFieldAndDate() +void HTTPDictionarySource::getUpdateFieldAndDate(Poco::URI & uri) { if (update_time != std::chrono::system_clock::from_time_t(0)) { @@ -67,14 +54,14 @@ std::string HTTPDictionarySource::getUpdateFieldAndDate() char buffer [80]; struct tm * timeinfo; timeinfo = localtime (&hr_time); - strftime(buffer, 80, "=%Y-%m-%d%%20%H:%M:%S", timeinfo); + strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", timeinfo); std::string str_time(buffer); - return url.substr(0, url.find("#", 0)) + update_field + str_time; + uri.addQueryParameter(update_field, str_time); } else { update_time = std::chrono::system_clock::now(); - return url.substr(0, url.find("#", 0)) + update_field + "=0000-00-00%2000:00:00"; ///for initial load + uri.addQueryParameter(update_field, "0000-00-00 00:00:00"); } } @@ -90,9 +77,9 @@ BlockInputStreamPtr HTTPDictionarySource::loadAll() BlockInputStreamPtr HTTPDictionarySource::loadUpdatedAll() { - std::string url_update = getUpdateFieldAndDate(); - LOG_TRACE(log, "loadUpdatedAll " + url_update); - Poco::URI uri(url_update); + Poco::URI uri(url); + getUpdateFieldAndDate(uri); + LOG_TRACE(log, "loadUpdatedAll " + uri.toString()); auto in_ptr = std::make_unique(uri, Poco::Net::HTTPRequest::HTTP_GET, ReadWriteBufferFromHTTP::OutStreamCallback(), timeouts); auto input_stream = context.getInputFormat(format, *in_ptr, sample_block, max_block_size); diff --git a/dbms/src/Dictionaries/HTTPDictionarySource.h b/dbms/src/Dictionaries/HTTPDictionarySource.h index 29204bc99c6..ac49cc59e16 100644 --- a/dbms/src/Dictionaries/HTTPDictionarySource.h +++ b/dbms/src/Dictionaries/HTTPDictionarySource.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -43,7 +44,7 @@ public: std::string toString() const override; private: - std::string getUpdateFieldAndDate(); + void getUpdateFieldAndDate(Poco::URI & uri); Poco::Logger * log;