Remove duplicate code

This commit is contained in:
JaySon-Huang 2023-04-14 18:18:20 +08:00
parent 9eee7c72fe
commit 3795ec2a4c
2 changed files with 14 additions and 26 deletions

View File

@ -96,12 +96,14 @@ namespace
private:
const std::string host;
const UInt16 port;
bool https;
const bool https;
const String proxy_host;
const UInt16 proxy_port;
bool proxy_https;
bool resolve_host;
const bool proxy_https;
const bool resolve_host;
using Base = PoolBase<Poco::Net::HTTPClientSession>;
ObjectPtr allocObject() override
{
auto session = makeHTTPSessionImpl(host, port, https, true, resolve_host);
@ -121,14 +123,14 @@ namespace
public:
SingleEndpointHTTPSessionPool(
const std::string & host_,
UInt16 port_,
bool https_,
const std::string & proxy_host_,
UInt16 proxy_port_,
bool proxy_https_,
size_t max_pool_size_,
bool resolve_host_ = true)
const std::string & host_,
UInt16 port_,
bool https_,
const std::string & proxy_host_,
UInt16 proxy_port_,
bool proxy_https_,
size_t max_pool_size_,
bool resolve_host_ = true)
: Base(static_cast<unsigned>(max_pool_size_), &Poco::Logger::get("HTTPSessionPool"))
, host(host_)
, port(port_)

View File

@ -19,20 +19,6 @@ namespace DB
class HTTPServerResponse;
class SingleEndpointHTTPSessionPool : public PoolBase<Poco::Net::HTTPClientSession>
{
private:
const std::string host;
const UInt16 port;
const bool https;
using Base = PoolBase<Poco::Net::HTTPClientSession>;
ObjectPtr allocObject() override;
public:
SingleEndpointHTTPSessionPool(const std::string & host_, UInt16 port_, bool https_, size_t max_pool_size_);
};
class HTTPException : public Exception
{
public:
@ -66,7 +52,7 @@ private:
const char * className() const noexcept override { return "DB::HTTPException"; }
};
using PooledHTTPSessionPtr = SingleEndpointHTTPSessionPool::Entry;
using PooledHTTPSessionPtr = PoolBase<Poco::Net::HTTPClientSession>::Entry; // SingleEndpointHTTPSessionPool::Entry
using HTTPSessionPtr = std::shared_ptr<Poco::Net::HTTPClientSession>;
void setResponseDefaultHeaders(HTTPServerResponse & response, size_t keep_alive_timeout);