mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
cosmetic
This commit is contained in:
parent
367a0dcdb4
commit
647568a6f6
@ -38,23 +38,23 @@ HTTPDictionarySource::HTTPDictionarySource(
|
|||||||
|
|
||||||
if (config.has(credentials_prefix))
|
if (config.has(credentials_prefix))
|
||||||
{
|
{
|
||||||
this->credentials.setUsername(config.getString(credentials_prefix + ".user", ""));
|
credentials.setUsername(config.getString(credentials_prefix + ".user", ""));
|
||||||
this->credentials.setPassword(config.getString(credentials_prefix + ".password", ""));
|
credentials.setPassword(config.getString(credentials_prefix + ".password", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto & http_headers_prefix = config_prefix + ".http-headers";
|
const auto & headers_prefix = config_prefix + ".headers";
|
||||||
|
|
||||||
if (config.has(http_headers_prefix))
|
if (config.has(headers_prefix))
|
||||||
{
|
{
|
||||||
Poco::Util::AbstractConfiguration::Keys config_keys;
|
Poco::Util::AbstractConfiguration::Keys config_keys;
|
||||||
config.keys(http_headers_prefix, config_keys);
|
config.keys(headers_prefix, config_keys);
|
||||||
|
|
||||||
this->header_entries.reserve(config_keys.size());
|
header_entries.reserve(config_keys.size());
|
||||||
for (const auto & key : config_keys)
|
for (const auto & key : config_keys)
|
||||||
{
|
{
|
||||||
const auto header_key = config.getString(http_headers_prefix + "." + key + ".name", "");
|
const auto header_key = config.getString(headers_prefix + "." + key + ".name", "");
|
||||||
const auto header_value = config.getString(http_headers_prefix + "." + key + ".value", "");
|
const auto header_value = config.getString(headers_prefix + "." + key + ".value", "");
|
||||||
this->header_entries.emplace_back(std::make_tuple(header_key, header_value));
|
header_entries.emplace_back(std::make_tuple(header_key, header_value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,8 +71,8 @@ HTTPDictionarySource::HTTPDictionarySource(const HTTPDictionarySource & other)
|
|||||||
, context(other.context)
|
, context(other.context)
|
||||||
, timeouts(ConnectionTimeouts::getHTTPTimeouts(context))
|
, timeouts(ConnectionTimeouts::getHTTPTimeouts(context))
|
||||||
{
|
{
|
||||||
this->credentials.setUsername(other.credentials.getUsername());
|
credentials.setUsername(other.credentials.getUsername());
|
||||||
this->credentials.setPassword(other.credentials.getPassword());
|
credentials.setPassword(other.credentials.getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPDictionarySource::getUpdateFieldAndDate(Poco::URI & uri)
|
void HTTPDictionarySource::getUpdateFieldAndDate(Poco::URI & uri)
|
||||||
@ -101,7 +101,7 @@ BlockInputStreamPtr HTTPDictionarySource::loadAll()
|
|||||||
Poco::URI uri(url);
|
Poco::URI uri(url);
|
||||||
auto in_ptr = std::make_unique<ReadWriteBufferFromHTTP>(
|
auto in_ptr = std::make_unique<ReadWriteBufferFromHTTP>(
|
||||||
uri, Poco::Net::HTTPRequest::HTTP_GET, ReadWriteBufferFromHTTP::OutStreamCallback(), timeouts,
|
uri, Poco::Net::HTTPRequest::HTTP_GET, ReadWriteBufferFromHTTP::OutStreamCallback(), timeouts,
|
||||||
0, this->credentials, DBMS_DEFAULT_BUFFER_SIZE, this->header_entries);
|
0, credentials, DBMS_DEFAULT_BUFFER_SIZE, header_entries);
|
||||||
auto input_stream = context.getInputFormat(format, *in_ptr, sample_block, max_block_size);
|
auto input_stream = context.getInputFormat(format, *in_ptr, sample_block, max_block_size);
|
||||||
return std::make_shared<OwningBlockInputStream<ReadWriteBufferFromHTTP>>(input_stream, std::move(in_ptr));
|
return std::make_shared<OwningBlockInputStream<ReadWriteBufferFromHTTP>>(input_stream, std::move(in_ptr));
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ BlockInputStreamPtr HTTPDictionarySource::loadUpdatedAll()
|
|||||||
LOG_TRACE(log, "loadUpdatedAll " + uri.toString());
|
LOG_TRACE(log, "loadUpdatedAll " + uri.toString());
|
||||||
auto in_ptr = std::make_unique<ReadWriteBufferFromHTTP>(
|
auto in_ptr = std::make_unique<ReadWriteBufferFromHTTP>(
|
||||||
uri, Poco::Net::HTTPRequest::HTTP_GET, ReadWriteBufferFromHTTP::OutStreamCallback(), timeouts,
|
uri, Poco::Net::HTTPRequest::HTTP_GET, ReadWriteBufferFromHTTP::OutStreamCallback(), timeouts,
|
||||||
0, this->credentials, DBMS_DEFAULT_BUFFER_SIZE, this->header_entries);
|
0, credentials, DBMS_DEFAULT_BUFFER_SIZE, header_entries);
|
||||||
auto input_stream = context.getInputFormat(format, *in_ptr, sample_block, max_block_size);
|
auto input_stream = context.getInputFormat(format, *in_ptr, sample_block, max_block_size);
|
||||||
return std::make_shared<OwningBlockInputStream<ReadWriteBufferFromHTTP>>(input_stream, std::move(in_ptr));
|
return std::make_shared<OwningBlockInputStream<ReadWriteBufferFromHTTP>>(input_stream, std::move(in_ptr));
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ BlockInputStreamPtr HTTPDictionarySource::loadIds(const std::vector<UInt64> & id
|
|||||||
Poco::URI uri(url);
|
Poco::URI uri(url);
|
||||||
auto in_ptr = std::make_unique<ReadWriteBufferFromHTTP>(
|
auto in_ptr = std::make_unique<ReadWriteBufferFromHTTP>(
|
||||||
uri, Poco::Net::HTTPRequest::HTTP_POST, out_stream_callback, timeouts,
|
uri, Poco::Net::HTTPRequest::HTTP_POST, out_stream_callback, timeouts,
|
||||||
0, this->credentials, DBMS_DEFAULT_BUFFER_SIZE, this->header_entries);
|
0, credentials, DBMS_DEFAULT_BUFFER_SIZE, header_entries);
|
||||||
auto input_stream = context.getInputFormat(format, *in_ptr, sample_block, max_block_size);
|
auto input_stream = context.getInputFormat(format, *in_ptr, sample_block, max_block_size);
|
||||||
return std::make_shared<OwningBlockInputStream<ReadWriteBufferFromHTTP>>(input_stream, std::move(in_ptr));
|
return std::make_shared<OwningBlockInputStream<ReadWriteBufferFromHTTP>>(input_stream, std::move(in_ptr));
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ BlockInputStreamPtr HTTPDictionarySource::loadKeys(const Columns & key_columns,
|
|||||||
Poco::URI uri(url);
|
Poco::URI uri(url);
|
||||||
auto in_ptr = std::make_unique<ReadWriteBufferFromHTTP>(
|
auto in_ptr = std::make_unique<ReadWriteBufferFromHTTP>(
|
||||||
uri, Poco::Net::HTTPRequest::HTTP_POST, out_stream_callback, timeouts,
|
uri, Poco::Net::HTTPRequest::HTTP_POST, out_stream_callback, timeouts,
|
||||||
0, this->credentials, DBMS_DEFAULT_BUFFER_SIZE, this->header_entries);
|
0, credentials, DBMS_DEFAULT_BUFFER_SIZE, header_entries);
|
||||||
auto input_stream = context.getInputFormat(format, *in_ptr, sample_block, max_block_size);
|
auto input_stream = context.getInputFormat(format, *in_ptr, sample_block, max_block_size);
|
||||||
return std::make_shared<OwningBlockInputStream<ReadWriteBufferFromHTTP>>(input_stream, std::move(in_ptr));
|
return std::make_shared<OwningBlockInputStream<ReadWriteBufferFromHTTP>>(input_stream, std::move(in_ptr));
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ private:
|
|||||||
const DictionaryStructure dict_struct;
|
const DictionaryStructure dict_struct;
|
||||||
const std::string url;
|
const std::string url;
|
||||||
Poco::Net::HTTPBasicCredentials credentials;
|
Poco::Net::HTTPBasicCredentials credentials;
|
||||||
ReadWriteBufferFromHTTP::HttpHeaderEntries header_entries;
|
ReadWriteBufferFromHTTP::HTTPHeaderEntries header_entries;
|
||||||
std::string update_field;
|
std::string update_field;
|
||||||
const std::string format;
|
const std::string format;
|
||||||
Block sample_block;
|
Block sample_block;
|
||||||
|
@ -87,8 +87,8 @@ namespace detail
|
|||||||
class ReadWriteBufferFromHTTPBase : public ReadBuffer
|
class ReadWriteBufferFromHTTPBase : public ReadBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using HttpHeaderEntry = std::tuple<std::string, std::string>;
|
using HTTPHeaderEntry = std::tuple<std::string, std::string>;
|
||||||
using HttpHeaderEntries = std::vector<HttpHeaderEntry>;
|
using HTTPHeaderEntries = std::vector<HTTPHeaderEntry>;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Poco::URI uri;
|
Poco::URI uri;
|
||||||
@ -100,7 +100,7 @@ namespace detail
|
|||||||
std::function<void(std::ostream &)> out_stream_callback;
|
std::function<void(std::ostream &)> out_stream_callback;
|
||||||
const Poco::Net::HTTPBasicCredentials & credentials;
|
const Poco::Net::HTTPBasicCredentials & credentials;
|
||||||
std::vector<Poco::Net::HTTPCookie> cookies;
|
std::vector<Poco::Net::HTTPCookie> cookies;
|
||||||
HttpHeaderEntries http_header_entries;
|
HTTPHeaderEntries http_header_entries;
|
||||||
|
|
||||||
std::istream * call(const Poco::URI uri_, Poco::Net::HTTPResponse & response)
|
std::istream * call(const Poco::URI uri_, Poco::Net::HTTPResponse & response)
|
||||||
{
|
{
|
||||||
@ -157,7 +157,7 @@ namespace detail
|
|||||||
OutStreamCallback out_stream_callback_ = {},
|
OutStreamCallback out_stream_callback_ = {},
|
||||||
const Poco::Net::HTTPBasicCredentials & credentials_ = {},
|
const Poco::Net::HTTPBasicCredentials & credentials_ = {},
|
||||||
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE,
|
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE,
|
||||||
HttpHeaderEntries http_header_entries_ = {})
|
HTTPHeaderEntries http_header_entries_ = {})
|
||||||
: ReadBuffer(nullptr, 0)
|
: ReadBuffer(nullptr, 0)
|
||||||
, uri {uri_}
|
, uri {uri_}
|
||||||
, method {!method_.empty() ? method_ : out_stream_callback_ ? Poco::Net::HTTPRequest::HTTP_POST : Poco::Net::HTTPRequest::HTTP_GET}
|
, method {!method_.empty() ? method_ : out_stream_callback_ ? Poco::Net::HTTPRequest::HTTP_POST : Poco::Net::HTTPRequest::HTTP_GET}
|
||||||
@ -243,7 +243,7 @@ public:
|
|||||||
const DB::SettingUInt64 max_redirects = 0,
|
const DB::SettingUInt64 max_redirects = 0,
|
||||||
const Poco::Net::HTTPBasicCredentials & credentials_ = {},
|
const Poco::Net::HTTPBasicCredentials & credentials_ = {},
|
||||||
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE,
|
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE,
|
||||||
const HttpHeaderEntries & http_header_entries_ = {})
|
const HTTPHeaderEntries & http_header_entries_ = {})
|
||||||
: Parent(std::make_shared<UpdatableSession>(uri_, timeouts, max_redirects), uri_, method_, out_stream_callback_, credentials_, buffer_size_, http_header_entries_)
|
: Parent(std::make_shared<UpdatableSession>(uri_, timeouts, max_redirects), uri_, method_, out_stream_callback_, credentials_, buffer_size_, http_header_entries_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -104,10 +104,10 @@ Setting fields:
|
|||||||
|
|
||||||
- `url` – The source URL.
|
- `url` – The source URL.
|
||||||
- `format` – The file format. All the formats described in "[Formats](../../interfaces/formats.md#formats)" are supported.
|
- `format` – The file format. All the formats described in "[Formats](../../interfaces/formats.md#formats)" are supported.
|
||||||
- `credentials` – Basic HTTP authentification.
|
- `credentials` – Basic HTTP authentification. Optional parameter.
|
||||||
- `user` – Username required for the authentification.
|
- `user` – Username required for the authentification.
|
||||||
- `password` – Password required for the authentification.
|
- `password` – Password required for the authentification.
|
||||||
- `http-headers` – All custom HTTP headers entries used for the HTTP request.
|
- `headers` – All custom HTTP headers entries used for the HTTP request. Optional parameter.
|
||||||
- `http-header` – Single HTTP header entry.
|
- `http-header` – Single HTTP header entry.
|
||||||
- `key` – Identifiant name used for the header send on the request.
|
- `key` – Identifiant name used for the header send on the request.
|
||||||
- `value` – Value set for a specific identifiant name.
|
- `value` – Value set for a specific identifiant name.
|
||||||
|
Loading…
Reference in New Issue
Block a user