ClickHouse/src/IO/WriteBufferFromHTTP.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.4 KiB
C++
Raw Normal View History

2018-06-15 07:05:14 +00:00
#include <IO/WriteBufferFromHTTP.h>
2022-04-27 15:05:45 +00:00
#include <Common/logger_useful.h>
2018-06-15 07:05:14 +00:00
2018-06-16 05:54:06 +00:00
2018-06-15 07:05:14 +00:00
namespace DB
{
2018-06-16 05:54:06 +00:00
2018-06-15 07:05:14 +00:00
WriteBufferFromHTTP::WriteBufferFromHTTP(
2024-03-03 13:22:40 +00:00
const HTTPConnectionGroupType & connection_group,
2021-12-06 08:31:47 +00:00
const Poco::URI & uri,
const std::string & method,
const std::string & content_type,
2022-02-12 02:43:53 +00:00
const std::string & content_encoding,
const HTTPHeaderEntries & additional_headers,
2021-12-06 08:20:10 +00:00
const ConnectionTimeouts & timeouts,
Add global proxy setting (#51749) * initial impl * fix env ut * move ut directory * make sure no null proxy resolver is returned by ProxyConfigurationResolverProvider * minor adjustment * add a few tests, still incomplete * add proxy support for url table function * use proxy for select from url as well * remove optional from return type, just returns empty config * fix style * style * black * ohg boy * rm in progress file * god pls don't let me kill anyone * ... * add use_aws guards * remove hard coded s3 proxy resolver * add concurrency-mt-unsafe * aa * black * add logging back * revert change * imrpove code a bit * helper functions and separate tests * for some reason, this env test is not working.. * formatting * :) * clangtidy * lint * revert some stupid things * small test adjusmtments * simplify tests * rename test * remove extra line * freaking style change * simplify a bit * fix segfault & remove an extra call * tightly couple proxy provider with context.. * remove useless include * rename config prefix parameter * simplify provider a bit * organize provider a bit * add a few comments * comment out proxy env tests * fix nullptr in unit tests * make sure old storage proxy config is properly covered without global context instance * move a few functions from class to anonymous namespace * fix no fallback for specific storage conf * change API to accept http method instead of bool * implement http/https distinction in listresolver, any still not implemented * implement http/https distinction in remote resolver * progress on code, improve tests and add url function working test * use protcol instead of method for http and https * small fix * few more adjustments * fix style * black * move enum to proxyconfiguration * wip * fix build * fix ut * delete atomicroundrobin class * remove stale include * add some tests.. need to spend some more time on the design.. * change design a bit * progress * use existing context for tests * rename aux function and fix ut * .. * rename test * try to simplify tests a bit * simplify tests a bit more * attempt to fix tests, accept more than one remote resolver * use proper log id * try waiting for resolver * proper wait logic * black * empty * address a few comments * refactor tests * remove old tests * baclk * use RAII to set/unset env * black * clang tidy * fix env proxy not respecting any * use log trace * fix wrong logic in getRemoteREsolver * fix wrong logic in getRemoteREsolver * fix test * remove unwanted code * remove ClientConfigurationperRequest and auxilary classes * remove unwanted code * remove adapter test * few adjustments and add test for s3 storage conf with new proxy settings * black * use chassert for context * Add getenv comment
2023-08-24 13:07:26 +00:00
size_t buffer_size_,
2024-03-03 13:22:40 +00:00
ProxyConfiguration proxy_configuration
)
2018-06-15 07:05:14 +00:00
: WriteBufferFromOStream(buffer_size_)
2024-03-03 13:22:40 +00:00
, session{makeHTTPSession(connection_group, uri, timeouts, proxy_configuration)}
2018-06-15 07:05:14 +00:00
, request{method, uri.getPathAndQuery(), Poco::Net::HTTPRequest::HTTP_1_1}
{
request.setHost(uri.getHost());
request.setChunkedTransferEncoding(true);
if (!content_type.empty())
{
request.set("Content-Type", content_type);
}
2022-02-12 02:43:53 +00:00
if (!content_encoding.empty())
request.set("Content-Encoding", content_encoding);
2022-02-11 09:45:49 +00:00
for (const auto & header: additional_headers)
request.add(header.name, header.value);
2024-01-23 17:04:50 +00:00
LOG_TRACE((getLogger("WriteBufferToHTTP")), "Sending request to {}", uri.toString());
2018-06-15 07:05:14 +00:00
ostr = &session->sendRequest(request);
}
2018-06-16 05:54:06 +00:00
2021-11-10 22:58:56 +00:00
void WriteBufferFromHTTP::finalizeImpl()
2018-06-15 07:05:14 +00:00
{
// Make sure the content in the buffer has been flushed
this->next();
2022-02-11 09:45:49 +00:00
receiveResponse(*session, request, response, false);
2018-06-16 05:54:06 +00:00
/// TODO: Response body is ignored.
2018-06-15 07:05:14 +00:00
}
2018-06-16 05:54:06 +00:00
2018-06-15 07:05:14 +00:00
}